0 Replies Latest reply on Feb 13, 2007 11:24 AM by edeprez

    Action not being called

    edeprez

      Hello,
      I'm struggling with the following problem. So maybe someone will be kind enough to enlight me on what I'm doing wrong.
      I've simplified the code for the sake of clarity.

      A list of string is displayed. An id is associated with each string.
      A click on [edit] sends a request to the backing bean with the id as a request parameter. Then the list refreshes and the display changes for the corresponding string.

      The first click on [edit] actually works and triggers the backing bean. Any subsequent click on any commandLink goes to the server, updates the id with request parameter as expected, but doesn't call the action method!

      Here is the html

      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:s="http://jboss.com/products/seam/taglib">
      
      <head>
      </head>
      
      <body>
       <ui:debug hotkey="x" rendered="true"/>
       <form jsfc="h:form" id="testForm">
       <ui:repeat value="#{ctest.addresses}" var="addr">
       <h:panelGroup rendered="#{ctest.editMode and addr.id == ctest.editId}">
       <h:outputText value="-edit- #{addr.value}" />
       <h:commandLink title="reset" action="#{ctest.reset}" value="[reset]" />
       </h:panelGroup>
       <h:panelGroup rendered="#{not (ctest.editMode and addr.id == ctest.editId)}">
       <h:outputText value="#{addr.value} " />
       <h:commandLink title="edit" action="#{ctest.edit}" value="[edit]">
       <f:param name="editId" value="#{addr.id}"/>
       </h:commandLink>
       </h:panelGroup>
       XX editMode: #{ctest.editMode} / addr.id: #{addr.id} / ctest.editId: #{ctest.editId}
       <br/>
       </ui:repeat>
      
       <br/>
       <h:commandLink title="reset" action="#{ctest.reset}" value="[reset]" />
       </form>
      </body>
      </html>
      


      And the backing bean:
      @Name("ctest")
      @Scope(ScopeType.SESSION)
      public class CmpTest {
       private static Logger logger = Logger.getLogger(CmpTest.class);
      
       private ArrayList<Elem> addresses = new ArrayList<Elem>();
      
       @RequestParameter
       private Long editId;
      
       private boolean editMode;
      
       @Create
       public void cmpTest() {
       System.out.println("CREATING " + editUser);
       for (int i = 0; i < 2; i++) {
       addresses.add(new Elem(new Long(i), "ADDR " + i));
       }
      
       }
      
       public List getAddresses() {
       return addresses;
       }
       public boolean getEditMode() {
       return editMode;
       }
       public Long getEditId() {
       return editId;
       }
      
       public void reset() {
       logger.info("RESET!");
       editId = null;
       editMode = false;
       }
       public void edit() {
       logger.info("EDIT!! " + editId);
       editMode = true;
       }
      
      
       public static class Elem {
       Long id;
       String value;
       public Elem(Long id, String value) {
       this.id = id;
       this.value = value;
       }
       public Long getId() {
       return id;
       }
       public void setId(Long id) {
       this.id = id;
       }
       public String getValue() {
       return value;
       }
       public void setValue(String value) {
       this.value = value;
       }
       public String toString() {
       return id + ":" + value;
       }
       }
      }
      


      A click on the [reset] link that is outside of the ui:repeat somehow cleanup stuff so the next click on a link in the list triggers a call of the action method.

      Note that the same behavior occurs if there is not loop and a single object displayed.

      Any clues/explanation on why the action method is not called?

      Thanks!

      Eric.