Sharing managed beans

Ok �. This is driving me nuts. I�m relatively new to JSF (2 week profession  ), and I may not have grasped the concept of Managed Beans. The problem is detailed below:
Development Environment:
WebSphere Studio 1.5.2 � This creates a backing bean for each respective JSP page that is created, including setters and getters for each managed bean. The two backing beans I�ll talk about whilst specifying the problem are stored in session scope.
The Problem:
I can�t share data between two pages. On the first page I create managed bean in session scope and make this reusable (let�s say person). On the second page I add the reusable Person bean. The resulting entry in the faces.config file is:
<managed-bean>
<managed-bean-name>person</managed-bean-name>
<managed-bean-class>ibm.wlrs.model.PersonVO</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
Both pages however maintain an independent copy of the managed bean instead of JSF maintaining a shared one. I�ve looked at several documents, and too me it seems as though this bean should be shared between the two pages�� HELP!
On the first page I create a new Person object with the relevant details. This person is created upon a button click added to the backing beans managed bean.
//Page 1 add person from button click
public String doLnkInsertEntryAction() {
System.out.println("Insert");
     Person p1 = new Person();
     p1.setName("Duncan");
     setPerson(p1);
System.out.println(getPerson().getName());
//This prints the person�s name
     return "insert";
I have also setup a page load event to test that the person object stays in the session
//Page 1 page load
public void onPageLoadBegin(FacesContext facescontext) {
     System.out.println(getPerson().getName());
//Prints the person name that was added during the button click event� on Postback or even after going from page1 � page2 and back again.
On Page two if I try and access the managedBean contained within the session, the �name� will always print out as null.
//Page 2 page load
public void onPageLoadBegin(FacesContext facescontext) {
     System.out.println(getPerson().getName());
If I add an any information to the managed bean on page two i.e. person.setName(�Another�), this data stays in the session, only for page two though.
Is this how JSF is supposed to work? I though if a managed bean was stored in the session, the object (and it�s data) should be reusable between pages.
Sorry for the long post�. I though it would be worth while to try and be as specific as possible.
Thanks
Duncan

And� I still don�t understand why two independent
copies are kept by the pages�Because YOU create the copy.
JSF (exactly speaking the default VariableResolver) at first searches for an attribute in
request scope, then session scope, then application scope with the matching name.
Only when no attribute is found, it examines faces-config.xml, creates an instance of
the specified class, and stores the instance in the specified scope.
It never creates two instances with a same name.
I.E� On Page 1�. Several Person objects are stored in
a DataTable. The Vector containing the Person objects
is a managed bean bound to this data table. Upon a
button click I require to extract a person from the
data table and place it into the managed bean session
scope for person. Humm, I guess you misunderstand what the managed bean is.
h:dataTable has the "var" attribute which is used to refer each Person object.
JSF implements the "var" variable as a request scope attribute and re-binds it
to each Person object in the iteration. So, it is not a managed bean but is simply an attribute.
The entry of faces-config.xml is not required.
To know how to pass the selected row data to the next page, please see some
example using h:dataTable and javax.faces.model.DataModel.

Similar Messages

  • Managed Beans vs. POJO Data Control for sharing data

    Hi,
    I am currently using JAX-WS proxy client and POJO Data Controls to retrieve data from web services. This data needs to be shared across users. Normally I would use application scoped managed beans for this, but since I prefer using data controls and the binding layer, would using static POJO Data Control classes achieve the same thing?

    Hi,
    Data Controls don't exist across user sessions so in your use case use a managed bean in application scope. If you want to make this available from a Data Control
    - create a POJO
    - Use EL in the POJO to access the managed bean
    - Create a DataControl from the POJO
    This way the Data Control exposes the data as an API but itself always reaches out to the managed bean as a data store/cache
    Frank

  • JSF - Best Practice For Using Managed Bean

    I want to discuss what is the best practice for managed bean usage, especially using session scope or request scope to build database driven pages
    ---- Session Bean ----
    - In the book Core Java Server Faces, the author mentioned that most of the cases session bean should be used, unless the processing is passed on to other handler. Since JSF can store the state on client side, i think storing everything in session is not a big memory concern. (can some expert confirm this is true?) Session objects are easy to manage and states can be shared across the pages. It can make programming easy.
    In the case of a page binded to a resultset, the bean usually helds a java.util.List object for the result, which is intialized in the constructor by query the database first. However, this approach has a problem: when user navigates to other page and comes back, the data is not refreshed. You can of course solve the problem by issuing query everytime in your getXXX method. But you need to be very careful that you don't bind this XXX property too many times. In the case of querying in getXXX, setXXX is also tricky as you don't have a member to set. You usually don't want to persist the resultset changes in the setXXX as the changes may not be final, in stead, you want to handle in the actionlistener (like a save(actionevent)).
    I would glad to see your thought on this.
    --- Request Bean ---
    request bean is initialized everytime a reuqest is made. It sometimes drove me nuts because JSF seems not to be every consistent in updating model values. Suppose you have a page showing parent-children a list of records from database, and you also allow user to change directly on the children. if I hbind the parent to a bean called #{Parent} and you bind the children to ADF table (value="#{Parent.children}" var="rowValue". If I set Parent as a request scope, the setChildren method is never called when I submit the form. Not sure if this is just for ADF or it is JSF problem. But if you change the bean to session scope, everything works fine.
    I believe JSF doesn't update the bindings for all component attributes. It only update the input component value binding. Some one please verify this is true.
    In many cases, i found request bean is very hard to work with if there are lots of updates. (I have lots of trouble with update the binding value for rendered attributes).
    However, request bean is working fine for read only pages and simple binded forms. It definitely frees up memory quicker than session bean.
    ----- any comments or opinions are welcome!!! ------

    I think it should be either Option 2 or Option 3.
    Option 2 would be necessary if the bean data depends on some request parameters.
    (Example: Getting customer bean for a particular customer id)
    Otherwise Option 3 seems the reasonable approach.
    But, I am also pondering on this issue. The above are just my initial thoughts.

  • How to include Managed bean class in build sciprt for taskflow (Jdev 11.4)

    Hi,
    I've developed a custom taskflow to be deployed in the webcenter spaces. The taskflow that I developed contains managed beans. I am using oracle provided build script with the sample application, to deploy custom taskflow. After the build, we don't see any .class files (managed bean files) in the generated war file. Once we deploy the taskflow into the space, it is failing may be because the managed bean class files are missing in the <taskflow>.war. Am i missing something? Should we specifically include the .class files in the build script?
    Below is the oracle provide build script..
    <?xml version="1.0" encoding="US-ASCII" ?>
    <!--Ant buildfile generated by Oracle JDeveloper-->
    <!--Generated Sep 29, 2009 11:47:41 PM-->
    <project name="WebCenterSpacesSharedLibExtension" default="all" basedir="."
    xmlns:wls="oracle.webcenter.tools.wls">
    <property file="../config.properties"/>
    <property file="build.properties"/>
    <import file="internal-targets.xml"/>
    <taskdef resource="net/sf/antcontrib/antcontrib.properties">
    <classpath>
    <pathelement location="${jdeveloper.install.home.directory}/modules/net.sf.antcontrib_1.0.0.0_1-0b2/lib/ant-contrib.jar"/>
    </classpath>
    </taskdef>
    <target name="clean-stage"
    description="Cleans the output directory and generates the war"
    depends="clean, stage"/>
    <target name="deploy-shared-lib"
    depends="init-wls"
    description="Deploy the extending WebCenter shared library">
    <echo> ---------------------------- </echo>
    <echo> ${wls.userconfig} ${wls.userkey} ${wls.host}:${wls.port} ${oracle.jdeveloper.deploy.dir}/exploded ${wls.webcenter.app.target} ${customer.library.name}</echo>
    <exec logerror="true"
    executable="${jdeveloper.install.home.directory}/oracle_common/common/bin/${wlst.executable}"
    dir="${jdeveloper.install.home.directory}/oracle_common/common/bin">
    <!--TODO:ExpDeploy Uncomment line after this and comment the one after that to deploy exploded. -->
    <arg line="${extending.spaces.home.dir}/WebCenterSpacesSharedLibExtension/extspaces.py ${wls.userconfig} ${wls.userkey} ${wls.host}:${wls.port} ${oracle.jdeveloper.deploy.dir}/exploded/${customer.library.name}.war ${wls.webcenter.app.target} ${customer.library.name}"/>
    <!--TODO:ExpDeploy Uncomment line below and comment line above to have non-exploded deploy -->
    <!--arg line="${extending.spaces.home.dir}/WebCenterSpacesSharedLibExtension/extspaces.py ${wls.userconfig} ${wls.userkey} ${wls.host}:${wls.port} ${oracle.jdeveloper.deploy.dir}/${shared.library.name} ${wls.webcenter.app.target} ${customer.library.name}"/-->
    </exec>
    <echo> ---------------------------- </echo>
    <echo> Restarting the app </echo>
    <echo> ---------------------------- </echo>
    <exec logerror="true"
    executable="${jdeveloper.install.home.directory}/oracle_common/common/bin/${wlst.executable}"
    dir="${jdeveloper.install.home.directory}/oracle_common/common/bin">
    <arg line="${extending.spaces.home.dir}/WebCenterSpacesSharedLibExtension/redepwc.py ${wls.userconfig} ${wls.userkey} ${wls.host}:${wls.port} "/>
    </exec>
    </target>
    </project>
    Thanks in advance
    Nitin

    Hi,
    I've developed a custom taskflow to be deployed in the webcenter spaces. The taskflow that I developed contains managed beans. I am using oracle provided build script with the sample application, to deploy custom taskflow. After the build, we don't see any .class files (managed bean files) in the generated war file. Once we deploy the taskflow into the space, it is failing may be because the managed bean class files are missing in the <taskflow>.war. Am i missing something? Should we specifically include the .class files in the build script?
    Below is the oracle provide build script..
    <?xml version="1.0" encoding="US-ASCII" ?>
    <!--Ant buildfile generated by Oracle JDeveloper-->
    <!--Generated Sep 29, 2009 11:47:41 PM-->
    <project name="WebCenterSpacesSharedLibExtension" default="all" basedir="."
    xmlns:wls="oracle.webcenter.tools.wls">
    <property file="../config.properties"/>
    <property file="build.properties"/>
    <import file="internal-targets.xml"/>
    <taskdef resource="net/sf/antcontrib/antcontrib.properties">
    <classpath>
    <pathelement location="${jdeveloper.install.home.directory}/modules/net.sf.antcontrib_1.0.0.0_1-0b2/lib/ant-contrib.jar"/>
    </classpath>
    </taskdef>
    <target name="clean-stage"
    description="Cleans the output directory and generates the war"
    depends="clean, stage"/>
    <target name="deploy-shared-lib"
    depends="init-wls"
    description="Deploy the extending WebCenter shared library">
    <echo> ---------------------------- </echo>
    <echo> ${wls.userconfig} ${wls.userkey} ${wls.host}:${wls.port} ${oracle.jdeveloper.deploy.dir}/exploded ${wls.webcenter.app.target} ${customer.library.name}</echo>
    <exec logerror="true"
    executable="${jdeveloper.install.home.directory}/oracle_common/common/bin/${wlst.executable}"
    dir="${jdeveloper.install.home.directory}/oracle_common/common/bin">
    <!--TODO:ExpDeploy Uncomment line after this and comment the one after that to deploy exploded. -->
    <arg line="${extending.spaces.home.dir}/WebCenterSpacesSharedLibExtension/extspaces.py ${wls.userconfig} ${wls.userkey} ${wls.host}:${wls.port} ${oracle.jdeveloper.deploy.dir}/exploded/${customer.library.name}.war ${wls.webcenter.app.target} ${customer.library.name}"/>
    <!--TODO:ExpDeploy Uncomment line below and comment line above to have non-exploded deploy -->
    <!--arg line="${extending.spaces.home.dir}/WebCenterSpacesSharedLibExtension/extspaces.py ${wls.userconfig} ${wls.userkey} ${wls.host}:${wls.port} ${oracle.jdeveloper.deploy.dir}/${shared.library.name} ${wls.webcenter.app.target} ${customer.library.name}"/-->
    </exec>
    <echo> ---------------------------- </echo>
    <echo> Restarting the app </echo>
    <echo> ---------------------------- </echo>
    <exec logerror="true"
    executable="${jdeveloper.install.home.directory}/oracle_common/common/bin/${wlst.executable}"
    dir="${jdeveloper.install.home.directory}/oracle_common/common/bin">
    <arg line="${extending.spaces.home.dir}/WebCenterSpacesSharedLibExtension/redepwc.py ${wls.userconfig} ${wls.userkey} ${wls.host}:${wls.port} "/>
    </exec>
    </target>
    </project>
    Thanks in advance
    Nitin

  • Reset JSF session and the managed beans with sesison scope

    Hi,
    this is a very general question and maybe stupid for most of you. I have my jsf/facelets web application and i use inside of this application some managed beans, which are session beans. I want to know how is it possible to reset this beans. I'm asking this question beacuse i have this kind of problem: i built my web application which has a login form and i use the browser to test it. When i browse to the login page and I login with my credentials i get my customized home page. Then i open another istance of the browser and i browse to the login page again but this time i login as a different user. The result home page is the same as i got before with my login credentials, so the session is always the same. Instead i want the session and all its objects to be resetted for the new user! Do youn know which is the solution?

    The fact is that i want to have two sessions in parallel, so using the same browser and opening two tabs, i want to browse to the login page and access as two totaly different users and using in parallel the application without the problem of one user's action affecting the other user beacuse of session sharing. So I want to force the application to create two different session for the two users logins, because as i told you before as it is now, they are sharing the same sesison. And i think that if i at the login time I iterate thorugh the session and delete all the objects i will be able to have only one session per time. Isn't it?

  • Managed bean/Data exchange between two ADF Rich Faces based applications

    Hi,
    I have been trying to research what seems to be a small issue. My requirements are as follows.
    1. I need to be able to pass managed bean information from one ADF Rich Faces based application to another (in two separate ears) at runtime (e.g. from Ear1: SenderApp/Sender.jspx -> Ear2: ReceiverApp/Receiver.jspx).
    2. I do not want to use the database as my applications need to be performant.
    3. Serialization/de-serialization would fall pretty much under the database category. In other words, I like to avoid Serialization/de-serialization of the managed bean.
    4. I cannot use query string due to security issues.
    My question is as follows:
    1. Is there any standard/architecture/best practices for data exchange of backing beans or other forms between two ADF Rich Faces based apps (in two separate ears)?
    2. Has someone found anything similar to an applicationScope that works across applications?
    I would appreciate any ideas.
    Thanks very much,
    Edited by: user11219846 on Jul 23, 2009 2:38 PM
    Edited by: user11219846 on Jul 23, 2009 2:42 PM

    Hi,
    its not an ADF Faces problem, but not possible in Java EE. You can however fallback to vendor specific implementations like in WLS. From the WebLogic documentation : http://e-docs.bea.com/wls/docs103/webapp/sessions.html
    Enabling Web applications to share the same session*
    By default, Web applications do not share the same session. If you would like Web applications to share the same session, you can configure the session descriptor at the application level in the weblogic-application.xml deployment descriptor. To enable Web applications to share the same session, set the sharing-enabled attribute in the session descriptor to true in the weblogic-application.xml deployment descriptor. See “sharing-enabled” in session-descriptor.
    The session descriptor configuration that you specify at the application level overrides any session descriptor configuration that you specify at the Web application level for all of the Web applications in the application. If you set the sharing-enabled attribute to true at the Web application level, it will be ignored.
    All Web applications in an application are automatically started using the same session instance if you specify the session descriptor in the weblogic-application.xml deployment descriptor and set the sharing-enabled attribute to true as in the following example:
    +<?xml version="1.0" encoding="ISO-8859-1"?>+
    +<weblogic-application xmlns="http://www.bea.com/ns/weblogic/90";;>+
    +...+
    <session-descriptor>     
    +<persistent-store-type>memory</persistent-store-type>+
    +<sharing-enabled>true</sharing-enabled>+
    +...+
    +</session-descriptor>+
    +...+
    +</weblogic-application>+
    Frank

  • Data Palette not showing Managed Beans for Dynamic Web Project, JSF 2.1

    Hello.
    I have a problem in OEPE (oepe-juno-distro-win32.zip), where the Data tab in Palette shows no Managed Beans,
    even if I created them in the ManagedBeans in faces-config.xml using the Faces Config Editor.
    I have created a Dynamic Web Project with these Facets:
    Dynamic Web Module 3.0
    Java 1.7 (JDK 1.7_21)
    Java Annotation Processing Support 5.0
    JavaScript 1.0
    JavaServer Faces 2.1
    JSTL 1.2
    Oracle WebLogic Web App Extensions 12.1.1
    I am using Oracle WebLogic Server 12c 12.1.1 zip distribution for hosting the application.
    For example, I have a UserBean Managed Bean of Session scope, that has 3 String fields
    and the respective getters and setters.
    I create a "test.jspx" file, and from the Palette -> Tags tab -> JSF HTML I drag a Form into
    the new file so I can connect it to UserBean and generate a form to enter its details.
    I select the "Generate a form tag and content from data" and in the Choose Bean dialog
    there is none of my Beans.
    What could be the problem?
    Thanks in advance.
    Edited by: 997841 on Apr 30, 2013 6:09 PM
    I forgot to mention the Oracle WebLogic Web App Extensions version 12.1.1 and that also
    for JSF 2.1 the "sub-directory" Faces Configuration below the project in Project Explorer is not
    existent, as in projects created with earlier versions of JSF.

    Yes, they are both listed under the WebLogic System Libraries.
    This is the content of .classpath file when using WebLogic System Library:
    <?xml version="1.0" encoding="UTF-8"?>
    <classpath>
         <classpathentry kind="src" path="src"/>
         <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/Oracle WebLogic Server 12c (12.1.1) JRE">
              <attributes>
                   <attribute name="owner.project.facets" value="java"/>
              </attributes>
         </classpathentry>
         <classpathentry kind="src" path=".apt_src">
              <attributes>
                   <attribute name="optional" value="true"/>
              </attributes>
         </classpathentry>
         <classpathentry kind="con" path="oracle.eclipse.tools.weblogic.lib.system">
              <attributes>
                   <attribute name="owner.project.facets" value="jst.web"/>
              </attributes>
         </classpathentry>
         <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
         <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
         <classpathentry kind="con" path="oracle.eclipse.tools.weblogic.lib.shared/jstl/exact/1.2"/>
         <classpathentry kind="output" path="build/classes"/>
    </classpath>
    And this is the content when using User Library with Mojarra:
    <?xml version="1.0" encoding="UTF-8"?>
    <classpath>
         <classpathentry kind="src" path="src"/>
         <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/Oracle WebLogic Server 12c (12.1.1) JRE">
              <attributes>
                   <attribute name="owner.project.facets" value="java"/>
              </attributes>
         </classpathentry>
         <classpathentry kind="src" path=".apt_src">
              <attributes>
                   <attribute name="optional" value="true"/>
              </attributes>
         </classpathentry>
         <classpathentry kind="con" path="oracle.eclipse.tools.weblogic.lib.system">
              <attributes>
                   <attribute name="owner.project.facets" value="jst.web"/>
              </attributes>
         </classpathentry>
         <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
         <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
         <classpathentry kind="con" path="oracle.eclipse.tools.weblogic.lib.shared/jstl/exact/1.2"/>
         <classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/JSF 2.1 (Mojarra 2.1.6-FCS)">
              <attributes>
                   <attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
                   <attribute name="owner.project.facets" value="jst.jsf"/>
              </attributes>
         </classpathentry>
         <classpathentry kind="output" path="build/classes"/>
    </classpath>

  • Can you add a new managed bean when customizing taskflows?

    Hi,
    I see post on how to customize taskflows and most of the customization involves rendering changes such as showing/hiding parts of the page..
    But I was thinking is it possible to create your own managed bean in Customization Role of JDeveloper?
    I notice that when I right click some package, the New option is disabled by default? Does this mean that customization is limited to changing
    only the UI/JSFF file? The documentation does not mention about this or it maybe that I could not find it.
    What I would like is that, the new managed bean I define in my Customization Role will drive the UI.
    Anybody has done customization at this level? Would like to know your thoughts please.
    Is this possible or should I point my thinking in the other directions?
    Thanks.
    This is a Webcenter Portal Application by the way and I am looking into customizing an existing taskflow thru MDS means.
    Webcenter 11G PS5

    You cannot add a new managed bean via customization. Instead, these may be deployed as ADF Library jars within a shared library or as part of the Portal war.
    Once a managed bean has been added as above, then it can be referenced within a taskflow customization. For e.g. you can add a new button with the action set to a method in the managed bean.

  • Managed Beans and Data Access Object

    I have a question / need help understanding how to configure backing bean and model objects so that memory and object creation/deletion is done as efficiently as possible.
    1. I have a .jsf page with a form and a commandbutton that submits the form inputs to a backing bean (enrollispbean is backing bean)
    <h:commandButton value="Enter" action="#{enrollispbean.insert}"/>
    2. The backing bean is used for form handling - the insert() method is used to read the data fields from the form and create a SQL string that will be submitted to a model object, DbInsert, that is used as a generic data access object that connects to the database and insert the SQL string:
    public class EnrollIspBean {
    private String beanvar1="";
    private String beanvar2= "";
    // DbInsert is data access object
    private DbInsert dbinsert = new DbInsert();
    public String insert (){
    String sqlstmt;
    sqlstmt = "INSERT INTO ispmain VALUES(beanvar1, beanvar2,..)"
    dbinsert.insert(sqlstmt);
    return "success"; }
    3. DbInsert is the data access object that contains a method, insert(), that accepts a sql string to insert into the database. This method contains the code to obtain a connection from the database connection pool and then execute the sql statement (note: error checking code not shown):
    public class DbInsert {
    public void insert(String sqlstmt) throws SQLException {
    Connection conn = null;
    GetDBConnection getdbconnection = new GetDBConnection();
    PreparedStatement stmt = null;
    conn = getdbconnection.getdbconn();
    stmt = conn.prepareStatement(sqlstmt);
    stmt.executeUpdate();
    stmt.close();
    conn.close();
    return;
    Where I need help understanding is how to set up the scope for the managed beans and data access object. Currently, I have the backing bean within the session scope (using the facesconfig.xml file). My main question is how to set up the scope for the Data Access Object - currently I do not have it as a managed bean within facesconfig.xml. Instead I am creating a new instance within the backing bean:
    private DbInsert dbinsert = new DbInsert();
    Is this the best way to do this? Will the DBInsert object now be tied to the session scope of the backing bean (i.e., when backing bean is deleted, the DbInsert object will be deleted from session scope as well.)
    Ideally I would like the data access object to be available as a shared object throughout the life of the application. When I was programming using a servlet approach, I would have created a servlet to load on startup. Now that I'm using java server faces, I'm confused about the scope / how to efficiently set up a data access object that I want to be available to all backing beans in the application.
    tnanks for any help understanding this.
    Tom

    I was thinking about setting the data access object as application scope so that it can be used by an backing bean to execute sql statements.
    If I do set it as application scope, however, if I do this, do I still need to declare a new instance of the object from within each bean that uses the object?
    For example do I need to declare a new instance of the data access object from within the bean? or, should I assume that there is always an instance of the bean available in the application scope, and if so, how do I reference it from within the bean?
    Bean Code:
    public class EnrollIspBean {
    // DbInsert is data access object
    private DbInsert dbinsert = new DbInsert();
    Finally, I understand performance may be an issue if I have one instance of the data access object available in the application scope - is there a way to make multiple instances available in the application scope?
    thanks

  • Error while opening a popup from managed bean

    Hi,
    I am trying to open a popup from bean, after another popup is closed. When I open the second popup either through ActionListener(on first popup button) or DialogListener(on first popup), I am getting the below error on browser status bar(!); and the second popup doesn't open. There is no error in the log.
    *'AdfPage.PAGE.findComponent(...)' is null or not an object.*
    Although the popup id is there on the jspx page.
    <af:popup id="confirmationStatus" binding="#{MyBean1.confirmationStatus}">
    <af:dialog cancelVisible="false"
    closeIconVisible="false" binding="#{MyBean1.d2}"
    title="Appointment Confirmation Status">
    <af:outputText value="Appointment is successfully confirmed"/>
    </af:dialog>
    </af:popup>
    public void confirmAppointment_dialogListener(DialogEvent dialogEvent) {
    FacesContext context = FacesContext.getCurrentInstance();
    ExtendedRenderKitService service = Service.getRenderKitService(context, ExtendedRenderKitService.class);
    String popupId = "confirmationStatus";
    service.addScript(context,"AdfPage.PAGE.findComponent('" + popupId + "').show();");
    Please tell me why my popup is not getting open from the managed bean and I am getting an error in below line.
    service.addScript(context,"AdfPage.PAGE.findComponent('" + popupId + "').show();");

    To find out the right address of a component related to an other component, open your page select the component you want to add a partial trigger, go to the partial trigger property, select the down arrow at the right end and select 'Edit'. Now look for the popup in the component tree shown on the left side. When you have found the popup shuffle it the the selected side and click OK. The string you see in the field is the full address of the popup related to he component you've selected. Try the string you see there in your bean code. Remove the string from the partial trigger property, it's just to get the correct path.
    One other thing to check is that your popup has the ClientComponent property set to true.
    Next thing to try, is to use AdfPage.PAGE.findComponentByAbsoluteId(...)
    Timo

  • How to pop up a browser window from a managed bean?

    I have a user case like this:
    User login our home website. He/she clicks a button. Control flow goes to a managed bean (MB here after) to check some conditions. If conditions are met, instead of sending the user back to the home page, the user will be presented a new web site (e.g. forums.oracle.com) in a popup window on top of our home site.
    Can we invoke a website in a adf popup? If so, how to do that? If not, any idea on how to develop this use case?
    Any idea is appreciated.

    Sorry, I have updated the previous reply with the required inputs.
    For convenience, putting it again;
    if you need to check for some condition and then invoke the browser, you could use the following code in your managed bean for af:commandButton for Action.
    import javax.faces.context.FacesContext;
    import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
    import org.apache.myfaces.trinidad.util.Service;
    public class TestURLPageBean {
    public TestURLPageBean() {
    super();
    public String onClick() {
    *// Check for the condition here and invoke the browser only if it is true*
    if (true) {
    ExtendedRenderKitService erks =
    (ExtendedRenderKitService)Service.getRenderKitService(FacesContext.getCurrentInstance(),
    ExtendedRenderKitService.class);
    StringBuilder script = new StringBuilder();
    script.append("window.open('http://www.google.com');");
    erks.addScript(FacesContext.getCurrentInstance(),
    script.toString());
    return null;
    Thanks,
    Navaneeth

  • What is difference between Managed Bean and Backing Bean?

    What is difference between Managed Bean and Backing Bean? Please guide me how to create them and when to use them?
    Please post sample for both beans.

    Hi,
    managed beans and backing beans are quite the same in that the Java object is managed by the JavaServer Faces framework. Manage in this respect means instantiation. The difference is that backing beans contain component "binding" references, which managed beans usually don't. Do backing beans are page specific versions of managed beans.
    Managed beans are configured either in the faces-config.xml file, or using ADF Faces and ADFc, in the adfc-config.xml file
    Frank
    Edited by: Frank Nimphius on Jan 31, 2011 8:49 AM

  • How to get iterator values from a managed bean ?

    Due to a bug in selectOneChoice i'm not able to get the label list i want to display directly from an iterator when the value binding is a managed bean.
    To solve the problem i would like to create a managed bean that contains that list and use it as the selectItems to display.
    I would like that the values in that managed bean loaded from the a data control iterator.
    My question is :
    1) is it possible to access the iterator values from a managed bean, i mean without any reference to a page definition
    2) how to do ? is it documented somewhere ? any example ?
    Thank you

    I got it also with this code:
    package view.managedBeans;
    import classification.bean.ClassificationDocument;
    import classification.castor.ClassificationLanguage;
    import java.io.FileNotFoundException;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.Hashtable;
    import java.util.List;
    import java.util.Locale;
    import javax.faces.context.FacesContext;
    import javax.faces.el.ValueBinding;
    import javax.faces.model.SelectItem;
    import oracle.adf.model.generic.DCGenericDataControl;
    import org.exolab.castor.xml.MarshalException;
    import org.exolab.castor.xml.ValidationException;
    public class ClassificationLanguageList {
    private java.util.List<SelectItem> supportedLanguages = new ArrayList();
    public ClassificationLanguageList() throws FileNotFoundException,
    MarshalException,
    ValidationException {
    FacesContext ctx = FacesContext.getCurrentInstance();
    ValueBinding vb = ctx.getApplication().createValueBinding("#{data.ClassificationDocumentDataControl}");
    DCGenericDataControl classificationDocumentDataControl = (DCGenericDataControl)vb.getValue(ctx);
    ClassificationDocument classificationDocument = (ClassificationDocument)classificationDocumentDataControl.getDataProvider();
    ClassificationLanguage[] classificationLanguage = classificationDocument.getClassification().getClassificationLanguageList().getClassificationLanguage();
    for (int counter = 1; counter < classificationLanguage.length; counter++) {
    SelectItem language = new SelectItem();
    language.setValue(classificationLanguage[counter].getClassificationLanguageCode());
    language.setLabel(classificationLanguage[counter].getClassificationLanguageLabel());
    supportedLanguages.add(language);
    public void setSupportedLanguages(java.util.List<SelectItem> supportedLanguages) {
    this.supportedLanguages = supportedLanguages;
    public java.util.List<SelectItem> getSupportedLanguages() {
    return supportedLanguages;
    }

  • Re:How to get the vo from managed bean

    Hi all,
    I am using Jdev11.1.2.3.0
    My requirement is : I have one jspx page.In that page i have created one form,so i need to get the values from managed bean.here i wont create by using data control view instance.so finally i have to get the table values from managed bean.so how can i get it.can anyone help me please.
    Thanks,
    G.Shilpa

    So you're not using ADF BC at all, right ?
    From JSF point of view, it does not matter how you provide UI control values.
    What you can do, for example, is to use pure JDBC in order to get and display the database values.
    What you need in your backing bean, is appropriate properties (setter/getter method pairs).
    In the getter, you can obtain DB values by using JDBC
    Take a look at:
    JSF 2.0 + JDBC integration example
    JSF JDBC Integration
    JDBC in JSF - YouTube

  • Initialize managed bean from request parameters

    Hi:
    I thought this topic would be on the FAQ, but I couldn't find it. I am looking for a mean to initialize my managed bean from the query string. There must be something like:
    <h:form initializeBean=""true"" requestParameter=""id_author"" beanProperty=""#{author.id_author}"" action=""#{author.getFromDB}"" >
    </form>
    The url would be something like http://localhost:8080/protoJSF/showAuthor.jsf?id_author=5334
    And the getFromDB method would be something like
      Public void getFromDB()
         Statement stmt = cn.createStatement( ?SELECT * from author where id_author=? + getId_author() );
         ResultSet rs = stmt.executeQuery();
      }The only way I've found to perform something like this is to present a blank author form with a ''load data'' button: after pressing the button the user can see author's data and edit the data if she wants to. This two-step data screening is annoying, to say the least.
    There must be a better way.
    I beg for a pointer on how can I achieve the initializing of a managed bean with dynamic data.
    Regards
    Alberto Gaona

    You just have to read carefully the very fun 289 pages
    specification :-)Or, if 289 pages of JavaServer Faces is too much, you can get almost all of the same information from the JavaServer Pages 2.0 specification, or even the JSP Standard Tag Libraries specification :-).
    More seriously, the standard set of "magic" variable names that JavaServer Faces recognizes is the same as that reognized by the EL implementations in JSP and JSTL. Specifically:
    * applicationScope - Map of servlet context attributes
    * cooke - Map of cookies in this request
    * facesContext - The FacesContext instance for this request
    * header - Map of HTTP headers (max one value per header name)
    * headerValues - Map of HTTP headers (String array of values per header name)
    * initParam - Map of context initialization parameters for this webapp
    * param - Map of request parameters (max one value per parameter name)
    * paramMap - Map of request parameters (String array of values per parameter name)
    * requestScope - Map of request attributes for this request
    * sessionScope - Map of session attributes for this request
    * view - The UIViewRoot component at the base of the component tree for this view
    If you use a simple name other than the ones on this list, JavaServer Faces will search through request attributes, session attributes, and servlet context (application) attributes. If not found, it will then try to use the managed bean facility to create and configure an appropriate bean, and give it back to you.
    For extra fun, you can even create your own VariableResolver that can define additional "magic" variable names known to your application, and delegate to the standard VariableResolver for anything else.
    Craig McClanahan

Maybe you are looking for