How to organize the bean class?

Hello I am a new to ADF. I am using mostly pages with session scope, because I can pass parameters from the session scope: adf.context.expressionEvaluator.evaluate('#{sessionBean.dateDay}');
Because of that I am trying to not put many variables to the scope.
I am wondering what is the better practice? To put the Application Module as a static class field to my bean and call it as 'this.am' in every function or
to create it in every function around 30+ times per class like that: AppModuleImpl am = (AppModuleImpl)ADFUtils.getApplicationModuleForDataControl("AppModuleDataControl");
Also I am wondering if I have a button and I want to modify its 'visible' attribute is it better to bind this button and change it visibility as : this.button.setVisible(false);
or to make a field in my class private Boolean isButtonVisible = false; and in the setter to look like this:
    public void setIsButtonVisible(Boolean isButtonVisible) {
        this.isButtonVisible= isButtonVisible;
        refreshButtonById(":pt1:but1");
       private void refreshButtonById(String elementId) {
        RichCommandLink button =
            (RichCommandLink)FacesContext.getCurrentInstance().getViewRoot().findComponent(elementId);
        AdfFacesContext.getCurrentInstance().addPartialTarget(button);
    }I will gladly accept any links that will show me how to write a quality code in ADF. :)

Here is a part of the code of one of my beans:
    public String save() {
        try {
            BuildixxUtils.commit();
            System.out.println("The changes are commited.");
            BuildixxUtils.addInfoMessage("All changes are successfully saved");
        } catch (Exception e) {
            BuildixxUtils.addErrorMessage(e.getMessage());
        return "null";
    public String cancel() {
        DCBindingContainer dbc = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
        DCIteratorBinding vehicleOwnerIterator = dbc.findIteratorBinding("VehicleOwnerAdminViewIterator");
        Key selectedVehicleOwnerKey = vehicleOwnerIterator.getCurrentRow().getKey();
        DCIteratorBinding voGroupIdIterator = dbc.findIteratorBinding("VoGroupAdminView2Iterator");
        Key selectedVoGroupKey = null;
        if (voGroupIdIterator.getCurrentRow() != null) {
            selectedVoGroupKey = voGroupIdIterator.getCurrentRow().getKey();
        try {
            AppModuleImpl am = (AppModuleImpl)ADFUtils.getApplicationModuleForDataControl("AppModuleDataControl");
            am.getTransaction().rollback();
            System.out.println("Rollback done.");
            BuildixxUtils.addInfoMessage("All changes are cancelled");
        } catch (Exception e) {
            BuildixxUtils.addErrorMessage(e.getMessage());
        setCurrentRowsOfAllTables(dbc, vehicleOwnerIterator, selectedVehicleOwnerKey, voGroupIdIterator,
                                  selectedVoGroupKey);
        return "null";
    private void setCurrentRowsOfAllTables(DCBindingContainer dbc,
                                           DCIteratorBinding vehicleOwnerIterator,
                                           Key selectedVehicleOwnerKey,
                                           DCIteratorBinding voGroupIdIterator,
                                           Key selectedVoGroupKey) {
        vehicleOwnerIterator.setCurrentRowWithKey(selectedVehicleOwnerKey.toStringFormat(true));
        if (selectedVoGroupKey != null) {
            Row row = voGroupIdIterator.findRowByKeyString(selectedVoGroupKey.toStringFormat(true));
            if (row != null) {
                System.out.println("Key exists");
                voGroupIdIterator.setCurrentRowWithKey(selectedVoGroupKey.toStringFormat(true));
                HidePersonVehicleButtonsIfNeeded(dbc);
            } else {
                System.out.println("Key doesn't exist");
                setIsDeleteGroupButtonVisible(false);
                setIsDeletePersonButtonVisible(false);
    private void HidePersonVehicleButtonsIfNeeded(DCBindingContainer dbc) {
        DCIteratorBinding personGroupIterator = dbc.findIteratorBinding("VoGroupPersonView2Iterator");
        if (personGroupIterator.getCurrentRow() == null) {
            setIsDeletePersonButtonVisible(false);
        DCIteratorBinding vehicleGroupIterator = dbc.findIteratorBinding("VoGroupVehicleView1Iterator");
        if (vehicleGroupIterator.getCurrentRow() == null) {
            setIsDeleteVehicleButtonVisible(false);
    }I am using 5 tables 3 popups 8 buttons. When no rows are selected i make the delete buttons invisible. When a cancel button is pressed I want to save the state of the page so I need to set the current rows of some of the tables. The tables are connected with view links etc...
You can give me some hits how I can refactor the functions to improve them. Thanks. :)

Similar Messages

  • How to call the bean in jspdyn component?

    Hi,
    i created  jspdyn component in that bean and bussiness logic class in NWDS.i created a method() in that businesslogic class.i called that method in bean class.i created both in same package,there is no error occur while creating the object of that class.but the bean class not recognize the business class method which i created. What is the cause? and also tell me how to call the bean in jsppage also.and also give me textfields,button and syntax of event handling in HTMLB,iam new to this area.so,give me one example step by step.

    Hi,
         Please check on these links for a good start.
    Java development methodologies (Part II)
    Bean usage in JSPDynPage
    jspDynPage portalapp.xml
    Regards,
    Harini S
    Please avoid giving personal mail id(s). That may prevent others from getting the same information when needed.

  • How to organize the content of MANIFEST.MF

    Most of the jar files contain a file named META-INF/MANIFEST.MF, and it provides some information about the class in the jar files, but when I execute the code below, I can't output all of the jar file name in the eclipse project's classpath.
    import java.net.URL;
    import java.util.Enumeration;
    public class TestClassLoader {
    public static void main(String args[]) throws Exception {
    Enumeration<URL> en = TestClassLoader.class.getClassLoader().getResources("META-INF");
    while (en.hasMoreElements()) {
    URL metaInf = en.nextElement();
    System.out.println(metaInf.toExternalForm());
    So I want to know how to organize the content of MANIFEST.MF file to output the file name

    getResources doesn't do what you apparently think it does. The resource path still has to be an exact match, but getResources allows for the possibility that the same resource path may occur multiple times on the class path.
    You could use it to access all the MANFEST.MF files on the classpath but you'd need to full resource path "META-INF/MANIFEST.MF"
    The code you've written doesn't access the contents of the manifests, of course. To access the contents of manifests use java.util.jar.Manifest objects.

  • How to use the different class for each screen as well as function.

    Hi Experts,
    How to use the different class for each screen as well as function.
    With BestRegards,
    M.Thippa Reddy.

    Hi ThippaReddy,
    see this sample code
    Public Class ClsMenInBlack
    #Region "Declarations"
        'Class objects
        'UI and Di objects
        Dim objForm As SAPbouiCOM.Form
        'Variables
        Dim strQuery As String
    #End Region
    #Region "Methods"
        Private Function GeRate() As Double
                Return Double
        End Function
    #End Region
    Public Sub SBO_Appln_MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean)
            If pVal.BeforeAction = True Then
                If pVal.MenuUID = "ENV_Menu_MIB" Then
                End If
            Else ' Before Action False
                End If
        End Sub
    #End Region
    End Class
    End Class
    Rgds
    Micheal
    Vasu Anna Regional Feeling a???? Just Kidding
    Edited by: micheal willis on Jul 27, 2009 5:49 PM
    Edited by: micheal willis on Jul 27, 2009 5:50 PM

  • How to use the implementation class in propetty pallete

    Hi,
    I am using forms 10g....I have to insert horizontal scroll bar in text item..
    I have only class files instead of jar files ...how cani place the class file instead of jar file...
    How to use the implementation class in property palette to display the PJC
    Thanks,
    Ansaf.

    The Implementation Class must reflect the full name of the class. For instance, if the full class name is : xx.yyy.zz.class_name, then put this in the Implementation Class property of the corresponding item.
    Also, the class must be stored in the equivalent directory structure, so that, in my example: <DEV_HOME>/forms/java/xx/yyy/zz
    Francois

  • How to get the object class field value in CDHDR table for vendor

    hi
    how to get the object class field value in CDHDR table for vendor

    Try KRED/KRED_N as object class in CDHDR for Vendor.

  • How to organize the import statements in FXML Files?

    Hello,
    I'm a user of NetBeans IDE and it can organize the import statements in *.java files. Now, I'm using JavaFX and editing the *.fxml files as well. I want to know how to organize the import statements in *.fxml files?
    Thanks a lot.

    You should use Scene Builder, it will make all these import statements for you.
    Moreover, it will greatly simplify the writing of your FXML files, since you only have to Drag&Drop JavaFX objects on the scene. Then, it automatically generates FXML files.

  • How to Organize the columns in the dynamic internal table?

    Hello Folks!
    How to Organize the columns in the dynamic internal table? i tried passing the parameter COL_POS to the fieldcatalog, Which is not working.

    Organize in What order ? What is your way to output ?
    If you use ALV, you need to create fresh FIELD CATALOG for your dynamic table and then assign the column position.
    Regards,
    Diwakar

  • How to find the Feeder class behind Incident creation in SAP EHS?

    I have a requirement where i need to change the message text after clicking "Send" button while creating Incident.
    How to find the feeder class and method which is called behind "Send" button ?
    Thanks,
    Vimal

    I dont have such.. but you can set  external debug point in function module POWL_QUERY_REFRESH
    * get the result object type from the feeder
       lr_feeder->get_object_definition(
          EXPORTING
           i_selcrit_values = lt_crit_para  " selcrit dependent object def.
           i_langu = l_langu                                     "nt_1673495
           i_type  = i_query_data-type
          IMPORTING
           e_object_def = lr_object_def
    In I_QUERY_DATA-TYPE you can see name of POWL ID.
    Find it in transaction POWL_TYPE and you get name of feader class!

  • Java.lang.ClassCastException in the Bean Class

    Does anybody have any idea about the following exception.
    MessageLoggerBean is the Bean class and I am attaching the java file for further
    reference
    java.lang.ClassCastException: com.wellmanage.Bean.MessageLoggerBean_3p5ifg_HomeImpl
    java.lang.ClassCastException: com.wellmanage.Bean.MessageLoggerBean_3p5ifg_HomeImpl
    at com.wellmanage.Bean.MessageLoggerBean.getConnection(MessageLoggerBean.java:181)
    at com.wellmanage.Bean.MessageLoggerBean.logMessage(MessageLoggerBean.java:77)
    at com.wellmanage.Bean.MessageLoggerBean_3p5ifg_EOImpl.logMessage(MessageLoggerBean_3p5ifg_EOImpl
    java:79)
    Thanks
    Srini
    [MessageLoggerBean.java]

    Please configure the classloader to delegate to the parent loader by specifying the following in WEB-INF/sun-web.xml (the Sun ONE Application Server specific deployment descriptor for web applications)
    <class-loader delegate="true"/>
    More information on this can be found at
    http://docs.sun.com/source/816-7150-10/dwdeploy.html#48102
    Thanks,
    Arvind

  • Printing directly from the bean class

    i am using a 3 tier layer to implement an event calendar
    i have a calendar.jsp that sends form data to eventday.jsp, which extracts the form data and calls mtds from eventBean.java that connects to db. my print statements are in the bean class. my prob is that the required information are not printed.
    i have debugged calendar.jsp and eventday.jsp and am quite sure that both are ok. i have placed a simple print statement in the bean class n it does not get printed.
    can i know if it's true we can't print directly from the bean class?
    should i return the values to be printed in dayevent.jsp instead?

    i see, then will it be okay if i store the value retrieved from the bean in a vector n retrieve the vector content in the jsp page? but i remember my tutor sayin that it's poor programing to expose the data structure to other classes or pages? wat other mtd can i use then? thks!

  • How to Change the Development Class from $TMP to YABAP in Layout

    Hi all,
    How to Change the Development Class from $TMP to YABAP in Layout( SE71).
    Thanks & Regards,
    N.L.Narayana

    Hi,
    it is possible with SE03. you just click on Change <b>Object Directory Entries</b> under the tree menu <b>Object directory</b>, and then enter in the last column of table control
    Check the check box and enter FORM and formname,
      R3TR FORM SAPscript form 
    then execute it.
    then you will be able to change it to PACKAGE from $TMP
    regards
    vijay

  • How to change the development class of a script?

    helo experts can u please explain how to change the development class of a script?

    SE03->Object Directory-->select change object entries->Execute
    Now Select FORM in second row
    Check box(tick)    R3TR     FORM     SAP Script     <Give your Script name here>
    Package   : give the current package of the script ex. $tmp
    Execute
    Now right click on your form name--> object directory ( I guess from here you can proceed)
    Reward points to all useful answers.
    Regards,
    SaiRam Reddy

  • Where I should put the bean class?

    Hello,
    I am learning JSP. I want to know where I should put the bean class? Which directory should I put the bean class?
    note that I am using Tomcat 4.1
    johnwen
    24-12-2005

    I can't tell if you've got everything you need or not, but what you've shown looks right so far. Let me run down the necessities:
    In your JSP file:
    <%@ page import="aos.*" %>
    <%-- imports all of the classes in the "aos" package --%>
    In your Java file:
    package aos; // tells Java this is a package (you probably have this)
    Then, of course, you put the class file into the directories that you mentioned, ie, $CATALINA_HOME/ROOT/WEB-INF/classes/aos (forgive me if I use Unix-styled slashes; old habit, and shouldn't make any difference.)
    You may need to restart Tomcat. You have to restart it when you add certain directories, although I'm not sure exactly which ones. But it never hurts to just restart it anyway.

  • Where to put the Bean class in a html- Bean- JSP setup

    Hi,
    The setup is simple, the front end is a html form, there is a Java Bean with set/get methods and finally a jsp which accesses the bean and prints the result.
    The problem is that it cannot locate the Bean class. I have compiled the bean class and stored the .class file in webapps/ROOT/WEB-INF/classes dir. The jsp and html files are located in the webapps/ROOT dir. Iam using tomcat 5.0.28, with ROOT context enabled. Is this because I need to set the CLASSPATH for Tomcat? Any pointers?
    Thanks

    No you don't need to set CLASSPATH.
    You need to put your bean in a package.
    As of java1.4, JSPs can not access beans that are in the default/unnamed pacakge.
    package mypackage
    public class MyClass
    and then the class would compile to
    WEB-INF/classes/mypackage/MyClass.class

Maybe you are looking for

  • Bdc recording for trancastion ME01

    Hi, Can u help me in BDC recording for transaction 'ME01' . I have no idea for transaction 'ME01'  & here i like to know how to handle table ctr during bdc recording? give sample code if possible. Thanks

  • Best solution for showing photos on a HD TV?

    I recently got a Sony HD TV with full 1080. I would like to be able to display my photos at the best resolution possible on it. What is the best way to do that? My computer is nowhere near the TV so I can't plug it in directly. I also am not interest

  • Webservices - No such operation....

    Hi, I'm implementing remote application (Ruby on Rails) for Vibe, using ruby Savon SOAP client. I can list all operations that Vibe offers, but I'm not able to call any of them. I always get "No such operation.... " error message back from the vibe s

  • Field conversion from char .

    Dear member ,             Is there any way to reduce the prefix zero from sale order 10 digit char .            EG: if 0053549980 is the so no I want to make it 53549980  . I have transfered  the vale into integer variable but error is coming  data o

  • Saprouter service on windows -  which user rights are required?

    Hi, We have the saprouter service running in a windows 2003 server, this service is started by a user account named 'saprouter' which has its password set to never expires. Due to security concerns, our IT Security Deparment have ask us to apply all