Trying to pass and object variable to a method

I have yet another question. I'm trying to display my output in succession using a next button. The button works and I get what I want using test results, however what I really want to do is pass it a variable instead of using a set number.
I want to be able to pass the object variables myProduct, myOfficeSupplies, and maxNumber to method actionPerformed so they can be in-turn passed to the displayResults method which is called in the actionPerformed method. Since there is no direct call to actionPerformed because it is called within one of the built in methods, I can't tell it to receive and pass those variables. Is there a way to do it without having to pass them through the built-in methods?
import javax.swing.JToolBar;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;
import javax.swing.JPanel;
import java.net.URL;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Panel extends JPanel implements ActionListener
     protected JTextArea myTextArea;
     protected String newline = "\n";
     static final private String FIRST = "first";
     static final private String PREVIOUS = "previous";
     static final private String NEXT = "next";
     public Panel( Product myProduct, OfficeSupplies myOfficeSupplies, int maxNumber )
             super(new BorderLayout());
          int counter = 0;
             //Create the toolbar.
             JToolBar myToolBar = new JToolBar( "Still draggable" );
             addButtons( myToolBar );
             //Create the text area used for output.
             myTextArea = new JTextArea( 450, 190 );
             myTextArea.setEditable( false );
             JScrollPane scrollPane = new JScrollPane( myTextArea );
             //Lay out the main panel.
             setPreferredSize(new Dimension( 450, 190 ));
             add( myToolBar, BorderLayout.PAGE_START );
             add( scrollPane, BorderLayout.CENTER );
          myTextArea.setText( packageData( myProduct, myOfficeSupplies, counter ) );
          setCounter( counter );
     } // End Constructor
     protected void addButtons( JToolBar myToolBar )
             JButton myButton = null;
             //first button
             myButton = makeNavigationButton( FIRST, "Display first record", "First" );
             myToolBar.add(myButton);
             //second button
             myButton = makeNavigationButton( PREVIOUS, "Display previous record", "Previous" );
             myToolBar.add(myButton);
             //third button
             myButton = makeNavigationButton( NEXT, "Display next record", "Next" );
             myToolBar.add(myButton);
     } //End method addButtons
     protected JButton makeNavigationButton( String actionCommand, String toolTipText, String altText )
             //Create and initialize the button.
             JButton myButton = new JButton();
                 myButton.setActionCommand( actionCommand );
             myButton.setToolTipText( toolTipText );
             myButton.addActionListener( this );
               myButton.setText( altText );
             return myButton;
     } // End makeNavigationButton method
         public void actionPerformed( ActionEvent e )
             String cmd = e.getActionCommand();
             // Handle each button.
          if (FIRST.equals(cmd))
          { // first button clicked
                      int counter = 0;
               setCounter( counter );
             else if (PREVIOUS.equals(cmd))
          { // second button clicked
               counter = getCounter();
                  if ( counter == 0 )
                    counter = 5;  // 5 would be replaced with variable maxNumber
                    setCounter( counter );
               else
                    counter = getCounter() - 1;
                    setCounter( counter );
          else if (NEXT.equals(cmd))
          { // third button clicked
               counter = getCounter();
               if ( counter == 5 )  // 5 would be replaced with variable maxNumber
                    counter = 0;
                    setCounter( counter );
                  else
                    counter = getCounter() + 1;
                    setCounter( counter );
             displayResult( counter );
     } // End method actionPerformed
     private int counter;
     public void setCounter( int number ) // Declare setCounter method
          counter = number; // stores the counter
     } // End setCounter method
     public int getCounter()  // Declares getCounter method
          return counter;
     } // End method getCounter
     protected void displayResult( int counter )
          //Test statement
//                 myTextArea.setText( String.format( "%d", counter ) );
          // How can I carry the myProduct and myOfficeSupplies variables into this method?
          myTextArea.setText( packageData( product, officeSupplies, counter ) );
             myTextArea.setCaretPosition(myTextArea.getDocument().getLength());
         } // End method displayResult
     * Create the GUI and show it.  For thread safety,
     * this method should be invoked from the
     * event dispatch thread.
     public void createAndShowGUI( Product myProduct, OfficeSupplies myOfficeSupplies, int maxNumber )
             //Create and set up the window.
             JFrame frame = new JFrame("Products");
             frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             //Add content to the window.
             frame.add(new Panel( myProduct, myOfficeSupplies, maxNumber ));
             //Display the window.
             frame.pack();
             frame.setVisible( true );
         } // End method createAndShowGUI
     public void displayData( Product myProduct, OfficeSupplies myOfficeSupplies, int maxNumber )
          JTextArea myTextArea = new JTextArea(); // textarea to display output
          JFrame JFrame = new JFrame( "Products" );
          // For loop to display data array in a single Window
          for ( int counter = 0; counter < maxNumber; counter++ )  // Loop for displaying each product
               myTextArea.append( packageData( myProduct, myOfficeSupplies, counter ) + "\n\n" );
               JFrame.add( myTextArea ); // add textarea to JFrame
          } // End For Loop
          JScrollPane scrollPane = new JScrollPane( myTextArea ); //Creates the JScrollPane
          JFrame.setPreferredSize(new Dimension(350, 170)); // Sets the pane size
          JFrame.add(scrollPane, BorderLayout.CENTER); // adds scrollpane to JFrame
          JFrame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); // Sets program to exit on close
          JFrame.setSize( 350, 170 ); // set frame size
          JFrame.setVisible( true ); // display frame
     } // End method displayData
     public String packageData( Product myProduct, OfficeSupplies myOfficeSupplies, int counter ) // Method for formatting output
          return String.format( "%s: %d\n%s: %s\n%s: %s\n%s: %s\n%s: $%.2f\n%s: $%.2f\n%s: $%.2f\n%s: $%.2f",
          "Product Number", myOfficeSupplies.getProductNumber( counter ),
          "Product Name", myOfficeSupplies.getProductName( counter ),
          "Product Brand",myProduct.getProductBrand( counter ),
          "Number of Units in stock", myOfficeSupplies.getNumberUnits( counter ),
          "Price per Unit", myOfficeSupplies.getUnitPrice( counter ),
          "Total Value of Item in Stock is", myOfficeSupplies.getProductValue( counter ),
          "Restock charge for this product is", myProduct.restockingFee( myOfficeSupplies.getProductValue( counter ) ),
          "Total Value of Inventory plus restocking fee", myOfficeSupplies.getProductValue( counter )+
               myProduct.restockingFee( myOfficeSupplies.getProductValue( counter ) ) );
     } // end method packageData
} //End Class Panel

multarnc wrote:
My instructor has not been very forthcoming with assistance to her students leaving us to figure it out on our own.Aren't they all the same! Makes one wonder why they are called instructors. <sarcasm/>
Of course it's highly likely that enough information was imparted for any sincere, reasonably intelligent student to actually figure it out, and learn the subject in the process.
And if everything were spoonfed, how would one grade the performance of the students? Have them recite from memory
public class HelloWorld left-brace
indent public static void main left-parenthesis String left-bracket right-bracket args right-parenthesis left-brace
And everywhere that Mary went
The lamb was sure to go
db

Similar Messages

  • Scripting - Passing and Enterprise variable from script to script

    Hello all,
    We are using UCCX 7.0_SR5
    I am looking to be able to pass a captured variable from one script to another.
    We use a message in queue where a caller waiting in queue can choose to leave a message and then that message is queued back into the sytem for the next available agent. When that agent recieves the message in queue they basically call back out to the customer leaving the message.
    We capture a variable in the first script when they decide to leave a message. The variable holds the call back number that they enter into the system. There is a second script that presents these message in queue calls to the agents. We would like to pass that variable that holds the number enterend by the customer to the second script so that that number appears on CAD in the enterprise data fields. The reason behind this is so the agent has a number to call back in the event they don't reach anyone when the system calls back out and the message left by the customer does not contain a call back number.
    How can I pass that variable from one script to another so it can be presented in CAD for the agents?
    Thanks for any help and let me know if you need any further information.

    You would use a "Get Call Contact Info" step to set your callerID variable, where the "Calling Number" attribute is set to your callerID variable.

  • Pass an object from a static method

    Hi,
    I'm trying to pass a reference to an object from a static method, but I get an error when compiling.
    Say for example I have this:
    public class obj1 {
    public void myMethod (int i, Object ob, etc...) {
    ...and I want to call this method from a method that looks like this:
    public class obj2 {
    public static int anotherMethod(...) {
    obj1.myMethod(1,this,...);
    ...Can I pass a reference from obj2 to obj1 any other way?
    Thanks alot.

    how can I get a reference to obj2 then?Pay no attention to zdude's answer - it's nonsense.
    You're confused about basic Java concepts. obj2 is a class, not an object. References point to objects, not classes. There is no obj2 object in the code you show, so you cannot have a reference to an obj2 object.
    Maybe if you post some more code, we can get an idea of what you're trying to do. You might want to try the New to Java forum.

  • Trying to pass Hidden/Session variables from 1 JSP to 3rd JSP

    Hellol JSP Gurus !!
    This is a question on how a hidden or a value of a session variable can be passed from 1 JSP to a 3rd JSP, with the 2nd JSP as a Processing page.
    For eg., here's the scenario
    I have a Login page which has the hidden variables. Once the user enters the Login information, the info is validated in a LoginP.jsp (say, its a Processing page for the Login user/passwd info), which does a sendRedirect to a 3rd (Final) JSP which displays the values of the hidden/session variables of the 1st JSP.
    In my case, for some reason, I am not able to see the value for the hidden or the session variables in the 3rd JSP - they are null values.
    I am attaching some Duke dollars to who ever gives me the right solution.
    Thanks a lot in advance

    Use strings to set attributes;You can store any serializable object in the session. I doubt this will actually change anything.
    Anything wrong with the above code ?Not that I can see ... A number of other things can explain why you're getting null values out of the session. For example :
    - You are not using the implicit session obj in the 3rd jsp, but creating a new one and thus overwriting the one created previously
    - the session timeout value is unusually low, and by the time you're getting to the 3rd jsp, the session is invalidated and you're getting nulls. Verify your server config, or call session.getMaxInactiveInterval() to check the value. Check also if the session is new ( session.isNew() )
    Somebody already pointed this out : If the client does not support cookies and URL rewriting is not enabled, no session ID is returned to the server on a request, which the server then perceives as a new session.
    - Another (remote?) possibility : your 3rd jsp belongs to another webapp (i.e you're redirecting to another app context).
    If nothing of the above applies, post the jsp code and we'll try to help.

  • How can I pass an object to an inner method?

    Hi all,
    I'm stuck with a tiny problem here, hope someone can help out:
    I receive an UndoableEditEvent object in my method and I then want to apply that object to a JTextArea, my understanding is that I need to add a listener to the JTextArea.. but it won't see my UndoableEditEvent object.
          public static void edit( UndoableEditEvent e ) {
                final UndoManager undo = new UndoManager();
                Document doc = text_in.getDocument();
                doc.addUndoableEditListener(new UndoableEditListener() {
                public void undoableEditHappened(UndoableEditEvent e) {
                    System.out.println(e.getEdit());
                     undo.addEdit(e.getEdit());
    Any ideas?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Well, that looks like the right code for adding a listener to your JTextArea... except for the bit where the code is inside a static method that has an UndoableEditEvent as a parameter. Just get rid of that, and put the inside code immediately after the line of code where you create your JTextArea. You will probably have to make your UndoManager an instance variable of your class, too.

  • NEED HELP! passing an object array to a method

    Hi, i need to make a method called public Server[] getServers() and i need to be able to see if specific server is available for use.
    I have this so far:
    public abstract class AbstractServer
    protected String serverName;
    protected String serverLocation;
    public AbstractServer(String name,String location)
    this.serverName=name;
    this.serverLocation=location;
    public abstract class Server extends AbstractServer
    public Server(String name,String location)
    super(name,location);
    public class CreateServers
    Server server[];
    public CreateServers()
    public Server create()
    for(int i=0; i<10; i++)
    server=new Server(" ", " "); //i was going to fill in something here
    return server;
    OK NOW HERE IS THE PROBLEM
    i have another class that is supposed to manage all these servers, and i dont understand how to do the public Server[] getServers(), this is what i have tried so far
    public class ServerManager()
    public Server[] getServers(Server[] AbstractServer)
    Server server=null; //ok im also confused about what to do here
    return server;
    in the end i need this because i have a thread class that runs the servers that has a call this like:
    ServerManager.getServers("serverName", null);
    Im just really confused because i need to get a specific server by name but i have to go through AbstractServer class to get it
    Any help?

    ok, right
    since i have to call this method in the thread class saying
    ServerManger.getServer(AbstractServer[]) //to see if i have all the servers i need to proceed
    im confused about how it should be declared in the actual ServerManager
    should it be like
    public Server[] getServers(AbstractServer[]) ???? and then have it return all the servers it has
    thats the part i dont get, because instead of saying ServerManager.getServer(string, string) i want it to go and find out if i have all the servers i need to continue
    does that make sense? sort of?

  • How to pass an object as method parameter

    Hi Guys
    I was testing a simple program and was trying to pass an object to a method but it didnt seem to work and I couldnt find out WHY.
    I am posting the code so please let me know who can i make my method ADD_EMPLOYEE work so that when i pass an object of LCL_EMPLOYEE, it updates I_EMPLOYEE_LIST.
    *& Report:  ZOO_HR_SAMPLE_1
    *& Author:  Avinash Pandey
    *& Date:    25.03.2009
    *& Description: Concepts of OO in ABAP
    REPORT  zoo_hr_sample_1.
    *&       Class LCL_EMPLOYEE
           Local class
    CLASS lcl_employee DEFINITION.
    Public section
      PUBLIC SECTION.
    Data type
        TYPES:
          BEGIN OF t_employee,
            no  TYPE i,
            name TYPE string,
            wage TYPE i,
         END OF t_employee.
    Method
        METHODS:
          constructor
            IMPORTING im_employee_no TYPE i
                      im_employee_name TYPE string
                      im_wage TYPE i,
            add_employee
             IMPORTING im_employee TYPE REF TO lcl_employee,
           display_employee_list,
           display_employee,
           get_no EXPORTING ex_no TYPE i,
           get_name EXPORTING ex_name TYPE string,
           get_wage EXPORTING ex_wage TYPE i.
      Class methods are global for all instances
        CLASS-METHODS: display_no_of_employees.
    Protected section
      PROTECTED SECTION.
      Class data are global for all instances
        CLASS-DATA: g_no_of_employees TYPE i.
        CLASS-DATA: i_employee_list TYPE TABLE OF t_employee.
    Private section
      PRIVATE SECTION.
       CLASS-DATA: i_employee_list TYPE TABLE OF t_employee.
        DATA: g_employee TYPE t_employee.
    ENDCLASS.               "LCL_EMPLOYEE
    *&       Class (Implementation)  LCL_EMPLOYEE
           Text
    CLASS lcl_employee IMPLEMENTATION.
    Class constructor method
      METHOD constructor.
        g_employee-no = im_employee_no.
        g_employee-name = im_employee_name.
        g_employee-wage = im_wage.
        g_no_of_employees = g_no_of_employees + 1.
      ENDMETHOD.                    "constructor
    Method
      METHOD display_employee.
        WRITE:/ 'Employee', g_employee-no, g_employee-name.
      ENDMETHOD.                    "display_employee
    Method
      METHOD get_no.
        ex_no = g_employee-no.
      ENDMETHOD.                    "get_no
    Method
      METHOD get_name.
        ex_name = g_employee-name.
        WRITE: / 'Name is:' , ex_name.
      ENDMETHOD.                    "get_no
    Method
      METHOD get_wage.
        ex_wage = g_employee-wage.
      ENDMETHOD.                    "get_no
    Method
      METHOD add_employee.
      Adds a new employee to the list of employees
        DATA: l_employee TYPE t_employee.
        l_employee-no = im_employee->get_no.
        l_employee-name = im_employee->get_name.
        l_employee-wage = im_employee->get_wage.
        APPEND l_employee TO i_employee_list.
      ENDMETHOD.                    "add_employee
    Method
      METHOD display_employee_list.
      Displays all employees and there wage
        DATA: l_employee TYPE t_employee.
        WRITE: / 'List of Employees'.
        LOOP AT i_employee_list INTO l_employee.
          WRITE: / l_employee-no, l_employee-name, l_employee-wage.
        ENDLOOP.
      ENDMETHOD.                    "display_employee_list
    Class method
      METHOD display_no_of_employees.
        WRITE: / 'Number of employees is:', g_no_of_employees.
      ENDMETHOD.                    "display_no_of_employees
    ENDCLASS.               "LCL_EMPLOYEE
    REPORT
    DATA: g_employee1 TYPE REF TO lcl_employee,
          g_employee2 TYPE REF TO lcl_employee.
    START-OF-SELECTION.
    Create class instances
      CREATE OBJECT g_employee1
        EXPORTING
          im_employee_no   = 1
          im_employee_name = 'John Jones'
          im_wage          = 20000.
      CREATE OBJECT g_employee2
        EXPORTING
          im_employee_no   = 2
          im_employee_name = 'Sally Summer'
          im_wage          = 28000.
    Call methods
      CALL METHOD g_employee1->display_employee.
      CALL METHOD g_employee1->add_employee
        EXPORTING
          im_employee = g_employee1.
      CALL METHOD g_employee1->get_name.
      CALL METHOD g_employee2->display_employee.
      CALL METHOD g_employee2->display_no_of_employees.
    The error I am getting is:
    Field GET_NO/GET_NAME/GET_WAGE is unknown.
    Please help me out on this.
    Thanks a lot you people

    hi.
    The following parts of your program were changed.
    The result is OK?.
    *(1)change
    CLASS lcl_employee DEFINITION.
    Public section
    PUBLIC SECTION.
    display_employee,
    *get_no EXPORTING ex_no TYPE i,
    *get_name EXPORTING ex_name TYPE string,
    *get_wage EXPORTING ex_wage TYPE i.
    get_no returning value(ex_no) TYPE i,
    get_name returning value(ex_name) TYPE string,
    get_wage returning value(ex_wage) TYPE i.
    *(2)change
    CLASS lcl_employee IMPLEMENTATION.
    Method
    METHOD add_employee.
    Adds a new employee to the list of employees
    DATA: l_employee TYPE t_employee.
    *l_employee-no = im_employee->get_no.
    *l_employee-name = im_employee->get_name.
    *l_employee-wage = im_employee->get_wage.
    l_employee-no   = im_employee->get_no( ).
    l_employee-name = im_employee->get_name( ).
    l_employee-wage = im_employee->get_wage( ).
    APPEND l_employee TO i_employee_list.
    ENDMETHOD. "add_employee
    Result List
    Employee          1  John Jones
    Name is: John Jones
    Name is: John Jones
    Employee          2  Sally Summer
    Number of employees is:          2

  • Passing Business Object(Complex Type) as argument using PAPI-WS

    Hi All,
    Is it possible to pass Business Object or Complex Type as argument to process instance through PAPI-WS?
    As am getting error when am trying to pass business object in place of primitive type.. It would be great help any of you can provide example; if it is possible.
    Thanks & Regards,
    Ankur

    Hi Alexander,
    You are now able to create the Structure and set the cardinality also in NetWeaver CE.  I thin the following steps will be helpful for you.
    1. Create a CAF project called firstcaf.
    2.Create an entity service within the project called Customer.
    3. Now expand modeled.
    4. Then right click on Data Types. Here you will get the option "New Structure".
    5.Now select New Structure, One popup will appear then enter the Structure name called Address and click ok.
    6. Now You will get your Address structure under Complex Types.
    7.Double Click on Address. In right hand side you will get the Address structure for editing.
    8.Now from left hand side(Existing Type) expand caf.core and add your required attribute. In right hand side (structure Field) you can edit the name of attribute. suppose for Address structure I have added two field phone and mobile (both are short text ). save it.
    9. Now switch to Composite Application Explorer and expand Business Objects ->Customer -> Customer->Customer. and double click on it (Customer).
    10. In right hand side expand project firstcaf ->modeled. Now you will get your structure here, In my case I will get Address structure. Now select your structure and  click Add button. Structure will go to right hand side(Structure Fields).
    11. If you want to change the cardinality it is very simple. Select The Structure from right hand side(Structure Fields) and in bottom side click on property. Now you will get the Cardinality field. you can change it as you like.
    Thanks and Regards
    Chandan

  • Passing an object to a cfc as an argument

    I am trying to pass an object of java.util.RegularEnumSet into a CFC as an argument. This object contains several methods, but when I try to use any of these methods inside the CFC it is telling me there is no such methods in my enum set. When I use these java methods outside of my cfc on a test page it works just fine, any ideas why I cant pass this java object into my cfc and use the object's methods? Thanks in advance.

    I'm guessing that cfc's were not designed with your intended use in mind.  Why don't you simply create an object inside your cfc?

  • How do you pass a TES variable in a REST call?

    I am trying to create an email action using the EmailAction.create REST call.  I am able to successfully create an email action, but I cannot get it to work while trying to pass a TES variable (i.e. <JobName>) in the message body.
    Does anyone know how tis is done?

    Here is the XML code:
    <?xml version="1.0" encoding="UTF-8" ?>
    http://purl.org/atom/ns#">
        3
        HTTP
        http://www.tidalsoftware.com/client/tesservlet">
                EJS
                            [email protected]
                            Test Api
                            This is a test, only a test of the rest API.
                            [email protected]
                            test3_email
                            5
                            N
    In the I wnat to pass .

  • JNI - Passing an object containing an array field

    I need to pass an object to a native method. The object contains several int fields and a field that is an int array (contains 32 int).
    I have no problem with the int fields, but do not know how to access the int array field in the C code. What approach should be used to get/set values in the int array field?
    Any suggestions are appreciated.

    I have been reading up on the subject, but I guess I'm just an idiot. If all the answers were obvious from reading the specification then there wouldn't be much point to this forum.
    For int fields in the object passed to the native function I do the following to set the value:
    fid = (*env)->GetFieldID(env, cls, "intFieldName", "I");
    (*env)->SetIntField(env, myObj, fid, newValue);
    For a field that is an array of int, it seems that I can get the field ID as follows:
    fid = (*env)->GetFieldID(env, cls, "arrayFieldName", "[I");
    The "Get<Type>Field" and "Set<Type>Field" methods can be used for object, boolean, byte, char, short, int, long, float, double. Nothing specific here for array. Should I use the GetObjectField method, if so can the object field then be handled as an array? This is where I am missing something. I have experimented with using the SetIntArrayRegion method but this causes an exception - obviously missing a necessary step here. I am hoping someone here can provide guidance on what I am missing, what JNI functions I should be using, or refer me to the appropriate page of the specification or other document where it is explained (for idiots like me).

  • Procedure and Bind Variable

    I'm trying to write a procedure for an exercise I'm working on. I got an error that I needed to use a "Bind Variable," so now I'm trying to pass a bind variable to the procedure. I am supposed to get user input.
    CREATE OR REPLACE PROCEDURE insert_glaccount
    account_num_pram general_ledger_accounts.account_number%TYPE,
    account_desc_pram general_ledger_accounts.account_description%TYPE
    AS
    BEGIN
    INSERT INTO general_ledger_accounts
    VALUES (account_num_pram, account_desc_pram);
    /*Error handling to coming soon*/
    END;
    VARIABLE account_num_var general_ledger_accounts.account_number%TYPE;
    VARIABLE account_desc_var general_ledger_accounts.account_description%TYPE;
    BEGIN
    :account_num_var := &account_num;
    :account_desc_var := &account_desc;
    CALL insert_glaccount(:account_num_var, :account_desc_var);
    END;
    Now I'm getting an error: "Bind Variable "account_num_var" is NOT DECLARED"
    Can someone please explain how I'm messing this up?

    I don't know if that helps. Now I have this, but it still doesn't work. It looks like the procedure it's self is working, but not the script where I call the procedure:
    CREATE OR REPLACE PROCEDURE insert_glaccount
    account_num_pram general_ledger_accounts.account_number%TYPE,
    account_desc_pram general_ledger_accounts.account_description%TYPE
    AS
    BEGIN
    INSERT INTO general_ledger_accounts
    VALUES (account_num_pram, account_desc_pram);
    COMMIT;
    EXCEPTION
    WHEN DUP_VAL_ON_INDEX THEN
    DBMS_OUTPUT.PUT_LINE('A dup val on index error occurred.');
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('An unknown exception has occurred.');
    END;
    DECLARE
    account_num_var general_ledger_accounts.account_number%TYPE;
    account_desc_var general_ledger_accounts.account_description%TYPE;
    BEGIN
    account_num_var := &account_num; -- Get user input for account number
    account_desc_var := &account_desc; -- Get user input for account description
    CALL insert_glaccount(account_num_var, account_desc_var);
    END;
    /

  • How to pass calculated value to Application Module method?

    I am a newbie to ADF. Ithink I am missing something very basic:
    In JDeveloper 10.1.3.3 using ADF, I am trying to pass the session ID to a method in my App Mod, but the method receives a null value. I think I a getting the session ID too late in the process, but do not know where else to get it.
    Here are the details:
    I am passing 3 argument to a method called ProcessReport:
    public String ProcessReport(Number reportNumber, Double caratWeight, String sessionID)
    In my PageDef I have:
    <p>
    &lt;executables&gt;
    &lt;variableIterator id="variables"&gt;
    &lt;variable Type="oracle.jbo.domain.Number"
    Name="ProcessReport_reportNumber" IsQueriable="false"/&gt;
    &lt;variable Type="java.lang.Double" Name="ProcessReport_caratWeight"
    IsQueriable="false"/&gt;
    &lt;variable Type="java.lang.String" Name="ProcessReport_sessionID"
    IsQueriable="false"/&gt;
    &lt;/variableIterator&gt;
    &lt;/executables&gt;
    &lt;bindings&gt;
    </p>
    <p>
    &lt;methodAction id="ProcessReport" MethodName="ProcessReport"
    RequiresUpdateModel="true" Action="999"
    IsViewObjectMethod="false" DataControl="RC2DataControl"
    InstanceName="RC2DataControl.dataProvider"
    ReturnName="RC2DataControl.methodResults.RC2DataControl_dataProvider_ProcessReport_result"&gt;
    &lt;NamedData NDName="reportNumber" NDType="oracle.jbo.domain.Number"
    NDValue="${bindings.ProcessReport_reportNumber}"/&gt;
    &lt;NamedData NDName="caratWeight" NDType="java.lang.Double"
    NDValue="${bindings.ProcessReport_caratWeight}"/&gt;
    &lt;NamedData NDName="sessionID" NDType="java.lang.String"
    NDValue="${bindings.ProcessReport_sessionID}"/&gt;
    &lt;/methodAction&gt;
    &lt;attributeValues id="reportNumber" IterBinding="variables"&gt;
    &lt;AttrNames&gt;
    &lt;Item Value="ProcessReport_reportNumber"/&gt;
    &lt;/AttrNames&gt;
    &lt;/attributeValues&gt;
    &lt;attributeValues id="caratWeight" IterBinding="variables"&gt;
    &lt;AttrNames&gt;
    &lt;Item Value="ProcessReport_caratWeight"/&gt;
    &lt;/AttrNames&gt;
    &lt;/attributeValues&gt;
    &lt;attributeValues id="sessionID" IterBinding="variables"&gt;
    &lt;AttrNames&gt;
    &lt;Item Value="ProcessReport_sessionID"/&gt;
    &lt;/AttrNames&gt;
    &lt;/attributeValues&gt;
    &lt;/bindings&gt;
    </p>
    On my page I have added an outputText control called sessionID to hold the session ID.
    In my command Button to submit the page I have and action to call a method in my backing bean:
    The code is:
    FacesContext ctx = FacesContext.getCurrentInstance();
    ExternalContext ectx = ctx.getExternalContext();
    HttpSession mySession = (HttpSession) ectx.getSession(false);
    String theSessionID = mySession.getId();
    sessionID.setValue(theSessoinID) // I hope it populates the outputText control and is added to the binding to be passed to the ProcessReport method
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding = bindings.getOperationBinding("ProcessReport");
    Object result = operationBinding.execute();
    if (!operationBinding.getErrors().isEmpty()) {
    return null;
    String resultStr = (String) result;
    return resultStr;
    No luck! I think I should get the sesson ID earlier, when the page loads, but I do not know where to put the code.
    Any suggestions would be appreciated.
    John

    Hi,
    here's what I would do
    1. Create a managed bean as follows
    import javax.faces.context.ExternalContext;
    import javax.faces.context.FacesContext;
    import javax.servlet.http.HttpSession;
    public class HTTPSessionAccessBean {
        public HTTPSessionAccessBean() {
        public void setHttpSessionId(String httpSessionId) {
        public String getHttpSessionId() {
            FacesContext ctx = FacesContext.getCurrentInstance();
            ExternalContext ectx = ctx.getExternalContext();
            HttpSession mySession = (HttpSession) ectx.getSession(false);
            String sessionId = mySession.getId();
            return sessionId;
    }2. In the ApplicationModule Impl class create the following method and expose it as a clientInterface
        public void setSession(String sessionId){
           ((SessionImpl)this.getSession()).getEnvironment().put("http_session",sessionId);
        }3) In the pageDef File create a method binding as
    <methodAction id="setSession"
                      InstanceName="AppModuleDataControl.dataProvider"
                      DataControl="AppModuleDataControl" MethodName="setSession"
                      RequiresUpdateModel="true" Action="999"
                      IsViewObjectMethod="false">
          <NamedData NDName="sessionId"
                     NDValue="${HttpSession.httpSessionId}"
                     NDType="java.lang.String"/>4) In the same pageDef file create an invokeAction
        <invokeAction id="setSessionInAM" Binds="setSession"
                      RefreshCondition="#{!adfFacesContext.postback}"/>The session ID is now accessible from the ApplicationModule as
            Hashtable env = ((SessionImpl)this.getSession()).getEnvironment();
            String sessonId =(String) env.get("session);
            }This maintains the separation of model/view layer
    Frank

  • How to pass a file into a java method

    I am trying to pass a file into a java method so I can read the file from inside the method. How can I do this? I am confident passing int, char, arrays etc into methods as I know how to identify them in a methods signature but I have no idea how to decalre a file in a mthods signature. Any ideas please ?
    Thanks

    Hi,
    Just go thru the URL,
    http://www6.software.ibm.com/devtools/news1001/art24.htm#toc2
    I hope you will get a fair understanding of 'what is pass by reference/value'.
    You can pass Object reference as an argument.
    What Pablo Lucien had written is right. But the ideal situation is if you are not modifying the
    file in the calling method, then you can pass the String (file name) as an argument to the called method.
    Sudha

  • Trying to pass array to stored procedure in a loop using bind variable

    All,
    I'm having trouble figuring out if I can do the following:
    I have a stored procedure as follows:
    create procedure enque_f826_utility_q (inpayload IN f826_utility_payload, msgid out RAW) is
    enqopt dbms_aq.enqueue_options_t;
    mprop dbms_aq.message_properties_t;
    begin
    dbms_aq.enqueue(queue_name=>'f826_utility_queue',
    enqueue_options=>enqopt,
    message_properties=>mprop,
    payload=>inpayload,
    msgid=>msgid);
    end;
    The above compiles cleanly.
    The first parameter "inpayload" a database type something like the following:
    create or replace type f826_utility_payload as object
    2 (
    3 YEAR NUMBER(4,0),
    4 MONTH NUMBER(2,0),
    83 MUSTHAVE CHAR(1)
    84 );
    I'd like to call the stored procedure enque_f826_utility_q in a loop passing to it
    each time, new values in the inpayload parameter.
    My questions are:
    First, I'm not sure in php, how to construct the first parameter which is a database type.
    Can I just make an associative array variable with the keys of the array the same as the columns of the database type shown above and then pass that array to the stored procedure?
    Second, is it possible to parse a statement that calls the enque_f826_utility_q procedure using bind variables and then execute the call to the stored procedure in a loop passing new bind variables each time?
    I've tried something like the following but it's not working:
    $conn = oci_pconnect (....);
    $stmt = "select * from f826_utility";
    $stid = oci_parse($conn, $sqlstmt);
    $r = oci_execute($stid, OCI_DEFAULT);
    $row = array();
    $msgid = "";
    $enqstmt = "call enque_f826_utility_q(:RID,:MID)";
    $enqstid = oci_parse($conn, $sqlstmt);
    oci_bind_by_name($enqstid, ":RID", $row); /* line 57 */
    oci_bind_by_name($enqstid, ":MID", $msgid);
    while ($row = oci_fetch_array($stid, OCI_RETURN_NULLS+OCI_ASSOC))
    ++$rowcnt;
    if (! oci_execute($enqstid)) /* line 65 */
    echo "Error";
    exit;
    When I run this, I get the following:
    PHP Notice: Array to string conversion in C:\Temp\enqueue_f826_utility.php on l
    ine 57
    Entering loop to process records from F826_UTIITY table
    PHP Notice: Array to string conversion in C:\Temp\enqueue_f826_utility.php on l
    ine 65
    PHP Warning: oci_execute(): ORA-06553: PLS-306: wrong number or types of argume
    nts in call to 'ENQUE_F826_UTILITY_Q' in C:\Temp\enqueue_f826_utility.php on lin
    e 65
    PHP Notice: Undefined variable: msgnum in C:\Temp\enqueue_f826_utility.php on l
    ine 68
    Error during oci_execute of statement select * from F826_UTILITY
    Exiting!

    Thanks for the reply.
    I took a look at this article. What it appears to describe is
    a calling a stored procedure that takes a collection type which is an array.
    Does anyone from Oracle know if I can pass other database type definitions to a stored procedure from PHP?
    I have a type defined in my database similar to the following which is not
    an array but a record of various fields. This type corresponds to a payload
    of an advanced queue payload type. I have a stored procedure which will take as it's input, a payload type of this structure and then enqueue it to a queue.
    So I want to be able to pass a database type similar to the following type definition from within PHP. Can anyone from Oracle verify whether or not this is possible?
    create or replace type f826_utility_payload as object
    YEAR NUMBER(4,0),
    MONTH NUMBER(2,0),
    UTILITY_ID NUMBER(10,0),
    SUBMIT_FAIL_BY VARCHAR2(30),
    MUSTHAVE CHAR(1)
    );

Maybe you are looking for

  • ITunes crashes when I connect my iPhone 4S

    This is a case of one laptop being confused with two different iPhones. I had no problem using iTunes with my iPhone 4S on my Win7 laptop. The other day, I had connected my wife's iPhone to my laptop to transfer some files. It didn't work, so I gave

  • I want to make three HDD partitions on Satellite A200-1GB

    Hi all, Yesterday night I noticed that there is a small sound comes out when Hard disk is being read. The sound same as the Desktop Hard disk sound. In desktop HDD's that's normal. I thought that Notebook's HDD doesn't sound like that even it has the

  • JaVA 1_4_2 SLES 11 - download ?

    Hi, I`d like to install new system SAP ERP ECC 6.06 on the Linux SUSE 11 (x64_86) and Oracle 11. Temporarily i have trail version SUSE Enterprise Server 11. I installed SUSE, but according to note (1172419) I neeed java: SUSE Linux Enterprise Server

  • TCP chat filtering by listbox multiline, is it possible?

    Hey, would you help me  so, i have a TCP chat one-way. and i need to filter every chat which will be forward to end-devices, this is a scenario: client 1, client 2, client 3, etc -----> Filter -----> end devices. my problem is in Filter, i have listb

  • Apply Deposit Invoice to Sales Invoice

    Hello, How we can apply the deposit (customer prepayment) to the sales invoice to clear the customer's account balance using AR public API. I am using Oracle EBS 11.5.10.2. Appreciate help. Regards, Anirudha