2 Replies Latest reply on Apr 11, 2011 9:07 AM by ret

    parts of form dont get submitted if rendered by condition

    ret

      hello!

       

      i am facing a strange problem: in a form i would like to display parts of it by a certian condition (some param is set or not).

      if i put this in a panelGroup, the parts of the form seem not to be submitted. This only appears if i put them in a panelGroup, but not adding rendered directly to the input!

      anyone have an explanation?

       

      sample page code:

       

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
      <html xmlns="http://www.w3.org/1999/xhtml"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:f="http://java.sun.com/jsf/core"
            xmlns:ui="http://java.sun.com/jsf/facelets"> 
      
      <h:head>
          <f:metadata>
              <f:viewParam name="userid" value="#{testBean.userid}" converter="javax.faces.Long" />
              <f:viewParam name="action" value="#{testBean.action}" />
          </f:metadata>
      </h:head> 
      <body> 
      
          <h:form>
              id: <h:inputText value="#{testBean.userid}" /><h:outputText value=" set" rendered="#{not empty testBean.userid}"/><br/>
              action: <h:inputText value="#{testBean.action}" /><h:outputText value=" set" rendered="#{not empty testBean.action}"/><br/>
              <h:panelGroup rendered="#{not empty testBean.action}">
                  editmode: <h:inputText value="#{testBean.mode}" />
                  <h:outputText value=" set" rendered="#{not empty testBean.mode}"/>
                  <br/>
              </h:panelGroup>
              <h:commandButton value="senden" action="#{testBean.submit}"/>
          </h:form>
      </body> 
      </html>
      

       

      sample bean code:

       

      import java.io.Serializable;
      
      import javax.enterprise.context.RequestScoped;
      import javax.inject.Named;
      
      import org.apache.commons.logging.Log;
      import org.apache.commons.logging.LogFactory;
      
      
      @RequestScoped
      @Named
      public class TestBean implements Serializable {
      
          private static final long serialVersionUID = -8792513244688669749L;
          private static final transient Log LOG = LogFactory.getLog(TestBean.class);
      
          private String action = "";
          public String getAction() {return action;}
          public void setAction(String action) {LOG.debug("set action="+action);this.action = action;}
      
          private long userid = 0;
          public long getUserid() {return userid;}
          public void setUserid(long userid) {LOG.debug("set userid="+userid);this.userid = userid;}
      
          private String mode = "";
          public String getMode() {return mode;}
          public void setMode(String mode) {LOG.debug("set mode="+mode);this.mode = mode;}
      
          public void submit() {
              LOG.debug("handle submit: action=" + action + ", mode=" + mode + ",userid=" + userid);
          }
      }
      

       

      usage: type in an action, then the mode-input gets displayed. then type in a mode and sumbit. the mode will not get submitted correctly if the input is within the panelGroup!