1 2 3 Previous Next 34 Replies Latest reply on Jun 30, 2006 12:00 PM by supernovasoftware.com Go to original post
      • 30. Re: whew! finally, a pattern for SelectItems using generics
        paper

        Thanks to Patric for the LookupConverter Code (and related) I use a simular solution and have posted my code here:
        http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3925444#3925444

        Works good with the DAOpattern (also generic).
        Like described here:
        http://www.jboss.org/index.html?module=bb&op=viewtopic&t=75802
        It uses Seam Components to put in the facelets code so the converter may not be registered in the facelets-conf.xml

        Dennis

        • 31. selectOneMenu doesn't work with Facelets + MyFaces
          newion

          Look at the code below. It works perfectly but only without Facelets. With Facelets page is not generated correctly.

          <h:form>
          <h:dataTable value="#{employeeList}" var="empl" rendered="true" >
           <h:column>
           <h:outputText value="#{empl.name}"/>
           </h:column>
           <h:column>
           <h:selectOneMenu id="country" value="#{empl.country}" converter="CountryConverter">
           <f:selectItems value="#{selectItems.countries}" />
           </h:selectOneMenu>
           </h:column>
          </h:dataTable>
          <h:commandButton type="submit" action="#{employeesEditor.update}" value="Apply"/>
          </h:form>
          


          HTML generated correctly (without facelets):
          <select id="_id0:_id1_0:country" name="_id0:_id1_0:country" size="1"> <option value="1">Germany</option> <option value="2" selected="selected">Poland</option> <option value="3">Switzerland</option> <option value="4">Ukraine</option></select>


          HTML generated incorrectly (with facelets):
          <f:selectItems value="[javax.faces.model.SelectItem@dd14d9, javax.faces.model.SelectItem@83f3a0, javax.faces.model.SelectItem@efc0ee, javax.faces.model.SelectItem@6352f8]"/>
           <select id="_id0:_id1_0:country" name="_id0:_id1_0:country" size="1"></select>


          Do you have any idea how to solve this problem? Anybody succeeded with Facelets and converters described in this topic?

          Thanks,
          Pawel Kaczor

          • 32. Re: selectOneMenu doesn't work with Facelets + MyFaces
            newion

            I've managed to solve the problem! I've installed myfaces-tomahawk extension components (tomahawk.jar)
            and added tomahawk.taglib.xml (http://wiki.apache.org/myfaces/Use_Facelets_with_Tomahawk)
            I've also added definition of my converter to this taglib file.
            Now (most important:), istead of <f:selectItems> I use <t:navigationMenuItems> and it works!

            <t:dataTable value="#{employeeList}" var="empl" rendered="true" >
             <t:column>
             <t:outputText value="#{empl.name}"/>
             </t:column>
             <t:column>
             <t:selectOneMenu id="country" value="#{empl.country}" converter="CountryConverter">
             <t:navigationMenuItems value="#{selectItems.countries}" />
             </t:selectOneMenu>
             </t:column>
            </t:dataTable>
            



            Pawel Kaczor

            • 33. Re: whew! finally, a pattern for SelectItems using generics
              coryvirok

              Just wanted to add my thanks for the lookup code. I'm still fairly new to this whole Seam business so every little bit helps!

              The only thing I modified was the lookup interface. I changed the

              public String getKey();
              public String getName();
              
              to
              
              public String lookupKey();
              public String lookupName();
              


              so that Hibernate didn't mistake it for a column in the DB schema.
              Works great!

              - Cory

              • 34. Re: whew! finally, a pattern for SelectItems using generics

                I would like for the list to be able pulled from a query so I that I can control which entities are selected, the description, label, and in what order they appear.

                I do not mind putting annotation and or making my enties implement specific interfaces.

                I have not tried this, but maybe this could work for me. Any thoughts?

                select new SelectItem( y, y.contact.company, y.contact.companyAbreviation) from Yard y where y.area=:area order by y.contact.companyAbreviation

                1 2 3 Previous Next