Using Managed bean

Hi All,
How to use managed bean instead of backing bean to retreive a value from a object.
a)Say in my form i have selectoneChoice box and i need to retreive the value inputed by the user
b)According to the value selected by the user i need to show a tick mark or cross mark. Is it possible.
Am using ADF 11g
Please guide me how to acheive this.
Thanks in Advance

Your backing bean can access the bindings object and get the value of the attribute from there in your code.
Lots of code samples for this here:
http://biemond.blogspot.com/2009/03/some-handy-code-for-backing-beans-adf.html
For list binding there is a little trick though:
http://www.oracle.com/technetwork/developer-tools/jdev/listbindingvalue-088449.html
I would also suggest that you watch the seminars about binding in the ADF Insider series:
http://www.oracle.com/technetwork/developer-tools/adf/learnmore/adfinsider-093342.html

Similar Messages

  • Generate PDF using Managed Bean with custom HTTP headers

    Background
    Generate a report in various formats (e.g., PDF, delimited, Excel, HTML, etc.) using JDeveloper 11g Release 2 (11.1.2.3.0) upon clicking an af:commandButton. See also the StackOverflow version of this question:
    http://stackoverflow.com/q/13654625/59087
    Problem
    HTTP headers are being sent twice: once by the framework and once by a bean.
    Source Code
    The source code includes:
    - Button Action
    - Managed Bean
    - Task Flow
    Button Action
    The button action:
    <af:commandButton text="Report" id="submitReport" action="Execute" />
    Managed Bean
    The Managed Bean is fairly complex. The code to `responseComplete` is getting called, however it does not seem to be called sufficiently early to prevent the application framework from writing the HTTP headers.
    HTTP Response Header Override
    * Sets the HTTP headers required to indicate to the browser that the
    * report is to be downloaded (rather than displayed in the current
    * window).
    protected void setDownloadHeaders() {
    HttpServletResponse response = getServletResponse();
    response.setHeader( "Content-Description", getContentDescription() );
    response.setHeader( "Content-Disposition", "attachment, filename="
    + getFilename() );
    response.setHeader( "Content-Type", getContentType() );
    response.setHeader( "Content-Transfer-Encoding",
    getContentTransferEncoding() );
    Issue Response Complete
    The bean indirectly tells the framework that the response is handled (by the bean):
    getFacesContext().responseComplete();
    Bean Run and Configure
    public void run() {
    try {
    Report report = getReport();
    configure(report.getParameters());
    report.run();
    } catch (Exception e) {
    e.printStackTrace();
    private void configure(Parameters p) {
    p.put(ReportImpl.SYSTEM_REPORT_PROTOCOL, "http");
    p.put(ReportImpl.SYSTEM_REPORT_HOST, "localhost");
    p.put(ReportImpl.SYSTEM_REPORT_PORT, "7002");
    p.put(ReportImpl.SYSTEM_REPORT_PATH, "/reports/rwservlet");
    p.put(Parameters.PARAM_REPORT_FORMAT, "pdf");
    p.put("report_cmdkey", getReportName());
    p.put("report_ORACLE_1", getReportDestinationType());
    p.put("report_ORACLE_2", getReportDestinationFormat());
    Task Flow
    The Task Flow calls Execute, which refers to the bean's `run()` method:
    entry -> main -> Execute -> ReportBeanRun
    Where:
    <method-call id="ReportBeanRun">
    <description>Executes a report</description>
    <display-name>Execute Report</display-name>
    <method>#{reportBean.run}</method>
    <outcome>
    <fixed-outcome>success</fixed-outcome>
    </outcome>
    </method-call>
    The bean is assigned to the `request` scope, with a few managed properties:
    <control-flow-rule id="__3">
    <from-activity-id>main</from-activity-id>
    <control-flow-case id="ExecuteReport">
    <from-outcome>Execute</from-outcome>
    <to-activity-id>ReportBeanRun</to-activity-id>
    </control-flow-case>
    </control-flow-rule>
    <managed-bean id="ReportBean">
    <description>Executes a report</description>
    <display-name>ReportBean</display-name>
    <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    The `<fixed-outcome>success</fixed-outcome>` strikes me as incorrect -- I don't want the method call to return to another task.
    Restrictions
    The report server receives requests from the web server exclusively. The report server URL cannot be used by browsers to download directly, for security reasons.
    Error Messages
    The error message that is generated:
    Duplicate headers received from server
    Error 349 (net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION): Multiple distinct Content-Disposition headers received. This is disallowed to protect against HTTP response splitting attacks.Nevertheless, the report is being generated. Preventing the framework from writing the HTTP headers would resolve this issue.
    Question
    How can you set the HTTP headers in ADF while using a Task Flow to generate a PDF by calling a managed bean?
    Ideas
    Some additional ideas:
    - Override the Page Lifecycle Phase Listener (`ADFPhaseListener` + `PageLifecycle`)
    - Develop a custom Servlet on the web server
    Related Links
    - http://www.oracle.com/technetwork/middleware/bi-publisher/adf-bip-ucm-integration-179699.pdf
    - http://www.slideshare.net/lucbors/reports-no-notes#btnNext
    - http://www.techartifact.com/blogs/2012/03/calling-oracle-report-from-adf-applications.html?goback=%2Egde_4212375_member_102062735
    - http://docs.oracle.com/cd/E29049_01/web.1112/e16182/adf_lifecycle.htm#CIABEJFB
    Thank you!

    The problem was that the HTTP headers were in fact being written twice:
    1. The report server was returning HTTP response headers.
    2. The bean was including its own HTTP response headers (as shown in the question).
    3. The bean was copying the entire contents of the report server response, including the headers, into the output stream.
    Firefox ignored the duplicate header errors, but Google Chrome did not.

  • 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.

  • Using managed bean method in expression builder

    Hello,
    I'm new to adf and I have the following problem.
    I have a managed bean in session scope that has the following method:
    public boolean alertMessages() throws NamingException,
    SQLException {
    if (condition)
    {  return true;}
    else
    {return false;}
    I have a page that has a link. Using the expression builder and according the function result I want to make the link bold or not.
    I use the expression #{sessionScope.backing_pages_index.alertMessages ?'bold':'normal'} but it does'n work.
    Could anybody help me.
    Thank you,

    Hi..
    If you add your bean as sessionScope No need to add sessionScope to EL front,and should setter and getter for alertMessages
    use *font-weight:#{backing_pages_index.alertMessages ? 'bold':'normal'}*
    try as follows it is working for me
    > private boolean alertMessages;
    > public void setAlertMessages(boolean alertMessages) {
    > this.alertMessages = alertMessages;
    > }
    > public boolean isAlertMessages() {
    > if (true) {
    > return true;
    > } else {
    > return false;
    > }
    > }
         <af:commandLink text="commandLink 1" id="cl1" action="CustomPage"> inlineStyle="font-weight:#{backing_pages_index.alertMessages ? 'bold':'normal'};"/>

  • Use managed beans in navigation model

    Hello
    I have a bean called UserInfoBean.
    UserInfoBean is managed in faces-config.xml and uses a Java API to determine if a user has access to a page within my WebCenter Portal. The method is called isUserAuthorized.
    In default-navigation-model.xml I try to set the visible field to #{userInfoBean.isUserAuthorized} but it says that 'userInfoBean is an unknown variable'.
    Do I need to manage UserInfoBean in adfc-config.xml??
    Thanks!
    Mitch

    What's the scope of the bean?
    Any specific reason why you are not using the built-in declarative security that ADF/WebCenter gives you. You can assign page/taskflow privileges without having to write any code.

  • Popup on page load using managed bean, using jdev-11.4

    Hi,
    My requirement is on the button click from page 1 the control should get passed to new window(2nd page), and the popup should be opened on load.
    And after clicking button on the pop-up the control should get transferred to the 3rd page.
    Please let me know how to do this.
    Thanks,
    Nitin

    Here, is a sample based on the mentioned use-case.
    1) Create three pages namely FirstPage, SecondPage & ThirdPage
    2) Create the following navigation rules
    From FirstPage to SecondPage ==> gotoSecond
    From SecondPage to ThirdPage ==> gotoThird
    3) The following code snippets show the flow.
    FirstPage.jspx:
    <af:document id="d1">
    <af:form id="f1">
    <af:commandButton text="Go to Second Page" id="cb1"
    action="gotoSecond"/>
    </af:form>
    </af:document>
    SecondPage.jspx:
    *<f:view beforePhase="#{SecondPageBean.phaseListener}">*
    <af:document id="d1">
    <af:form id="f1">
    <af:popup id="p1" binding="#{SecondPageBean.popup}">
    <af:dialog id="d2" closeIconVisible="false" type="none">
    <af:outputLabel value="Popup Contents" id="ol1"/>
    *<af:commandButton text="Go to Third Page" id="cb1"*
    action="gotoThird"/>
    </af:dialog>
    </af:popup>
    </af:form>
    </af:document>
    </f:view>
    SecondPageBean.java:
    import javax.faces.event.PhaseEvent;
    import oracle.adf.view.rich.component.rich.RichPopup;
    public class SecondPageBean {
    private RichPopup popup;
    public SecondPageBean() {
    *public void phaseListener(PhaseEvent phaseEvent) {*
    *if (phaseEvent.getPhaseId().equals(phaseEvent.getPhaseId().RENDER_RESPONSE)) {*
    RichPopup.PopupHints hints = new RichPopup.PopupHints();
    popup.show(hints);
    public void setPopup(RichPopup popup) {
    this.popup = popup;
    public RichPopup getPopup() {
    return popup;
    ThirdPage.jspx:
    <af:document id="d1">
    <af:form id="f1">
    <af:outputLabel value="In Page3" id="ol1"/>
    </af:form>
    </af:document>
    Thanks,
    Navaneeth

  • Use ADF Managed Bean to get the username in BPM Workspace

    Hi all,
    I used JSF and ADF to build the UI of human task. And I want to get the username of the user who is manipulate on BPM Workspace. For example, an ADF form can display the username of current user in BPM Workspace. I also try this approach: use Manage Bean, and bind this bean to a output text in ADF form. The code fragment I use to get the current username is:
    ADFContext.getCurrent().getSecurityContext().getUserPrincipal().getName();
    But it does not work. The value I get is Anonymous.
    So, plz help me solve this problem

    Hi, please try this function as below:
    public String getUserLogin() throws WorkflowException,
    BPMIdentityException,
    BPMUnsupportedAttributeException {
    String userId = "";
    IWorkflowServiceClient wfSvcClient;
    ITaskQueryService queryService;
    IWorkflowContext wfContext;
    // Get username of User Login
    String contextStr = ADFWorklistBeanUtil.getWorklistContextId();
    wfSvcClient = WorkflowService.getWorkflowServiceClient();
    queryService = wfSvcClient.getTaskQueryService();
    wfContext = queryService.getWorkflowContext(contextStr);
    userId = wfContext.getUser();
    return userId;
    Regards.

  • Managed Bean in Task Form

    Hi!Oracle Fusion Middleware 11.1.1.5.0, Oracle JDeveloper 11g.
    I post this thread in this section because of the type of project I am working in (SOA Application).
    I am trying to customize a BPEL Task Form.
    After I made a project using Fusion Web Application, I could confirm that the managed beans for some ADF Faces components were working and the form (an .jspx page that I would run on Integrated Web Logic Server) was functional.
    I made a project using SOA Application.
    I made a BPEL Process with a Human Tak and using the Launch Task Form Wizard I made a form.
    Then I started adding ADF Faces components that are using managed beans, just like in the other project.
    When I deploy the project, all the components using the beans just dont show up. If I dont use the components with the managed beans the form appears normally.
    Is there some additional requirement to make the bindings with the managed beans in the Task Form?
    To clarify the question below I have some printscreens:
    1. SelectOneChoice "Rubrica" component with value binding from the ActionListenerOK java class;
    http://i43.tinypic.com/x4j0ol.jpg
    2. Showing the Expression Builder for the above value binding;
    http://i42.tinypic.com/14mdxqq.jpg
    3. Method Expression Builder for a Button Component;
    http://i41.tinypic.com/2r38tw2.jpg
    4. The managed beans list for the form page;
    http://i41.tinypic.com/rbjqt2.jpg
    5. How the form appears when using the components with java bean bindings;
    http://i39.tinypic.com/34pghh0.jpg
    6. How the form appears when delete the components with tha java bindings;
    http://i41.tinypic.com/2mwwkuo.jpg

    &lt;af:outputText value="Authenticated User: #{securityContext.userName}" id="ot2"/>
    or via standard j2se apis (Subject.getSubject(..))
    hth clemens (http://blogs.oracle.com/soabpm)

  • Rendered Property calling managed bean Multiple Times

    Hi
    We have a problem within a command button in a jspx, which includes a rendered tag which references a managed bean method via EL.
    e.g.
    rendered="#{PERUserInfo.trainee}"
    When I debug the jspx, the PERUserInfo.trainee method is called 4 times instead of once.
    We have noticed similar findings when using managed bean methods via the rendered property. i.e. calls getters multiple times.
    Any idea why this is happening?
    We are using JDeveloper v10.1.3, JHS v10.1.3 SU1.
    All comments appreciated.
    Cheers
    Denis

    Denis,
    There can be many reasons why your bean method is called multiple times; but I would consider this perfectly normal in any JSF application considering all the lifecycles and (possible) Partial Page Rendering that happens.
    The question is, by the way, more appropriate on the JDeveloper forum since it is not directly related to JHeadstart itself.
    Hope this helps,
    Evert-Jan de Bruin

  • Managed Bean Best Practices

    Hi
    Are there any best practices for using Managed Beans?
    We plan to use our own custom-built JSF components. Need to understand how to design backing beans for performance/effort optimization.
    For example :
    1. How to make managed beans thread-safe for concurrent requests, without compromising on efficiency/speed?
    2. How to enforce the J2EE security with managed-beans?
    3. How to decide the scope of these beans to ensure minimal data-storage in session?
    4. How to decide the granularity at which a managed-bean should be used for example :
    4.1 One bean-per-component
    Advantages :
    a) if complex components require special data-holding/processing/event-handling capabilities from bean
    (e.g. datagrid model,tree model,menu model)
    Problems :
    - with multiple components in a page/form
    a) it becomes tedious to debug/change/track which bean serves which component
    b) if session scope is required, too many beans will be cached in session
    c) unnecessarily too many beans will be created on server (= n pages * m components-per-page)
    d) unnecessarily increases the length of faces-config.xml
    4.2 One bean-per-form
    Advantages :
    a) in multi-form web pages, to ensure the functional behaviour of each form is separate/modular in its own bean.
    b) each managed-bean would map to specific/meaningful functionality/user-interaction in use-case.
    Problems :
    - if form includes complex components (datagrid/tree/menu) requiring a specialised bean class, then
    a) either one of the specialized bean has to be augmented with additional logic to handle data/events for all other components within the form
    (Not good, as it mixes-up the responsibilities of component-specific-beans, and the bean may no more be reusable in another form)
    b) or without using component-specific beans, only single form bean should handle the data/events for all components in the form?
    (Neither good, since if a complex tree-compoent is reused in multiple forms, then the logic to handle data/events for such a component will be repeated in those many form-specific managed beans)
    4.3 One bean-per-page
    Advantages :
    a) seems more modular/meaningful way - since a page would map to some feature within the use-case
    b) bean will contain only behaviour which is relevent for the associated page/function within use-case
    Problems :
    a) in multi-form pages, can single bean handle data/events for multiple forms?
    b) if page uses complex component (e.g datagrid, tree) that needs its own bean - how does page-bean exchange data with component-bean?
    Thanks,
    Arti

    Are there any best practices for using Managed
    Beans?There are no best practices for using Managed Beans in terms of Sun, or other vendors recommendations. But there are some patterns that can be applied to the managed beans (The managed bean is already a pattern). Also common sense is allways a good practice.
    For example, the managed bean should not have business logic code, only presentation logic code, etc.
    1. How to make managed beans thread-safe for
    concurrent requests, without compromising on
    efficiency/speed?The beans can be created by request, so concurrency is not an issue. If they are session scope, also is not an issue because, a user can only have one thread running. Only in application scope you must have carefull.
    >
    2. How to enforce the J2EE security with
    managed-beans?see this:
    http://jsf-security.sourceforge.net/
    About jsf-security
    >
    3. How to decide the scope of these beans to ensure
    minimal data-storage in session?If you wnat minimal data-storage in session the answer is request or none.
    In question 4, you make the question and give the answer ;-)

  • Shoudn't Managed Bean be part of view state?

    Hello,
    Why does JSF not identify managed bean as part of view state? After all it is beans which provide the data (model) for components in view. Isn't data part of view state?
    There are number of problems with 'request' scoped beans - in fact there are enough reasons to question why JSF allowed 'request' scope in first place.
    1. Choice of request scope saves storage, but requires the developers to save the bean data in session and restore that data everytime when the bean is reconstructed on subsequent POST backs.
    2. Failure to store or restore the bean's previous data results in NullPointerExceptions during APPLY_REQUEST_VALUES phase, when JSF tries to compare old values with new submitted values to broadcast events.
    3. This essentially mean beans are required (with old data) right at the APPLY_REQUEST_VALUES phase, same as the view state.
    4. Any storing of data in session creates overhead of cleaning it without fail. Failure to clean results in too big session storage affecting performance.
    5. Restoring bean state sometimes also means database calls as early as APPLY_REQUEST_VALUES phase - which is not the right phase for such business logic.
    JSF spec should at least provide a way for developers to configure the bean to be saved in view state.

    Hello,
    Why does JSF not identify managed bean as part of
    view state? After all it is beans which provide the
    data (model) for components in view. Isn't data part
    of view state?No. MVC is about seperating M-V-C. Model - View - Controller. View == page, Model == data. Data can be very large in some cases, storing it with a page (per user) is not scalable and is not a good idea in many cases.
    There are number of problems with 'request' scoped
    beans - in fact there are enough reasons to question
    why JSF allowed 'request' scope in first place. Request scope is very useful for certain things. I think a "pageScope" is missing, which is why I added it to JSFTemplating (https://jsftemplating.dev.java.net). Request scope is not appropriate for all cases.
    1. Choice of request scope saves storage, but
    requires the developers to save the bean data in
    session and restore that data everytime when the bean
    is reconstructed on subsequent POST backs.
    2. Failure to store or restore the bean's previous
    data results in NullPointerExceptions during
    APPLY_REQUEST_VALUES phase, when JSF tries to compare
    old values with new submitted values to broadcast
    events.
    3. This essentially mean beans are required (with old
    data) right at the APPLY_REQUEST_VALUES phase, same
    as the view state.Both managed beans and the request scope map itself can make this happen transparently.
    4. Any storing of data in session creates overhead of
    cleaning it without fail. Failure to clean results in
    too big session storage affecting performance.I agree.
    5. Restoring bean state sometimes also means database
    calls as early as APPLY_REQUEST_VALUES phase - which
    is not the right phase for such business logic.Depends on how you write your beans / application.
    JSF spec should at least provide a way for developers
    to configure the bean to be saved in view state.You don't have to use beans let alone use "managed" beans. If you feel your application would be better off storing data w/ the view state... get the UIViewRoot, call setAttribute("key", yourData).
    Good luck!
    Ken Paulsen
    https://jsftemplating.dev.java.net

  • Circular dependencies in managed beans

    Hi,
    I have been using JSF for a couple of weeks now and am wondering about an IoC specific issue that arises when using managed beans. The basic problem is that, when I create a circular dependency between two managed beans, I get StackOverflow errors. My beans are declared in the JSF configuration as both having one managed-property of which the value contains an EL expression pointing to the other bean. (BTW: the two beans each back a page in a Master-Detail scenario and need to pass some information to each other)
    The stack trace seems to denote that the cause of this problem is the separation of the EL lookup and the ManagedBeanBuilder. As this seems to be a pretty basic configuration, I am a bit flabbergast that JSF trips on this. How should I solve this?
    -mik
    PS: Just to cut of that path: I do not want to call FacesContext.getCurrentContext() to fill up the dependencies after the setup was done. Apart from really hurting my Karma, it would also destroy the POJO-ness of these components and make unit testing a whole lot more difficult�

    Use SessionMap to communicate between beans in one session.
    Also see http://balusc.xs4all.nl/srv/dev-j2p-com.html

  • Query with bind variable, how can use it in managed bean ?

    Hi
    I create query with bind variable (BindControlTextValue), this query return description of value that i set in BindControlTextValue variable, how can i use this query in managed bean? I need to set this value in String parameter in managed bean.
    Thanks

    Put the query in a VO and execute it the usual way.
    If you need to, you can write a parameterized method in VOImpl that executes the VO query with the parameter and then call that method from the UI (as a methodAction binding) either through the managed bean or via a direct button click on the page.

  • How do I use a managed bean in another managed bean

    I have two managed beans. One is backing bean for a form and the other is used to access a database table.
    1st bean
    public class TestDBAO
    @PersistenceContext
    private EntityManager em;
    public void addEntry(PersonObj person)
    em.persist(person);
    public class formdata
    private String id;
    private String fname;
    private String lname;
    getter functions
    setter functions
    public String submit()
    in here i want to call addEntry function from TestDBAO
    How can I achieve this or is there another way to do this?

    Do I understand correctly that you have definied TestDBAO as a session scoped managed bean? Why?
    You don't need that. Just create and call TestDBAO in the backing bean. Or if you want only one instance of TestDBAO during the session, then create a singleton constructor and eventually make the methods static.

  • Urgent - can't set managed bean value using a form, getting null

    I have a form with a bean -- unbelievably, I can't get the values entered into the form by the user to get stored into the bean. Everything is null... I've looked at a zillion examples, posts and compared etc...yet still can't see what is missing.
    Here's part of a trace :
    [cc]Dec-31 01:25:02 ApplicationImpl - Created bean resourceBean successfully
    [cc]Dec-31 01:25:02 ApplicationImpl - Storing resourceBean in scope request
    [cc]Dec-31 01:25:02 VariableResolverImpl - resolveVariable: Resolved variable:id=null name=null
    [cc]Dec-31 01:25:02 ValueBindingImpl - getValue Result:id=null name=null
    [cc]Dec-31 01:25:02 ValueBindingImpl - -->Returning id=null name=null
    If you have any ideas, please let me know--it seems just as I solve one JSF issue, I run into another on unexpectedly simple things.
    Here's the ResourceBean.java, the bean-config.xml and my jsp.
    package com.intalio.qa.tcm.view.beans;
    import java.util.Map;
    import javax.faces.context.FacesContext;
    import javax.faces.model.SelectItem;
    import org.apache.log4j.Logger;
    import com.intalio.qa.exceptions.DuplicateIdException;
    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 {
         * Class logger
         public static final Logger LOG =
              Logger.getLogger(ResourceBean.class);
    * The Resource id
         private String id = null;
         * The Resource name
         private String name = null;
    * Description
    private String description= null;
         * the resource type id associated with the Resource
         private String resourceTypeId= null;
         private static SelectItem[] resourceTypeIds = new SelectItem[] {
              new SelectItem("External Software"),
              new SelectItem("Hardware"),
              new SelectItem("Intalio Product Software"),
              new SelectItem("Machine - Dual CPU"),
              new SelectItem("Machine - CPU Single"),
              new SelectItem("Memory - UNIX"),
              new SelectItem("Memory - Windows") };
    * @return Returns the resourceTypeIds.
    public SelectItem[] getResourceTypeIds() {
    return resourceTypeIds;
    * @param resourceTypeIds The resourceTypeIds to set.
    public void setResourceTypeIds(SelectItem[] typeIds) {
    resourceTypeIds = typeIds;
         * Default constructor.
         public ResourceBean() {
    super();
    init();
         * Initializes ResourceBean.
         * @see RootBean#init()
         protected void init() {
         /*True, but I'd strongly recommend instead using:
    FacesContext fContext = FacesContext.getCurrentInstance();
    Map requestParams = fContext.getExternalContext().getRequestParameterMap();
    String companyId = (String) requestParams.get("companyID");
    The getRequest(), getSession(), and getContext() methods of ExternalContext should only be used as a last resort.*/
         * 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);
              } catch (Exception e) {
                   String msg = "Could not update Resource";
                   LOG.error(msg, e);
                   FacesUtils.addErrorMessage(msg + ": Internal Error.");
                   return ActionResult.FAILURE;
              LOG.info("Resource with id of " + id + " was updated successfully.");
              return ActionResult.SUCCESS;
         * Backing bean action to create a new Resource.
         * @return the navigation result
         public String addAction() {
              try {
                   Resource resource = ResourceBuilder.createResource(this);
    LOG.info("resource created: " + resource.getName() + " with typeId = " + resource.getResourceTypeId());
                   viewServicesManager.getResourceService().saveResource(resource);
              } catch (DuplicateIdException de) {
                   String msg = "This id already exists";
                   LOG.info(msg);
                   FacesUtils.addErrorMessage(msg);
                   return ActionResult.RETRY;
              } catch (Exception e) {
                   String msg = "Could not save Resource";
                   LOG.error(msg, e);
                   FacesUtils.addErrorMessage(msg + ": Internal Error");
                   return ActionResult.FAILURE;
              String msg = "Resource with id of " + id + " was created successfully.";
              LOG.info(msg);
              return ActionResult.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 ActionResult.FAILURE;
              String msg = "Resource with id of " + id + " was deleted successfully.";
              LOG.info(msg);
              FacesUtils.addInfoMessage(msg);
              return ActionResult.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) {
              LOG.info("setId " + 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;
         <!-- view -->
         <managed-bean>
              <description>
                   Managed bean
              </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>request</managed-bean-scope>
              <managed-property>
                   <property-name>viewServicesManager</property-name>
                   <value>#{viewServicesManagerBean}</value>
              </managed-property>
         </managed-bean>
    </faces-config>
    <f:view>
         <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"/> <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" /> <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>
                                            <f:selectItems value="#{resourceBean.resourceTypeIds}" />
                                       </h:selectOneMenu> <h:outputText value="#{resourceBean.resourceTypeId}" id="dresourceTypeId" /> <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;" action="#{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" 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" action="#{resourceBean.saveAction}">
                        </h:commandButton>
                        <h:commandButton id="updateCB" value="Update" style="height:21px; width:51px;font-size:8pt" action="#{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:view>
    THANKS.
    -L

    I solved this.
    Since I was testing the action code only, I didn't define a navigation entry corresponding to the action string returned for this button:
    <h:commandButton value="Add" style="height:21px; width:51px;font-size:8pt; font-color: black;" action="#{resourceBean.addAction}">
    </h:commandButton>After I added a nav definition, it worked. I don't know why at this point. I suspect a key step in the lifecycle was pre-empted...someone else can probably explain why. If I get a chance to research it after I'm done with my project, I'll update this post.
    Thanks.
    -L

Maybe you are looking for