4 Replies Latest reply on Oct 3, 2007 6:04 PM by Pete Muir

    Datmodel(Selection with facelets) does not work

    Carsten Hoehne Master

      Hello,
      today i have a question about DataModelSelection. I have not found an answer for this for more than one year. But now a solution will be greatly appreciated.
      This is the starting point: (all code is simplified)
      i do have a fully functinal page in my app:

      [...]
       <rich:dataTable id="experimentSiteList" var="experimentSite" value="#{experimentSiteList}">
      
       <rich:column>
       <h:outputText size="5" id="year" value="#{experimentSite.experiment.year}"></h:outputText>
       </rich:column>
      [...]
       <rich:column>
       <s:link id="viewFieldplan" value="Fieldplan"
       action="#{htmlFieldplanBacking.showFieldplan}"
       propagation="begin" target="Fieldplan">
       <f:param name="experimentid"
       value="#{experimentSite.experiment.experimentId}" />
       </s:link>
       </rich:column>
       </rich:dataTable>
      

      and the backing contains the datamodel
      @DataModel
       private List<ExperimentSite> experimentSiteList;
      
       @DataModelSelection
       @Out(required=false)
       private ExperimentSite selectedExperimentSite;
      
       @Factory("experimentSiteList")
       public void getExperimentSitesByUser() {
       experimentSiteList = experimentQuery.getResultList();
       }
      
      

      The experimentSites are shown and when clicking on the link the selectedExperimentSite is set.

      The problem is:
      We do need more than one of this kind of page, but with different kind of actions.

      So the not working solution would be to use facelets:
      [This refactored xhtml page does not work]
      <ui:component>
       <rich:dataTable id="experimentSiteList" var="experimentSite" value="#{list}">
      
       <rich:column>
       <h:outputText size="5" id="year" value="#{list}"></h:outputText>
       </rich:column>
      [...]
       <rich:column>
       <ui:insert name="actions"/>
       </rich:column>
       </rich:dataTable>
      </ui:component>
      

      The calling page:
      [....]
      <ui:decorate template="myTemplate.xhtml">
       <ui:param name="list" value="experimentSiteList"/>
       <ui:define name="actions">
       <s:link id="viewFieldplan" value="Fieldplan"
       action="#{htmlFieldplanBacking.showFieldplan}"
       propagation="begin" target="Fieldplan">
       <f:param name="experimentid"
       value="#{experimentSite.experiment.experimentId}" />
       </s:link>
       </ui:define>
      </ui:decorate>
      [....]
      

      The List of ExperimentSites are rendered as expected. But when clicking on a link the DataModelSelection selectedExperimentSite is null. Why?
      Any insight is greatly welcomed.

      Or, if you have a working solution, please share it with us. Thanks.
      Ciao,
      Carsten