Reading viewScope variable in ViewImpl class method

Hi,
suppose i'd like to get viewScope.deptno in my function which is declared in ViewImpl class
public void proc(String deptno,String amount){
setp_deptno(deptno==null?"%":deptno );
this.setNamedWhereClauseParam("p_deptno", deptno);
this.executeQuery();
System.out.println("viewScope.deptno="...?);
how can i reach it in my function?

do you mean placing the logics from VOImpl to client interface class?yes, then you can see the method exposed in the data control under the ViewObject node. then you can execute the method in your bean method like below
    public String executeMyVOMethod {
        BindingContainer bindings = getBindings();
        OperationBinding operationBinding = bindings.getOperationBinding("proc");
        operationBinding.getParamsMap().put("deptno", PassAnyDeptNo);//you can get it from view scop variable
        operationBinding.getParamsMap().put("amount", passAnyAmmountvalue);  //you can get it from view scop variable
        Object result = operationBinding.execute();
        if (!operationBinding.getErrors().isEmpty()) {
            return null;
        return null;
    }could you clarify why it is a bad practice to store logics in VOImpl?
is that because i can't reference ViewScope from there?
>
accessing a memory scope variable in your model layer (if its applicable) is a bad practice because you violate MVC pattern. This is not the best approach even if you can do it.
>
(this approach is based on Shay's video tutorial "Passing Parameters to ADF Application through the URL")
>
it is different, it is not your use case

Similar Messages

  • How to read the source code of class method

    Hi,
    I want to read the source code of a method which is in a BAdi implementation.
    I used SEO_METHOD_GET_SOURCE function module where I passed interface name as class and method name.
    But I didn't get the source code. Is there any other function module of method to read the source code.
    Thanks and regards,
    Venkat.

    Hi Venkat,
      You can still use the Function Module SEO_METHOD_GET_SOURCE with a small change in the parameter passing. It should be:
    Paramaters:
    MTDKEY-CLSNAME : <Implementaion Classname>
    MTDKEY-CPDNAME: <Interfacename~methodname>
    STATE : 'A' for active or 'I' for inactive
    For example:
    MTDKEY-CLSNAME :ZCL_IM_PLM_AUDIT_ALV_GRID
    MTDKEY-CPDNAME: IF_EX_PLM_AUDIT_ALV_GRID~ON_USER_COMMAND
    STATE: A
    After executing you will get the source code in the form of string in the 'SOURCE' parameter.
    Hope this helps you.
    Regards,
    Swarna Munukoti

  • How to read static variable defined java class from flex?

    This is a beginner question. If I use remoteClass to map a java class and a flex class, how can I access a static variable defined in java class from the flex code?
    Thanks!

    Static propeties are by default ignored in the blazeds for serialization. You can try using another global property in the java bean which maps to the value stored in the static property( Hopefully it should work)
    eg,
    public String instanceValue = ClassName.staticValue;
    Ref: http://livedocs.adobe.com/blazeds/1/blazeds_devguide/help.html?content=serialize_data_3.ht ml

  • Why we are making a variable as final in method inner class ?

    Why we are making the variable as final (method inner class) while we are accessing the method variable in inner class ?
    regards,
    namanc

    As far as I can tell, the only reason is to protect the programmer: when the inner class instance is constructed, it is given the then-current value of the variable. If the variable (or method parameter) later changes, the value held by the inner class would not. By making the variable final, the programmer doesn't have to worry about them staying in sync.
    Here's some code to ponder:
    public class InnerExample
        void printMe( final int x )
            Runnable runMe = new Runnable()
                public void run()
                    System.out.println(x);
            (new Thread(runMe)).start();
    }When compiled with the Sun JDK 1.4.2, you get this bytecode:
    void printMe(int);
      Code:
       0:   new     #2; //class InnerExample$1
       3:   dup
       4:   aload_0
       5:   iload_1
       6:   invokespecial   #3; //Method InnerExample$1."<init>":(LInnerExample;I)V
       9:   astore_2
       10:  new     #4; //class Thread
       13:  dup
       14:  aload_2
       15:  invokespecial   #5; //Method java/lang/Thread."<init>":(Ljava/lang/Runnable;)V
       18:  invokevirtual   #6; //Method java/lang/Thread.start:()V
       21:  returnAt line (byte) 5, it loads the passed value onto the stack; at line 6, it invokes the inner class constructor (which is created by the compiler). Nothing in this sequence of code would prevent use of a non-final variable.

  • ActiveX in BradySoft (CodeSoft) - What Class/Method/Object's would I use to send variable form data to BradySoft?

    What Class/Method/Object's would I use to send variable form data to BradySoft? I have a basic label setup in BradySoft and I want to send it variable form data (a serial number) from Labview ActiveX. I have attached Brady's ActiveX programmers guide but can't figure out what to use for this. P.S. I would call Brady or TekLynx tech support about this but they have a strict policy whereas BradySoft supports ActiveX but their tech support doesn't provide programming help with it. I figured I'd try the NI Forums.  

    Aaronb, I presume by publishing an ActiveX programmers manual the BradySoft software installs Active X objects. You may choose to interact with these objects within LabVIEW using Active X controls. The following link will provide a starting point for LabVIEW help topics on Active X communication: Select ActiveX Object Dialog Box
    http://zone.ni.com/reference/en-XX/help/371361F-01/lvdialog/insert_active_x_object/
    Building a Simple Web Browser Using ActiveX (Example of ActiveX arcitecture)
    http://zone.ni.com/devzone/cda/epd/p/id/81 Hope this helps provide a bit of guidance. Cheers!  

  • How define a global variable in a class that all the methods will recognize

    hi friends,
    i need to define a global variable in a class that all the methods will recognize it.
    any suggestions?
    thanks,
    dana.

    Dera Dana,
    In se24, create your own "Z" class.
    Open the Attributes tab.
    Insert your variable in the declaration part.
    EQ:
    Attribute     Level                       Visibility   Typing      Associated Type         Description        
    ITAB     Instance Attribute     Public     Type     Structure name     Description
    In the Layout of View page,
    <phtmlb:formLayoutDropDownListBox id                = "Dropdown"
                                              label             = "Drop Down"
                                              table             = "<%= controller->Itab %>"
                                              nameOfKeyColumn   = "CODE"
                                              nameOfValueColumn = "VALUE"
                                              selection         = "<%= controller->feild to be selected %>"
                                               />
    Hope this will be helpful
    Regards,
    Gokul.N

  • Need Help with command line arguments for a class method

    Hey guys,
    I'm fairly new to programming in java.
    I want to a write a class method that adds up its command line arguments which are numbers. For example, if the input was .... 5 2 3....then the output would be 10.
    I have been told to use the Convert to convert a string to a double. I'm ok for writing the class method but I have no idea how to use Convert and why I need it in the method.
    Can anybody help please?

    Hey guys,
    I'm fairly new to programming in java.
    I want to a write a class method that adds up its
    command line arguments which are numbers. For
    example, if the input was .... 5 2 3....then the
    output would be 10.Okay. So you would receive the numbers to add as the String[] argument to a main method. The steps are simple:
    1) declare a variable for the count
    2) for each String in the array:
    2.1) extract the value as a double
    2.2) add this to the count
    3) output the resulting count
    I have been told to use the Convert to convert a
    string to a double.
    I'm ok for writing the class
    method but I have no idea how to use ConvertThere is no class Convert in the Java API.
    and why
    I need it in the method. Do you understand you need to somehow convert each String to a double (step 2.1)? Since Convert is unknown to me, maybe you should just take a look at class Double. It can help you do step 2.1, the rest should be trivial enough.
    http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Double.html
    Give it a go and feel free to post back with a specific problem you are having, accurately described if you please :-)

  • Is there a way to reference a private variable from one class in another?

    My first class starts off by declaring variables like so:
    class tStudent {
      // declare student name, id, grades 1 & 2, and gpa
      private String fname, lname, g1, g2;
      private int id;
      private double gpa;
      // define a constructor for a new student
      tStudent () {fname=lname=g1=g2=null; id=-1; gpa=0.0;}
      // define methods for manipulating the data members.
      // readStudent: reads information for just one student
    public void read (Scanner input) {
          fname = input.next();
          lname = input.next();
          id = input.nextInt();
          g1 = input.next();
          g2 = input.next();
    }And the second class:// tStudentList: for a list of students
    class tStudentList {
      private int nStudents;
      private tStudent[] list;
      // constructor for creating student list
      tStudentList() {
          list = new tStudent[36];
          for (int i=0; i < 36; i++) list=new tStudent();
    // read the individual students into the student list
    public void read(Scanner scan) {
    nStudents=0;
    while (scan.hasNext()) {list[nStudents++].read(scan);}
    // display the list of all students - fname, lname, id, g1, g2 and gpa
    // with an appropriate header so the output matches my sample //output
    public void print() {
    Is there a way to reference the variables in the first class to use in the second? Specifically in the last section of code where I am going to print the list.

    Not without resorting to reflection hackery. If the fields are private (and are supposed to be), then that means "don't allow access to these to outsiders of this class" by design.
    So if you really meant them to be accessible, then don't use private, or provide public accessors for them.

  • How to call inner class method in one java file from another java file?

    hello guyz, i m tryin to access an inner class method defined in one class from another class... i m posting the code too wit error. plz help me out.
    // test1.java
    public class test1
         public test1()
              test t = new test();
         public class test
              test()
              public int geti()
                   int i=10;
                   return i;
    // test2.java
    class test2
         public static void main(String[] args)
              test1 t1 = new test1();
              System.out.println(t1.t.i);
    i m getting error as
    test2.java:7: cannot resolve symbol
    symbol : variable t
    location: class test1
              System.out.println(t1.t.geti());
    ^

    There are various ways to define and use nested classes. Here is a common pattern. The inner class is private but implements an interface visible to the client. The enclosing class provides a factory method to create instances of the inner class.
    interface I {
        void method();
    class Outer {
        private String name;
        public Outer(String name) {
            this.name = name;
        public I createInner() {
            return new Inner();
        private class Inner implements I {
            public void method() {
                System.out.format("Enclosing object's name is %s%n", name);
    public class Demo {
        public static void main(String[] args) {
            Outer outer = new Outer("Otto");
            I junior = outer.createInner();
            junior.method();
    }

  • How to get a int value from another class method?

    Hi,
    how can I get a value of another class method variable value.
    example,
    class elist
            int a;
         ArrayList<Event> eventArray;
         void addEvent(Event e);
         Event getEvent(int index);
         void removeEvent(int index);
         void orderEventByTime();
    interface Event
         void Command();
    class servo implements Event
         String ip;
         int time = 10;
         void Command();
    class servo_2 implements Event
         String ip;
         int time = 20;
         void Command();
    [\code]
    I want to get the time value in elist variable a; 
    and want to compare each class time?.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Hi,
    1) this foum provides means to format/tag code, no need to manually add -tags
    2) by default, classname start with a capital letter, method names with a lower case letter
    3) where do you want to get the time value to Elist.a? During addEvent()?
    4) what do you want to do with the time value of each event? Sum all values up to make a an overall sum?
    5) where do you want to compare the time value(s)?
    To put it in one sentence: please be more specific with your description and answer.
    Bye.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to pass a variable from one class to another class?

    Hi,
    Is it possible to pass a variable from one class to another? For e.g., I need the value of int a for calculation purpose in method doB() but I get an error <identifier> expected. What does the error mean? I know, it's a very, very simple question but once I learn this, I promise to remember it forever. Thank you.
    class A {
      int a;
      int doA() {
          a = a + 1;
          return a;
    class B {
      int b;
      A r = new A();
      r.a;  // error: <identifier> expected. What does that mean ?
      int doB() {
         int c = b/a;  // error: operator / cannot be applied to a
    }Thank you!

    elaine_g wrote:
    I am wondering why does (r.a) give an error outside the method? What's the reason it only works when used inside the (b/r.a) maths function? This is illegal syntax:
    class B {
      int b;
      A r = new A();
      r.a;  //syntax error
    }Why? Class definition restricts what you can define within a class to a few things:
    class X {
        Y y = new Y(); //defining a field -- okay
        public X() { //defining a constructor -- okay
        void f() { //defining a method -- okay
    }... and a few other things, but you can't just write "r.a" there. It also makes no sense -- that expression by itself just accesses a field and does nothing with it -- why bother?
    This is also illegal syntax:
    int doB() {
          A r = new A();
          r.a;  // error: not a statement
    }Again, all "r.a" does on its own is access a field and do nothing with it -- a "noop". Since it has no effect, writing this indicates confusion on the part of the coder, so it classified as a syntax error. There is no reason to write that.

  • Sending a variable from one class to another?

    Dear Java Users - please can you help me out here... I know that what I am asking should be straight forward BUT I just don't understand any of the responses people have put on the web....
    Here is what I am trying to do:
    This piece of code - creates a window with a simple textbox on it to enter a word...
    The button then calls another class file to open a new window...
    All I want to do is to take the word from the text box and print it in the new window....
    The first .java file I have is this:
    import java.io.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class FrontPageGUI extends JFrame implements ActionListener
         //declare all instance variables for THIS per class
              JLabel lblInfoOne;
              JLabel lblButtonPopUp;
              JTextField txtName;
              JButton close;
              JButton popUp;
         public FrontPageGUI()
              //set characteristics of the JFrame object
              super("Title Bar");
              setSize(600,600);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setVisible(true);
              //we need to define a Container to place objects onto the frame - this is inside the JFrame Object Above
              Container ca = getContentPane( );
              ca.setSize(600,600);
              ca.setBackground(Color.white);
              ca.setLayout(null);                
              //define all other objects and set thier characteristics
              lblInfoOne     = new JLabel("Enter a word in the box above to send:");
              lblButtonPopUp = new JLabel("Click Here:");
              txtName          = new JTextField("");
              //create Button components
              close = new JButton("Close");
              popUp = new JButton("Click Me");
              //now add all objects to the container
              //Labels
              addXY(ca,lblInfoOne, 30, 160, 550,45);
              addXY(ca,lblButtonPopUp, 30, 210, 550,45);
              //TextField
              addXY(ca,txtName, 120, 100, 200,30);
              //Buttons
              addButtonXY(ca, popUp, 30, 260, 200, 45);
              addButtonXY(ca, close, 30, 310, 80, 30);
              // add the Container to the Frame     
              setContentPane(ca);          
         void addButtonXY(Container c, JButton cp, int x, int y, int w, int h)
               cp.setBounds(x,y,w,h);
               cp.addActionListener(this);
               c.add(cp);     
         void addXY(Container c, Component cp, int x, int y, int w, int h)
               cp.setBounds(x,y,w,h);
               c.add(cp);
         public void actionPerformed(ActionEvent event)
              if (event.getSource()== popUp)
                   //This is WHERE THE PROBLEM IS...
                   //Here I want to send to contents of the textfield - txtName
                   String temp = txtName.getText();
                   new PopUpGUI(temp);
              if (event.getSource()==close)
                   closeUp();
         void closeUp()
              System.exit(0);
              //dispose();
    //we need a driver program - this is the only time MAIN is used.
    public class FrontPage
         //create an instance of the GUI and showit
         public static void main(String args [])
              new FrontPageGUI();
                   The second .java file I have is this:
    import java.io.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class PopUpGUI extends JFrame implements ActionListener
         //declare all instance variables ie per class
              JLabel headerLabel;
              JLabel sentLabel;          
              JButton close;
         public PopUpGUI(String Sent)
              //set characteristics of the JFrame object
              super("Pop Up Window");
              setSize(320,450);
              setVisible(true);
              //need to define a Container to place objects onto the frame
              Container ca = getContentPane( );
              ca.setSize(320,450);
              ca.setLayout(null);                
              //define all other objects and set characteristics
              headerLabel = new JLabel("New Window!"); //heading label
              sentLabel = new JLabel(Sent);
              close = new JButton("Close");
              //now add all objects to the container
              addXY(ca,headerLabel,10,10,380,80);
              addXY(ca,sentLabel,10,100,380,80);
              addButtonXY(ca, close, 50, 200, 100, 30); //Bottom Left
              // add the Container to the Frame     
              setContentPane(ca);
         //We need these 2 methods - EVERY TIME
         void addButtonXY(Container c, JButton cp, int x, int y, int w, int h)
               cp.setBounds(x,y,w,h);
               cp.addActionListener(this);
               c.add(cp);     
         void addXY(Container c, Component cp, int x, int y, int w, int h)
               cp.setBounds(x,y,w,h);
               c.add(cp);
         //What to do when the click happens
         public void actionPerformed(ActionEvent event)
              if (event.getSource()==close)
                   dispose();
                   //closeUp(); - Doesn't run CLOSEUP this time (i.e. exit program) - instead just DISPOSEs of the window
    //Driver class is in FrontPage.javaThis seems to work... but is it the best way to do it????
    Tony.

    Well,
    Using the constructor is the way to go. Otherwise create a method that takes the string as parameter.

  • Setting variables from inner class

    I have a GUI that takes users information and provides a quotation as componants are clicked. My componants' Listeners are in seperate inner classes and from these I want to add certain details to variables, it seems to compile and run but it doesn't seem to be changing the value of the variable when the componants are clicked, is there any reason why this happens, my code is below:
    public class MyGUI extends JFrame{
            public MyGUI(){
              //GUI STUFF HERE
            double Price;
         private String total=calculate();
         public String calculate(){
              double aTotal=Price;
              return "$ " + aTotal;
         class MyListener implements ItemListener{
              public void itemStateChanged(ItemEvent evt){
                   if(evt.getSource()==rad1) {
                   Price=0.10;
                   else if(evt.getSource()==rad2) {
                   Price=0.12;
                        totalLab.setText(total);
    }

    shouldn't I also be able to access the outer classes methods? It doesn't seem to do this either.

  • Passing vector into class/methods

    I am new to Vectors check this simple code out. I am trying to pass a vector onto another class then add an integer element to it. I see that its looking for an identifier but i dont unerstand how the code is for an identifier for a vector.
    ERRORS: .\Remove.java:4: <identifier> expected
         public static void AddIntegers(varray);
    ^
    .\Remove.java:4: ')' expected
         public static void AddIntegers(varray);
    ^
    .\Remove.java:4: cannot resolve symbol
    symbol : class varray
    location: class Remove
         public static void AddIntegers(varray);
    ^
    C:\Computer Work\Lab4\RemoveTest.java:11: cannot resolve symbol
    symbol : method varray ()
    location: class RemoveTest
              rm.AddIntegers(varray());
    ^
    .\Remove.java:4: missing method body, or declare abstract
         public static void AddIntegers(varray);
    ^
    .\Remove.java:6: cannot resolve symbol
    symbol : variable varray
    location: class Remove
              varray.AddElement(new Integer(13));
    ^
    6 errors
    Tool completed with exit code 1
    import java.io.*;
    import java.util.*;
    public class RemoveTest
         public static void main(String[] args)
              Vector varray = new Vector();
              Remove rm = new Remove();
              rm.AddIntegers(varray);
              System.out.println(varray);
    public class Remove
         public static void AddIntegers(varray);
              varray.AddElement(new Integer(13));

    I think the question whether you should use Vector over arrays, but rather should you use Lists over arrays. Vectors are kind of deprecated. You should be using the Collections Framework as a whole, and that means that ordered items are in java.uti.Lists, where are a kind of java.util.Collection, and a Vector is just a particular kind of List, and not necessarily even the best kind -- an ArrayList or LinkedList is often better.
    The advantage of arrays over Lists is that they can hold primitive types trivially. You can only hold objects in Lists, so you can put primitive class wrapper objects in Lists, but that has its disadvantages. Apparently in JDK 1.5 there's some syntactic sugar to make this easier, but there are still other disadvantages.
    The advantages of Lists over arrays are like what you mentioned -- things like resizings are automatic, there are lots of convenience methods, etc. The Collections Framework provides an abstraction of, well, collections, which is a good thing over futzing with details like with arrays, frequently.

  • Accessing public variables from other classes

    Probably a simple questions, but how can I access a variable from another class. My exact situation is as follows.
    A class called WorldCalender has a variable which is defined: public int hour; (the value is given to it elsewhere).
    I want to access this variable and increase it by one in a subroutine in the class Hour. In this class I have put: WorldCalender.hour++; but it doesn't seem to work. How should I do it?

    don't expose the hour variable at all.
    have a method eg addToHourBy( int hrs )
    Probably a simple questions, but how can I access a
    variable from another class. My exact situation is as
    follows.
    A class called WorldCalender has a variable which is
    defined: public int hour; (the value is given to it
    elsewhere).
    I want to access this variable and increase it by one
    in a subroutine in the class Hour. In this class I
    have put: WorldCalender.hour++; but it doesn't seem to
    work. How should I do it?

Maybe you are looking for