2 Replies Latest reply on Oct 9, 2007 9:39 AM by dkane

    Standard task : lookup field

    dkane

      Was pretty sure this topic is described in documentation or discussed in forum, but have not found anything so far. Probably, wrong keywords were used..

      The form displays editable list of "clients" entities (DataModel + rich:dataTable).

      Each client has category_id field.

      "Categories" table has category_id and name fields.

      I need a "Category" column in clients table, with drop-down list in each row. User should be able to set category_id for client using this list. The actually displayed value in field and drop-down list should be Category."name".

      Thank you in advance for your help.

        • 1. Re: Standard task : lookup field
          swd847

          Something like:

          
          <rich:datatable value="#{datamodel}" var="var">
           <rich:column>
           <f:facet name="header">Category</f:facet>
           <h:selectOneMenu value="#{var.category_id}" converter="#{converters.myConverter}" />
           <s:selectItems value="#{categoryList}" var="cat" label="#{cat.name}"/>
           </h:selectOneMenu>
           </rich:column>
          </rich:datatable>
          
          


          Most likely you will want to use <s:convertEntity/> rather that a custom converter, if however you actually want to set the category_id property explicitly (i.e. you are not using hibernate to map the one to many relationship) then you will need to write a converter to convert between the Category entity and it's id, look in the docs for an example.



          • 2. Re: Standard task : lookup field
            dkane

            Thank you very much. Got it working.