3 Replies Latest reply on Jan 11, 2009 3:16 PM by Tony Herstell

    Needs ALL fields on page to be valid before it will alter th

    Tony Herstell Master

      I have a form with a number of fields.

      In one field I am allowing the user to enter SeamText.

      To help the user see what Seam Text will display in the final reckoning I offer a preview button and clicking this button shows the results in a preview panel just below the button (makes sense I hope).

      After 3.5 Hours I managed to find why it was randomly working and not working... (the clue was it generally always worked on the Update screen but not on the Create screen if I went through the fields in order!)

      IF there ANY other fields (for the backing entity) that are invalid; then pressing the button does not UPDATE the preview area (it could even be just the required fields in the form as they happen to co-incide with @NotNull).

      The Form backs onto an Entity with Hibernate/JPA/Seam annotations... I am using J5S3E (Java 5, Seam, EJB3).

      Setting immediate to true in the button does not pass through the data in the field you are trying to display...

      Any suggestions...

      Code...

      given:

      <!-- ***********
       Entries Description
       *********** -->
       <s:decorate id="entity_event_entry_description_decorator" template="../editOfSeamTextArea.xhtml">
       <ui:define name="label">
       <h:outputText value="#{messages.entity_event_entry_description_label}" />
       </ui:define>
       <ui:define name="header">
       <div>
       <center>
       <rich:simpleTogglePanel switchType="client" label="Formatting Instructions" opened="false">
       <ui:include src="/pages/seamTextHelpText/helptext.xhtml" />
       </rich:simpleTogglePanel>
       </center>
       </div>
       </ui:define>
       <ui:define name="content">
       <div>
       <a4j:outputPanel id="entriesTextInputPanel">
       <span class="edit_template_content_area #{invalid?'errorblock':'noerrorblock'}">
       <s:validateAll>
       <h:inputTextarea id="entity_event_entry_description" value="#{event.entryDescription}"
       title="#{messages.entity_event_entry_description_tooltip}" cols="70" rows="10">
       <s:validateFormattedText/>
       </h:inputTextarea>
       </s:validateAll>
       </span>
       </a4j:outputPanel>
       </div>
       </ui:define>
      
       <ui:define name="error_messages">
       </ui:define>
      
       <ui:define name="preview">
       <div>
       <span>
       <a4j:commandButton styleClass="general_form_button" id="reviewEntriesText" action="#{eventsManagementController.previewText}"
       value="#{messages.general_button_preview}" type="submit" onclick="this.disabled=true"
       oncomplete="this.disabled=false" limitToList="true" reRender="entriesTextInputPanel, entriesTextPreviewPanel, entriesTextInputErrorPanel">
       </a4j:commandButton>
       </span>
       <span>
       <a4j:outputPanel id="entriesTextInputErrorPanel">
       <rich:message id="reviewEntriesTextErrorMessages" errorClass="error" warnClass="warn"
       infoClass="error" for="entity_event_entry_description"/>
       </a4j:outputPanel>
       </span>
       </div>
       <div>
       <a4j:outputPanel id="entriesTextPreviewPanel">
       <s:fragment rendered="#{(event.entryDescription ne null) and (event.entryDescription ne '')}">
       <center>
       <div class="preview_panel">
       <s:formattedText value="#{event.entryDescription}"/>
       </div>
       </center>
       </s:fragment>
       </a4j:outputPanel>
       </div>
       </ui:define>
      
       <ui:define name="hint">
       <s:formattedText value="#{messages.entity_event_entry_description_hint}" />
       </ui:define>
       </s:decorate>
      


      using decorator template:


      <ui:composition 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">
      
       <table class="edit_template_area">
       <tr>
       <td class="edit_template_label_area" >
       <s:label styleClass="#{invalid?'error':''}">
       <ui:insert name="label" />
       </s:label>
       </td>
       <td class="edit_template_tag_area">
       <span >
       <h:outputText styleClass="mandatory" value="#{messages.general_mandatory_tag}" rendered="#{required}"/>
       </span>
       </td>
       <td class="edit_template_field_area">
       <table>
       <tr>
       <td>
       <ui:insert name="header" />
      
       </td>
       </tr>
       <tr>
       <td>
       <ui:insert name="content" />
       </td>
       </tr>
       <tr>
       <td>
       <span class="edit_template_error_area">
       <center>
       <ui:insert name="error_messages" >
       <s:message styleClass="edit_template_error error" />
       </ui:insert>
       </center>
       </span>
       </td>
       </tr>
       <tr>
       <td>
       <ui:insert name="preview" />
       </td>
       </tr>
       <tr>
       <td>
       <span class="edit_template_hint_area">
       <ui:insert name="hint"/>
       </span>
       </td>
       </tr>
       </table>
       </td>
       </tr>
       </table>
      
      </ui:composition>