10 Replies Latest reply on Feb 16, 2006 8:08 PM by Udo Krass

    Commandbutton doesn't work inside dataTable

    janbols Newbie

      When using a SFSB with SESSION scope, do you have to use a @Begin annotation?

      I have the following jsp page:

      <%@ page language="java" %>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
      <p>Page 1 </p>
      <f:view>
      <h:form>
       <h:messages />
       <h:commandButton action="#{sfsbSession.fillTable}" value="Fill table"/>
       <h:dataTable var="row" value="#{myTable}">
       <h:column>
       <h:commandButton value="Go to page 2" action="#{sfsbSession.goToPage2}"/>
       </h:column>
       <h:column>
       <h:outputText value="#{row}"/>
       </h:column>
       </h:dataTable>
       <h:commandButton value="Go to page 2" action="#{sfsbSession.goToPage2}"/>
      </h:form>
      </f:view>
      
      and the following SFSB with session scope:
      @Stateful
      @Name("sfsbSession")
      @Intercept(InterceptionType.ALWAYS)
      @Interceptor(SeamInterceptor.class)
      @Scope(ScopeType.SESSION)
      public class SFSBSessionAction implements SFSBSession, Serializable {
      
       private static final long serialVersionUID = -8231478684900323568L;
      
       @DataModel private List<String> myTable;
      
       //@Begin
       public String fillTable() {
       myTable = new ArrayList<String>();
       myTable.add("item1");
       myTable.add("item2");
      
       return "page1";
       }
      
       public String goToPage2() {return "page2";}
      
       @Destroy @Remove
       public void destroy() { }
      }
      

      When I click on the commandButton below the dataTable, the goToPage2 method in my SFSB is invoked and I get page2. However, when I click on the commandButton inside the dataTable, nothing is invoked and page1 is returned with an empty dataTable.

      When I uncomment the @Begin annotation at the fillTabel method, everything works fine though.

      Is this the normal behaviour? Why?

      I'm using myfaces (nightly build version 12-13-2005), jBoss 4.0.3SP1 and seam beta1.