Results 1 to 5 of 5

Thread: [JSF/SWF] drop down list submit problem

  1. #1
    Join Date
    Jul 2006
    Location
    London
    Posts
    500

    Default [JSF/SWF] drop down list submit problem

    [jsf/swf]

    In the sellitem-jsf example, the drop down list has hardcoded items. Currently we are hitting problems when submitting the list based on dynamic data.

    SWF Example
    Code:
    <h:selectOneMenu id="select_roles" value="#{flowScope.userAddCommand.roleId}">
      <f:selectItem itemLabel="None (0.02 discount rate)" itemValue=""/>
      <f:selectItem itemLabel="Cat. A (0.1 discount rate when more than 100 items)" itemValue="A"/>
      <f:selectItem itemLabel="Cat. B (0.2 discount rate when more than 200 items)" itemValue="B"/>
    </h:selectOneMenu>
    Our dynamically populated list.
    Code:
    <h:selectOneMenu id="select_roles" value="#{flowScope.userAddCommand.roleId}">              
      <f:selectItems value="${roles}" />
    </h:selectOneMenu>
    The list displays fine, its on sumbit it falls over.

    The list is a collection of SelectItem objects.

    ${roles} is put into flowScope by:

    Code:
    <method-result name="roles"/>
    Are we missing something fundemental here?

    kind regards

  2. #2
    Join Date
    Nov 2006
    Location
    munich
    Posts
    21

    Default

    The list displays fine, its on sumbit it falls over
    do you get any exception?

  3. #3
    Join Date
    Jul 2006
    Location
    London
    Posts
    500

    Default

    as requested:

    Code:
    javax.faces.FacesException: Value binding '${roles}'of UISelectItems with component-path {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /pages/user/userRegistrationForm.xhtml][Class: javax.faces.component.html.HtmlForm,Id: registrationForm][Class: javax.faces.component.html.HtmlSelectOneMenu,Id: select_roles][Class: javax.faces.component.UISelectItems,Id: _id11]} does not reference an Object of type SelectItem, SelectItem[], Collection or Map but of type : null 
    de.mindmatters.faces.lifecycle.ProcessValidationsPhase.executePhase(ProcessValidationsPhase.java:48) 
    de.mindmatters.faces.lifecycle.AbstractPhase.execute(AbstractPhase.java:37) 
    de.mindmatters.faces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:166) 
    de.mindmatters.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:211) 
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:137) 
    org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144) 
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    Clearly there is something wrong in the way the state is handled, because if elements are hardcoded into the list things are ok, maybe its the way I am populating the list via a service call in a render-action.

    Code:
    <render-actions>
      <bean-action bean="userDelegateService" method="findAllRoles">
       <method-result name="roles"/>
      </bean-action>
    </render-actions>

    regards,
    Last edited by jamesclinton; Dec 8th, 2006 at 03:19 AM.

  4. #4
    Join Date
    Nov 2006
    Location
    munich
    Posts
    21

    Default

    I see things I am not completely sure about...

    First of all ${role} seems to be a jstl expression instead of a jsf one, I am a bit surprised that you can see the select item list like that...

    Then I would try to bind the method-result explicitly to the flowScope since I am personally never sure which is the default one (I wouldn't bet on it but most of the time it turned out to be the requestScope), something like
    Code:
    <method-result name="roles" scope="flow"/>
    and then trying to access the value in a way like this:
    Code:
    <f:selectItems value="#{flowScope.roles}" />
    let me know

  5. #5
    Join Date
    Jul 2006
    Location
    London
    Posts
    500

    Default :)

    Your right. Cheers!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •