4 Replies Latest reply on Dec 7, 2009 4:41 AM by Ilya Shaikovsky

    issues persisting h:inputText from a a4j:outputPanel

    marian furdui Newbie

      Hi!

      I have the following issue:
      I can not save the content of the items placed under a4j:outputPanel.
      In the following sample, by default, the description is hidden.
      After the testOptionalDetails section is shown unchecking the selectBooleanCheckbox, the name and description fields are populated, and then pressed the "createdTest" button, only the name value is persisted while the description value is always null in the database.
      What is wrong in the following code? I need to persist also the description.
      Thank you!

      Environment:

      RichFaces: 3.3.2.SR1
      Seam: 2.2.0.GA
      JBoss: 5.1.0.GA


      test.xhtml
      <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:rich="http://richfaces.org/rich"
       xmlns:a="http://richfaces.org/a4j" template="/layout/template.xhtml">
      
       <ui:define name="body">
       <a:form id="testForm" styleClass="edit">
       <rich:panel id="testPanel">
       <f:facet name="header">
       <h:outputText value="#{messages.test}"/>
       </f:facet>
       <h:panelGrid columns="2">
       <h:outputText>#{messages.show_only_name}</h:outputText>
       <h:selectBooleanCheckbox value="#{testAction.showOnlyName}"
       id="showOnlyNameCheck" immediate="true">
       <a:support id="checkboxSupport" event="onclick" ajaxSingle="true"
       reRender="testOptionalDetails"/>
       </h:selectBooleanCheckbox>
       </h:panelGrid>
      
       <rich:panel id="testDetails">
      
       <f:facet name="header">#{messages.test_details}</f:facet>
      
       <s:decorate id="testNameField" template="/layout/edit.xhtml">
       <ui:define name="label">#{messages.test_name}</ui:define>
       <h:inputText id="testName" required="true"
       value="#{testAction.test.name}">
       <a:support event="onblur" reRender="testNameField"
       bypassUpdates="true" ajaxSingle="true"/>
       </h:inputText>
       </s:decorate>
      
       <a:outputPanel id="testOptionalDetails">
       <s:decorate id="testDescriptionField" template="/layout/edit.xhtml"
       rendered="#{not testAction.showOnlyName}">
       <ui:define name="label">#{messages.test_description}</ui:define>
       <h:inputText id="testDescription"
       value="#{testAction.test.description}"/>
       </s:decorate>
       </a:outputPanel>
      
       <div style="clear: both"><span class="required">*</span>
       #{messages.required_fields}</div>
       </rich:panel>
       <s:div>
       <a:commandButton type="button" id="createTestButton"
       value="#{messages.createTest}" action="#{testAction.createTest}"/>
       </s:div>
      
       </rich:panel>
      
       </a:form>
       </ui:define>
      
      </ui:composition>


      Test.java
      @Entity
      @SequenceGenerator(name = "SEQ", sequenceName = "SQ_TEST", initialValue = 500, allocationSize = 1)
      @Table(name = "TEST", schema = "TEST")
      public class Test implements Serializable {
      
       private long id;
       private String name;
       private String description;
      
       @Id
       @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ")
       @Column(name = "ID", unique = true, nullable = false, precision = 38, scale = 0)
       @NotNull
       public long getId() {
       return id;
       }
      
       public void setId(long id) {
       this.id = id;
       }
      
       @Column(name = "NAME", nullable = false)
       @NotNull
       public String getName() {
       return name;
       }
      
       public void setName(String name) {
       this.name = name;
       }
      
       @Column(name = "DESCRIPTION")
       public String getDescription() {
       return description;
       }
      
       public void setDescription(String description) {
       this.description = description;
       }
      }
      


      TestAction.java
      @Name("testAction")
      @Scope(ScopeType.CONVERSATION)
      @AutoCreate
      public class TestAction implements Serializable {
      
       @In
       EntityManager entityManager;
      
       private Test test;
       private boolean showOnlyName = true;
      
       @Transactional
       public void createTest() {
       entityManager.persist(test);
       }
      
       public Test getTest() {
       if (test == null) {
       test = new Test();
       }
       return test;
       }
      
       public void setTest(Test test) {
       this.test = test;
       }
      
       public boolean isShowOnlyName() {
       return showOnlyName;
       }
      
       public void setShowOnlyName(boolean showOnlyName) {
       this.showOnlyName = showOnlyName;
       }
      }