0 Replies Latest reply on Jan 20, 2013 2:44 PM by Yannick Ongena

    Building LOV with composite components in JSF2

    Yannick Ongena
      I am trying to build a reusable list of value with composite components in JSF2.

      I'm struggling with it as I'm not able to see how I can use the value attribute to return my value. The value is not a string, it's an object which is not used in a component.

      Here's my code so far...
      composite:interface componentType="peopleFinder">
                <composite:attribute name="label" default="Member"/>
                <composite:attribute name="value"/>
                <p:inputText id="txtMember" binding="#{cc.txtMember}" disabled="true" /><p:commandButton id="cmdSearch" oncomplete="dlgPeople.show();" icon="ui-icon-search"/>
                <p:dialog header="People finder" widgetVar="dlgPeople" id="dlgPeople" width="800">
                     <p:panel header="Search">
                          <h:panelGrid columns="3">
                               <h:outputLabel value="Name"/>
                               <p:inputText value="#{peopleFinder.name}" id="txtName"/>
                               <p:commandButton icon="ui-icon-search" actionListener="#{peopleFinder.doSearch}" update="pMembers" value="Search"/>
                     <p:panel header="Members" id="pMembers">
                          <p:dataGrid value="#{peopleFinder.result}" var="member" columns="4">
                               <p:panel header="#{member.firstname } #{member.lastname}">
                                    <h:panelGrid columns="2">
                                         <p:graphicImage width="40" height="50"/>
                                         <h:panelGrid columns="2">
                                              <p:outputLabel value="Date of birth: " styleClass="label"/>
                                              <h:outputText value="#{member.dob}">
                                                   <f:convertDateTime pattern="d MMMMMMMM y"/>
                                              <p:outputLabel value="Join date: " styleClass="label"/>
                                              <h:outputText value="#{member.joinDate}">
                                                   <f:convertDateTime pattern="d MMMMMMMM y"/>
                                         <f:facet name="footer"><p:commandButton value="Select" action="#{cc.selectMember(member)}" oncomplete="dlgPeople.hide()"/></f:facet>
      So basically what I want is that the component can be used as following:
      <dc:peopleFinder value="#{someBean.selectedMember}"/>
      someBean.selectedMember is a property in a managed bean which need to be set when the user clicks the Select button in the component.
      How can I do this?