6 Replies Latest reply on Aug 28, 2007 3:06 PM by Ilya Doe

    DataModelSelection does not work with PAGE scope

    Ilya Doe Newbie

      Hi, I am outjecting a DataModel on PAGE scope, but DataModelSelection is null(when I click on a h:datatable row). I don't understand why it doesn't work - I am struggling with it for a couple of days now.

      Here is a simple application that does just this:

      @Name("eventLister")
      @Scope(ScopeType.EVENT)
      public class EventListerAction implements Serializable {
      
       @In FacesMessages facesMessages;
      
       @DataModel(value="eventList", scope=ScopeType.PAGE)
       private List<Integer> eventList;
      
       @DataModelSelection
       private Integer selectedEvent;
      
       @Factory("eventList")
       public void initRequestList() {
       eventList = new ArrayList<Integer>();
       eventList.add(1);
       eventList.add(2);
       eventList.add(3);
       }
       public void selectEvent() {
       facesMessages.add("selected event: "+selectedEvent);
       }
      
      }
      


      and the page eventList.xhtml:

      <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <ui:composition xmlns="http://www.w3.org/1999/xhtml"
       xmlns:s="http://jboss.com/products/seam/taglib"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:a="https://ajax4jsf.dev.java.net/ajax"
       template="layout/template.xhtml">
      
      <ui:define name="body">
      
       <h:messages globalOnly="true" styleClass="message"/>
      
       <h:dataTable value="#{eventList}" var="item" >
       <h:column>
       <f:facet name="header">Event</f:facet>
       <s:link action="#{eventLister.selectEvent}" value="#{item}"/>
       </h:column>
       </h:dataTable>
      </ui:define>
      
      </ui:composition>
      


      Please help.