13 Replies Latest reply on Feb 8, 2011 3:00 AM by Carsten Hoehne

    Brain Teaser! JSF is broken!!!

    Bernhard Hurzeler Novice

      Here it goes. Consider the simple form below that collects first and lastname. Except we don't show the lastname input field to start off with. Once switching to Advanced the input field for lastname shows up but does not get submitted when the Go button is clicked.


      Wierd or what? I guess this happens because the lastname input field is not rendered to start off with.


      Does anyone know how to get this working?


      BTW it is JSF1.2, SEAM.2.2.1.Final, JBoss5.1.


      <!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:ui="http://java.sun.com/jsf/facelets"
           xmlns:f="http://java.sun.com/jsf/core"
           xmlns:h="http://java.sun.com/jsf/html">
      
           <h:form>
                <h:selectOneRadio value="#{miniBean.searchType}">
                     <f:selectItem itemLabel="Basic" itemValue="Basic" />
                     <f:selectItem itemLabel="Advanced" itemValue="Advanced" />
                </h:selectOneRadio>
                <h:outputLabel value="Firstname:" for="firstname" />
                <h:inputText id="firstname" value="#{miniBean.firstName}" />
                <h:outputLabel value="Lastname:" for="lastname"
                     rendered="#{miniBean.searchType.equals('Advanced')}" />
                <h:inputText id="lastname" value="#{miniBean.lastName}"
                     rendered="#{miniBean.searchType.equals('Advanced')}" />
      
                <h:commandButton value="Go" view="/searchRules.xhtml" />
           </h:form>
           <h:outputText value="Firstname: #{miniBean.firstName}" />
           <h:outputText value="Lastname: #{miniBean.lastName}" />
      </ui:composition>
      



      with a backing bean


      import org.jboss.seam.annotations.Name;
      
      @Name("miniBean")
      public class MiniBean  {
           
           private String firstName;
           private String lastName;
           private String searchType = "Basic";
      
           public void setSearchType(String searchType) {
                this.searchType = searchType;
           }
      
           public String getSearchType() {
                return searchType;
           }
      
           public void setFirstName(String firstName) {
                this.firstName = firstName;
           }
      
           public String getFirstName() {
                return firstName;
           }
      
           public void setLastName(String lastName) {
                this.lastName = lastName;
           }
      
           public String getLastName() {
                return lastName;
           }
           
      }