Help Reading parameter in VWP backing/managed bean

Hi everyone. I am working on adding a jMaki widget into my Visual Web Pack Application and need some help sending data from my jMaki widget and receiving it in my VWP backing bean.
I have been able to get the jMaki widget added by manipulating the example found on the divas blog: http://blogs.sun.com/divas/. My next step would be to be able to get the data being sent.
<a href="faces/Home.jsp?name=banana">Banana</a>Mainly how do i access the parameter "name" from my backing or managed bean in my VWP application. Any help is appreciated. Thanks.
Message was edited by:
b12s

i was able to resolve this. thanks anyway.

Similar Messages

  • ADF reading dirty records programmatically in managed bean

    Hi,
    I have a ADF Table in which one column is a input text field.If we make change to any of the rows and press update button ADF BC recognises the dirty records and updates them.I need to read those rows in managed bean as i need to update some other fields of that row programmatically.
    Any ideas..
    Thanks in advance.

    Thanks Frank..
    In value change listner we get the new value and old value only.. How can we get the complete row details..I thought of getting the row details from the iterator by passing the selected row index ..
    but there can be multiple rows selected ..
    Is there any other possible solution to get the other attributes of the same row in valuechangelistner..
    Thanks in advance

  • How to pass parameter onclick of a command link created in a managed bean

    Hi,
    I created a command link in a managed bean using RichCommandLink . I want to pass a parameter on click of the command link like we do using <f:attribute> on the jspx. As i have created a command link using the bean hence i want to pass it programmatically to another method . How should i pass the parameter via the command link. Please help..

    Hi,
    can you please elaborate more on this.
    i am not getting what you are trying to tell.
    following is my actual code in java bean : :
    RichCommandLink remove= new RichCommandLink();
    remove.setId("E"+(rowID-1));
    remove.setText("Remove");
    FacesContext context = FacesContext.getCurrentInstance();
    MethodExpression actionListener = context.getApplication().getExpressionFactory().createMethodExpression(context.getELContext(), "#{viewScope.test.onRemove}", null, new Class[] {ActionEvent.class});
    remove.addActionListener(new MethodExpressionActionListener(actionListener));
    childrenOfGroupLayout.add(remove);
    Here i have created RichCommandLink in Bean, in this i want to add the <f:attribute>
    how to add this in my current component.
    can you give some example..
    please help..

  • Pass parameter to included page and read it in the included packing bean

    Hello
    i have a page include in adf page (main.jspx include body.jspx) and i send a parameter to the included page ,and the included page has a request scope backing bean ,and in the constructor for this backing bean i tried to read the parameter , how can i get the included parameter "userId" in the backingbean which is realted to body page i.e(i want to pass the userid parameter to the body backing bean),the following is my code.
    main.jspx :
    <f:subview id="Body">
    <jsp:include page="/body.jspx";>
    <jsp:param name="userId" value="123456"/>
    </jsp:include>
    </f:subview>
    Regards
    Mohd.Weshah

    i tried your soluation
    <managed-bean>
    <managed-bean-name>testBacking</managed-bean-name>
    <managed-bean-class>checklist.TestBacking</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    <managed-property>
    <property-name>testValue</property-name>
    <property-class>java.lang.String</property-class>
    <value>${param.myParam}</value>
    </managed-property>
    </managed-bean>
    it return to me in the getter method for the testValue the experssion as string ${param.myParam} but if i put ${param.myParam} it return value.
    please advice.
    Regards
    Mohd.Weshah

  • How to access backing bean of a xml component , in a managed bean of ADF

    Hi,
    We wrote a xml component in JSF and this component is used in ADF project by including the component as jar .
    In a master detail page , we need to update the value of the xml component, when the master row is changed. How to do this.
    We are trying to do this by accessing the backing bean of the xml component in ADF project's managed bean. So when ever the row changes, we can access the managed bean in ADF and then can set the value of the xml component by accessing it's backing bean
    But i can't access the backing bean instance of the xml component in the ADF managed bean. Could you let me know how to do this. Thanks .

    Thanks for the response Shay. The xml component is added as a custom component , with a separate faces-config.xml file . This component is added to ADF project as a jar with a custom tag.
    In the ADF project , i'm having different managed beans and i can access them from a different managed bean.
    The issue is, i can't access the added custom component's backing bean which is available from a different jar , defined in a separate faces-config.xml file . This backing bean is defined with request scope.

  • Difference between a Managed Bean and Backing Bean

    hi
    i am new to JSF made my 1st appl today ...
    couldnt clearly understand difference between a Managed Bean and Backing Bean , anybody know the difference?
    Regards
    dsdsf

    These are two terms that means the same .... A backing bean is a normal web term, in JSF specifically it is termed as managed bean as this' backing bean' configurations in faces-config.xml are termed within 'managed-bean ' tags.
    Cutting the long story short its a bean class . period :)

  • 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

  • HT1296 Help! I failed to back up the data on my iphone 4 16gb using iTunes Version 11.01. The error message read that the back up was corrupt. I am suppose to delete the back up. Can someone help me? I urgently need to back up the data!:\

    Hi guys!
    I really need help. I tried to back up the data on my iphone 4 on the iTunes version 11.01 but failed.
    The error message read : the backup was corrupt or not compatible with iPhone. can anyone advise me on this,
    as I urgently need to back up my phone in anticipation for my iPhone 5.
    Greatly appreciated!

    this usally happens when the backup you tool was from an old ios version. Two options that you can try is
    1.  Delete the back up by going to edit> preferences> devices & delete back up on itunes & try backing up again
    2.  Update the ios software of the iphone4 & then take a back up. then try restoring
    Taz

  • I purchased a IMac in Feb later I added a Seagate ext. hard drive. On April 29 I received an errors that the ext. Drive may be a read only and not backing up files. I'm unable to check disk permission or correct errors. Help would be appreciated.

    I purchased a IMac in Feb later I added a Seagate ext. hard drive. On April 29 I received an errors that the ext. Drive may be a read only and not backing up files. I'm unable to check disk permission or correct errors. Help would be appreciated.

    Click on the hard drive on the desktop, then File > Get Info. What does it say about permissions?  If this is just a data drive you may want to consider "ignore ownership on this volume".
    Otherwise I can only say I have not been reading good things about Seagate drives recently.  I have some of their rock-solid ones from about 10 years ago (still running well), but now...?

  • Managed Bean Help for Definition Help

    I am working on creating Managed Bean Help for Definition Help as described in ‘19.5.3 How to Create Managed Bean Help’ section of the Web User Interface Developer's Guide fpr ADF. Using JDev Version 11.1.2.1.0.
    Thought I had all the artifacts assembled but when I run the log message is: <ELHelpProvider> <_getTranslationMap> ELHelpProvider's helpSourceExpression is null.
    Any suggestions would be greatly appreciated.
    Here is the managed bean:
    public class ELHelpProviderProjRequest extends ELHelpProvider {
        public ELHelpProviderProjRequest() {       
        /* To use the HelpProvider, the EL expression in the helpTopicId attribute must point to a Map, otherwise
           * you will get a coerceToType error. */
        public Map<String, String> getHelpMap()
              Iterator iterator = _HELP_MAP.entrySet().iterator();                
              while(iterator. hasNext()){       
              System.out.println("hash map entry " + iterator.next());
            return _HELP_MAP;
        static private final Map<String, String> _HELP_MAP = new HashMap<String, String>();
            static {
              // each element [put] can be for a separate helpTopicId attribute
              _HELP_MAP.put("MAPHELP_CATEGORY_CAPITAL_DEFINITION", "Map value for credit card definition");
              _HELP_MAP.put("MAPHELP_CATEGORY_OTHER_DEFINITION", "Map value for credit card instructions");         
    }  Here is the adf-setting.xml in Application sources / META-INF:
    <?xml version="1.0" encoding="windows-1252" ?>
    <adf-settings xmlns="http://xmlns.oracle.com/adf/settings" > 
      <adf-faces-config xmlns="http://xmlns.oracle.com/adf/faces/settings">
      <help-provider prefix="MAPHELP_">
        <help-provider-class>   
            com.corpnet.abc.util.ELHelpProviderProjRequest
        </help-provider-class>
        <property>
          <property-name>helpSource</property-name>
          <value>#{helpTranslationMap.helpMap}</value>
        </property>
      </help-provider>
    </adf-faces-config> 
    </adf-settings>Here is the faces-config:
    <managed-bean>
        <managed-bean-name>helpTranslationMap</managed-bean-name>
        <managed-bean-class> com.corpnet.abc.util.ELHelpProviderProjRequest </managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
      </managed-bean>Here is the helpTopicId in the inputText component:
    <af:inputText value="Test" inlineStyle="font-weight: bold;" id="it31" simple="true" helpTopicId="MAPHELP_CATEGORY_CAPITAL" readOnly="true"/>

    Register the managed-bean as a help provider in the adf-settings xml like:
    Example 19-9 Registering a Managed Bean as a Help Provider
    <adf-settings xmlns="http://xmlns.oracle.com/adf/settings">
    <adf-faces-config xmlns="http://xmlns.oracle.com/adf/faces/settings">
    <help-provider prefix="MAPHELP_">
    <help-provider-class>
    oracle.adf.view.rich.help.ELHelpProvider
    </help-provider-class>
    <property>
    <property-name>helpSource</property-name>
    <value>#{helpTranslationMap.helpMap}</value>
    </property>
    </help-provider>
    </adf-faces-config>
    </adf-settings>
    As you've pointed out, Review section 19.5.3 for more details -> http://docs.oracle.com/cd/E24382_01/web.1112/e16181/af_message.htm#CHDHIGIA
    You could also investigate use the OHW product available here: http://www.oracle.com/technetwork/developer-tools/help/index-083946.html

  • How to popluate a managed bean (not backing) with lookup from database

    Using ADF Faces/BC Jdev 10.1.3
    I'm trying to figure out how to populate a userInfo session bean with data from the database. When the userInfo bean instantiates I just need to look up a default directory by the logonId in a users table. Seems simple enough. How can I get to the view model when I don't have a binding (like in a backing_bean)? I've tried to put the data in the am prepareSession method (using getDBTransaction().getSession().getUserData().put("DownloadDirectory",
    userRow.getDownloadDirectory()), but doesn't seem like I can get to this info.
    Thanks,
    Doug

    Hi,
    a backing bean is not required to create a binding in ADF. For the JSP or JSPX page you display when creating the user session infromation, you can create a pagdedef file and create a rowset iterator for the view object you get the user infromation from. This can be accessed from a managed bean using teh "bindings" object
    Frank

  • Hi my mac wouldn't wake up after sleep so I read to try deleting power management plist but not I have whole lot of other problems help?

    I'm running snow leopard and now I just got a panic on computer and it froze. I'm an idiot I shouldn't have trusted what I read in a support comment : my mac wasn't waking up from sleep so read if j deleted power Managment plist it would possibly fix issue and that the file would regenerate obviously it hasn't so what can I do ?

    Reset the SMC, as per > Resetting the System Management Controller
    1. Shut down the computer.
    2. Unplug the computer's power cord.
    3. Wait fifteen seconds.
    4. Attach the computer's power cord.
    5. Wait five seconds, then press the power button to turn on the computer.
    Also, what mouse and keyboard are you using...? If they are wireless, go to Apple > System Preferences > Bluetooth > click Advanced > click Allow Bluetooth Devices to wake this computer.

  • How to set hidden value in managed bean?

    Hi
    I have the following :
                           <a4j:commandButton
                                          id="commandButton3"
                                          action="#{backing_CustSearchBean.serchCustomer}"
                                          image="images/btn_search.gif"
                                          style="position: relative; margin-right: 5px;"
                                          actionListener="#{backing_CustSearchBean.checkText}"
                                          immediate="true"
                                          status="wait"
                                          oncomplete="showQuickCreate()"
                                          >  
                                <h:inputHidden id="jsfHidden" binding="#{backing_CustSearchBean.jsfHidden}" />
                                  <a4j:status id="wait">
                                    <f:facet name="start" >
                                      <h:graphicImage url="images/SpinGear2.gif" style="position: absolute; left: 378px; top: 216px; width: 19px; height: 18px;"/>
                                    </f:facet>
                                  </a4j:status>
                     </a4j:commandButton>when the action goes in the managed bean I want to set the value of hidden parameter "jsfHidden" in managed bean and catch it in showQuickCreate (oncomplete="showQuickCreate()" ) javascript function on return to the page.
    Please help, how should I do it?

    I know nothing about a4j, but if you want to pass new parameters from JSF to the backing bean, then use f:param for commandlinks or f:attribute for commandbuttons.
    The h:inputHidden just saves backing bean properties from request to request. You can't set or change it from within the JSF.
    Not sure if the f:attribute will work for the a4j commandbutton (check if they have a support forum at their website?)
    Also see http://balusc.xs4all.nl/srv/dev-jep-com.html about passing parameters and accessing objects and beans in the facescontext.

  • Action / actionListener in h:commandButton with managed beans

    I have a problem with a backing bean whose method is not invoked when i click it. I've seen some posts on here about this yet, I still don't understand what I am doing wrong, if anything.
    Some context...I've modeled my application after 'jcatalog' from this article:
    http://www.javaworld.com/javaworld/jw-07-2004/jw-0719-jsf.html . It's simpler than the article -- I'm not using Spring/Hibernate and the persistence is the file system. For each business object (Resource), there's a backing bean (ResourceBean).
    In short, I can't get the backing bean to respond to the button event for 'Add' bound to addAction. This is just like the jcatalog 'createProduct' impl -- which doesn't use the (FacesEvent fe ) approach.
    Anyway, I would appreciate anyone's help to get past this.
    -Lorinda
    (Below are the codes...)
    Here's my beans-config.xml:
         <!-- view -->
         <managed-bean>
              <description>
                   Managed bean that is used as an application scope cache
              </description>
              <managed-bean-name>applicationBean</managed-bean-name>
              <managed-bean-class>
                   com.intalio.qa.tcm.view.beans.ApplicationBean
              </managed-bean-class>
              <managed-bean-scope>application</managed-bean-scope>
              <managed-property>
                   <property-name>viewServicesManager</property-name>
                   <value>#{viewServicesManagerBean}</value>
              </managed-property>
              </managed-bean>
         <managed-bean>
              <description>
                   View service manager impl for business services
              </description>
              <managed-bean-name>viewServicesManagerBean</managed-bean-name>
              <managed-bean-class>
                   com.intalio.qa.tcm.view.beans.ViewServicesManagerBean
              </managed-bean-class>
              <managed-bean-scope>application</managed-bean-scope>
         </managed-bean>
         <managed-bean>
              <description>
                   Backing bean that contains product information.
              </description>
              <managed-bean-name>resourceBean</managed-bean-name>
              <managed-bean-class>
                   com.intalio.qa.tcm.view.beans.ResourceBean
              </managed-bean-class>
              <managed-bean-scope>session</managed-bean-scope>
         </managed-bean>
    (Note, the applicationBean uses view services manager. The manager is used by the ResourceBean. (It's initialized by the h:output dummy variable reference at the top of my .jsp page)). I can see the initialization in the debug trace.
    Here's the resource bean:
    import java.util.ArrayList;
    import java.util.List;
    import javax.faces.FacesException;
    import javax.faces.model.SelectItem;
    import com.intalio.qa.exceptions.DuplicateIdException;
    import com.intalio.qa.exceptions.TCMException;
    import com.intalio.qa.tcm.model.Resource;
    import com.intalio.qa.tcm.view.builders.ResourceBuilder;
    import com.intalio.qa.tcm.view.util.FacesUtils;
    * Resource backing bean.
    public class ResourceBean extends RootBean {
    * The Resource id
         private String id;
         * The Resource name
         private String name;
    * Description
    private String description;
         * the resource type id associated with the Resource
         private String resourceTypeId;
    // the resource type id associated with the Resource
    private List resourceTypeIds;
    * @return Returns the resourceTypeIds.
    public List getResourceTypeIds() {
    return resourceTypeIds;
    * @param resourceTypeIds The resourceTypeIds to set.
    public void setResourceTypeIds(List resourceTypeIds) {
    this.resourceTypeIds = resourceTypeIds;
         * Default constructor.
         public ResourceBean() {
    super();
    init();
         * Initializes ResourceBean.
         * @see RootBean#init()
         protected void init() {
              try {
                   LOG.info("ResourceBean init()");
                   if (id != null) {
                        Resource resource = viewServicesManager.getResourceService().getResourceById(id);
                        ResourceBuilder.populateResourceBean(this, resource);
              } catch (TCMException ce) {
                   String msg = "Could not retrieve Resource with id of " + id;
                   LOG.info(msg, ce);
                   throw new FacesException(msg, ce);
         * Backing bean action to update Resource.
         * @return the navigation result
         public String updateAction() {
              LOG.info("updateAction is invoked");
              try {
         //          Resource Resource = ResourceBuilder.createResource(this);
              //     LOG.info("ResourceId = " + Resource.getId());
              //     viewServicesManager.getResourceService().updateResource(Resource);
                   //remove the ResourceList inside the cache
                   //FacesUtils.resetManagedBean(BeanNames.RESOURCE_LIST_BEAN);
              } catch (Exception e) {
                   String msg = "Could not update Resource";
                   LOG.error(msg, e);
                   FacesUtils.addErrorMessage(msg + ": Internal Error.");
                   return NavigationResults.FAILURE;
              LOG.info("Resource with id of " + id + " was updated successfully.");
              return NavigationResults.SUCCESS;
         * Backing bean action to create a new Resource.
         * @return the navigation result
         public String addAction() {
              LOG.info("addAction is invoked");
              try {
                   Resource resource = ResourceBuilder.createResource(this);
    LOG.info("between");
                   viewServicesManager.getResourceService().saveResource(resource);
              } catch (DuplicateIdException de) {
                   String msg = "This id already exists";
                   LOG.info(msg);
                   FacesUtils.addErrorMessage(msg);
                   return NavigationResults.RETRY;
              } catch (Exception e) {
                   String msg = "Could not save Resource";
                   LOG.error(msg, e);
                   FacesUtils.addErrorMessage(msg + ": Internal Error");
                   return NavigationResults.FAILURE;
              String msg = "Resource with id of " + id + " was created successfully.";
              LOG.info(msg);
              return NavigationResults.SUCCESS;
         * Backing bean action to delete Resource.
         * @return the navigation result
         public String deleteAction() {
              LOG.info("deleteAction is invoked");
              try {
         //          Resource Resource = ResourceBuilder.createResource(this);
         //          viewServicesManager.getResourceService().deleteResource(Resource);
                   //remove the ResourceList inside the cache
    //               FacesUtils.resetManagedBean(BeanNames.RESOURCE_LIST_BEAN);
              } catch (Exception e) {
                   String msg = "Could not delete Resource. ";
                   LOG.error(msg, e);
                   FacesUtils.addErrorMessage(null, msg + "Internal Error.");
                   return NavigationResults.FAILURE;
              String msg = "Resource with id of " + id + " was deleted successfully.";
              LOG.info(msg);
              FacesUtils.addInfoMessage(msg);
              return NavigationResults.SUCCESS;
         public String getId() {
              return id;
         * Invoked by the JSF managed bean facility.
         * <p>
         * The id is from the request parameter.
         * If the id is not null, by using the id as the key,
         * the Resource bean is initialized.
         * @param newQueryId the query id from request parameter
         public void setId(String newId) {
              id = newId;
         public String getName() {
              return name;
         public void setName(String newName) {
              name = newName;
         public String getDescription() {
              return description;
         public void setDescription(String newDescription) {
              description = newDescription;
         public String getResourceTypeId() {
              return resourceTypeId;
         public void setResourceTypeId(String newResourceTypeId) {
              resourceTypeId = newResourceTypeId;
         public String toString() {
              return "id=" + id + " name=" + name;
    Here's the jsp:
    <f:subview id="resourcesCombinedView_subview">
         <h:form id="createResourceForm" target="dataFrame">
              <h:outputText value="#{applicationBean.dummyVariable}" rendered="true" />
              <div align="center">
              <head>
              <link href="../../css/stylesheet.css" rel="stylesheet" type="text/css">
              <FONT color="#191970" size="4" face="Arial">Resources View</FONT>
              </head>
              <table style="margin-top: 2%" width="35%" cellpadding="10">
              <div align="left">
              <FONT color="#191970" size="3" face="Arial">Update Resources </FONT>
              </div>
                   <tr>
                        <td align="center" valign="top" align="center" style="" bgcolor="white" />
                        <table>
                             <tbody>
                                  <tr>
                                       <td align="left" styleClass="header" width="100" />
                                       <td align="left" width="450"/>
                                  </tr>
                                  <tr>
                                       <td align="right" width="100"><h:outputText value="Id" /></td>
                                       <td align="left" width="450"><h:inputText
                                            value="#{resourceBean.id}" id="id" required="true" /> <h:message
                                            for="id" styleClass="errorMessage" /></td>
                                  </tr>
                                  <tr>
                                       <td align="right" width="100"><h:outputText value="Name" /></td>
                                       <td align="left" width="450"><h:inputText
                                            value="#{resourceBean.name}" id="name" required="true" /> <h:message
                                            for="name" styleClass="errorMessage" /></td>
                                  </tr>
                                  <tr>
                                       <td align="right" width="100" valign="bottom"><h:outputText
                                            value="Type" /></td>
                                       <td align="left" width="550">
                                       <h:selectOneMenu
                                            value="#{resourceBean.resourceTypeId}" id="resourceTypeId">
                                            <f:selectItem itemValue="" itemLabel="Select Resource Type" />
                                            <f:selectItem itemValue="database" itemLabel="Database" />
                                            <f:selectItem itemValue="external application"
                                                 itemLabel="External Application" />
                                            <f:selectItem itemValue="internal"
                                                 itemLabel="Intalio|n3 Products" />
                                            <f:selectItem itemValue="os" itemLabel="Operating System" />
                                       </h:selectOneMenu> <h:outputText
                                            value="#{resourceBean.resourceTypeId}" /> <h:message
                                            for="resourceTypeId" styleClass="errorMessage" /></td>
                                  </tr>
                                  <tr>
                                       <td align="right" width="100" valign="bottom"><h:outputText
                                            value="Description" /></td>
                                       <td align="left" width="450"><h:inputText
                                            value="#{resourceBean.description}" id="description" size="96" />
                                       <h:message for="description" styleClass="errorMessage" /></td>
                                  </tr>
                             </tbody>
                        </table>
                        </h:form></td>
                        <!-- END DATA FORM -->
                        <!-- BEGIN COMMANDS -->
                        <td width="30%" align="left" valign="top"><h:form
                             id="buttonCommandsForm">
                             <h:panelGroup id="buttons">
                                  <h:panelGrid columns="1" cellspacing="1" cellpadding="2"
                                       border="0" bgcolor="white">
                                       <h:commandButton value="Add"
                                            style="height:21px; width:51px;font-size:8pt; font-color: black;"
                                            actionListener="#{resourceBean.addAction}">
                                       </h:commandButton>
                                       <h:commandButton id="deleteCB" value="Delete"
                                            style="height:21px; width:51px;font-size:8pt"
                                            action="#{resourceBean.deleteAction}">
                                       </h:commandButton>
                                       <h:commandButton id="spaceFillerButton" tabindex="-1"
                                            style="height:21px; width:51px;font-size:8pt;background-color: #ffffff;color: #ffffff;border: 0px;">
                                       </h:commandButton>
                                       <h:commandButton id="saveCB" value="Save"
                                            style="height:21px; width:51px;font-size:8pt"
                                            actionListener="#{resourceBean.saveAction}">
                                       </h:commandButton>
                                       <h:commandButton id="updateCB" value="Update"
                                            style="height:21px; width:51px;font-size:8pt"
                                            actionListener="#{resourceBean.updateAction}">
                                       </h:commandButton>
                                  </h:panelGrid>
                             </h:panelGroup>
                        </h:form> <!-- end buttons --></td>
                   </tr>
              </table>
              <HR align="center" size="2" width="60%" />
              <!-- data table --></div>
    </f:subview>

    Hey, anyway, have you note your jsp reference to the backing bean begins with a lowercase letter, and your backing bean class name begins with an uppercase letter?? I think that's it... I think, cause I'm too unexperienced in JSF.... Bye!!

  • Populating managed bean

    Hi,
    ok, with Bill Dudney's help I managed to figure out how to properly save a bean's state into a database. Now, I'm still lost about initializing the bean with database data to start with.
    I thought I could use <managed-property> facility, but I need to be pulling data from a database based on a request parameter (employee id), so this method didn't quite work. Any recommendations?
    Thanks
    Dmitry

    Hi Dmitri,
    Glad I could help! Lets see if I can do it again. :-)
    Ok the scenario that is in my head based on what I read in your question is this.
    Form 1 has a place to type in your employee id (maybe not type but choose or whatever) and a submit button.
    On Form 2 you want to display the data related to the employee.
    I would approach this problem in this way.
    Form 1's submit actionRef would point to an action that would get the data from a Business Delegate (the J2EE Core Pattern) then use that data to populate the Employee managed bean. I typically have each page of my application backed by a 'Page' class that has the data for the form to read and write to as well as actions that are invoked from the page. (BTW if you are in Chicago you can come see me present these ideas @ the nofluffjuststuff.com event next weekend).
    Form 2's UIInput and/or UIOutput components valueRef's would referr to the EmployeePage managed bean's attributes to get the data that is would display.
    So in your faces-config.xml file you would have something like this
      <managed-bean>
        <description>
          This page manages searching for employees (Form 1 from the discussion above)
        </description>
        <managed-bean-name> empSearchPage </managed-bean-name>
        <managed-bean-class> foo.baz.EmpSearchPage </managed-bean-class>
        <managed-bean-scope> session </managed-bean-scope>
      </managed-bean>
      <managed-bean>
        <description>
          This page manages showing employees (Form 2)
        </description>
        <managed-bean-name> empPage </managed-bean-name>
        <managed-bean-class> foo.baz.EmpPage </managed-bean-class>
        <managed-bean-scope> session </managed-bean-scope>
      </managed-bean>
    ...Then in your search page you would have something like this
      <h:input_text id="empId" size="32"
                            valueRef="empSearchPage.empId"/>
      <h:command_button id="submit" type="SUBMIT"
                                       label="Search" commandName="search"
                                       actionRef="empSearchPage.searchAction"/>
    ...Then your emp display page has something like this
      <h:output_text id="empName" size="32"
                              valueRef="empPage.empName"/>
    ...Then in your empSearchPage.searchAction you would get the data from the Biz Delegate and use that to populate the empPage.
    I think this would be better explained with a picture but since I don't to ascii art... :-)
    I hope this helps.
    TTFN,
    -bd-

Maybe you are looking for