2 Replies Latest reply on Dec 4, 2007 6:37 AM by Lars-Erik Lis

    using ajaxSingle and reRender fails due to validation?

    Lars-Erik Lis Newbie

      Hi!

      First time posting to this forum.

      I have a problem that's been puzzelling me for some time.

      I have a form and inside the a4j:form and inside the a4j:form a h:panelGrid. Inside the panelGrid i have some elements that has the attribute required="true". I also have some elements that has a4j:support inside. Such an a4j:support has singleAjax set to true, to avoid all fields beeing submitted, and reRender on an element further down in the panelGrid. The reRender does not work properly, the action is called and the backing bean property is set to the correct value while the reRender doesn't seem to work.
      I guess this has something to do with the validation of the element with required="true" but when I use ajaxSingle="true" that shouldn't be a problem, right?

      So, best would be if I could skip validation when performing the specific action or if the validation error appears but still the wanted action takes place.

      The elements of the form is placed in an panelGrid, could it be a problem that I'm using the h:panelGrid?

      By the way, this form is inside a tab which is inside an outputPanel with layout="none" since this form is dynamically visible.

      My environment:
      RichFaces 3.1.2.GA
      JSF 1.2
      Java 1.5
      Tomcat 6

      Any ideas?

      Thanks in advance!

      Code:

      <a4j:form>
       <h:panelGrid border="0" id="propView" columns="3"
       rendered="#{assets_backing.propertyView}">
       <h:outputText value="#{inv['assets.editasset.id']}:" />
       <h:inputText id="id" value="#{editasset_backing.id}" required="true" />
       <h:message for="id" />
       <h:outputText value="#{inv['assets.editasset.description']}:" />
       <h:inputText id="description" value="#{editasset_backing.description}" />
       <h:message for="description" />
       <a4j:htmlCommandLink action="viewAssetTypes">
       <h:outputText value="#{inv['assets.editasset.type']}:" />
       </a4j:htmlCommandLink>
       <h:panelGroup>
       <a4j:region>
       <h:inputText id="assetTypeSearch" value="#{editasset_backing.type}"
       disabled="#{editasset_backing.disabled}" />
       <rich:suggestionbox id="typeSuggestionBox" width="250" height="120"
       for="assetTypeSearch"
       suggestionAction="#{editasset_backing.typeAutoComplete}"
       var="result" ajaxSingle="true" nothingLabel="No match found"
       fetchValue="#{result.id}">
       <a4j:support event="onselect"
       actionListener="#{editasset_backing.onSelectSuggestion}"
       reRender="assetTypeSearch,typeSuggestionBox" />
       <h:column>
       <h:outputText value="#{result.name}" />
       </h:column>
       </rich:suggestionbox>
       </a4j:region>
       </h:panelGroup>
       <h:message for="assetTypeSearch" />
       <h:outputText value="#{inv['assets.editasset.brand']}:" />
       <h:inputText id="brand" value="#{editasset_backing.brand}" />
       <h:message for="brand" />
       <h:outputText value="#{inv['assets.editasset.sn']}:" />
       <h:inputText id="sn" value="#{editasset_backing.sn}" />
       <h:message for="sn" />
       <h:outputText value="#{inv['assets.editasset.pn']}:" />
       <h:inputText id="pn" value="#{editasset_backing.pn}" />
       <h:message for="pn" />
       <h:outputText value="#{inv['assets.editasset.dateofpurchase']}:" />
       <rich:calendar id="dateofpurchase"
       value="#{editasset_backing.dateOfPurchase}"
       datePattern="#{inv['assets.editasset.datepattern']}"
       enableManualInput="true" popup="true" locale="#{locale.locale}"
       disabled="#{editasset_backing.disabled}" />
       <h:message for="dateofpurchase" />
       <h:outputText value="#{inv['assets.editasset.acqvalue']}:" />
       <h:inputText id="acqvalue" value="#{editasset_backing.acqValue}"
       disabled="#{editasset_backing.disabled}" required="true">
       <a4j:support event="onblur" ajaxSingle="true"
       action="#{editasset_backing.giveValueToDeprAmount}"
       reRender="depramount" />
       </h:inputText>
       <h:message for="acqvalue" />
       <h:outputText value="#{inv['assets.editasset.warrantydate']}:" />
       <rich:calendar id="warrantydate"
       value="#{editasset_backing.warrantyDate}"
       datePattern="#{inv['assets.editasset.datepattern']}"
       enableManualInput="true" popup="true" locale="#{locale.locale}" />
       <h:message for="warrantydate" />
       <h:outputText value="#{inv['assets.editasset.depr']}:" />
       <h:panelGroup>
       <h:selectOneRadio id="depr" value="#{editasset_backing.depr}"
       layout="lineDirection" disabled="#{editasset_backing.disabled}">
       <f:selectItem itemValue="true"
       itemLabel="#{inv['assets.editasset.depryes']}" />
       <f:selectItem itemValue="false"
       itemLabel="#{inv['assets.editasset.deprno']}" />
       <a4j:support event="onchange" ajaxSingle="true"
       action="#{editasset_backing.deprOrNot}"
       reRender="assetPropertyView" />
       </h:selectOneRadio>
       </h:panelGroup>
       <h:message for="depr" />
       <h:outputText value="#{inv['assets.editasset.depramount']}:" />
       <h:inputText id="depramount" value="#{editasset_backing.deprAmount}"
       converter="javax.faces.Double"
       disabled="#{editasset_backing.hideDeprFields || editasset_backing.disabled}" />
       <h:message for="depramount" />
       <h:outputText value="#{inv['assets.editasset.deprstart']}:" />
       <rich:calendar id="deprstart" value="#{editasset_backing.deprStart}"
       datePattern="#{inv['assets.editasset.datepattern']}"
       enableManualInput="true" popup="true" locale="#{locale.locale}"
       disabled="#{editasset_backing.hideDeprFields || editasset_backing.disabled}" />
       <h:message for="deprstart" />
       <h:outputText value="#{inv['assets.editasset.deprlength']}:" />
       <a4j:outputPanel id="deprPeriod">
       <h:panelGroup>
       <h:outputText value="#{inv['assets.editasset.depryears']}: " />
       <h:inputText id="depryears" value="#{editasset_backing.deprYears}"
       style="width: 30px;"
       disabled="#{editasset_backing.hideDeprFields || editasset_backing.disabled}">
       <a4j:support ajaxSingle="true" event="onblur"
       action="#{editasset_backing.calcMonths}" reRender="deprPeriod" />
       </h:inputText>
       <h:outputText value="#{inv['assets.editasset.deprmonths']}: " />
       <h:inputText id="deprmonths" value="#{editasset_backing.deprMonths}"
       style="width: 30px;"
       disabled="#{editasset_backing.hideDeprFields || editasset_backing.disabled}">
       <a4j:support ajaxSingle="true" event="onblur"
       action="#{editasset_backing.calcYears}" reRender="deprPeriod" />
       </h:inputText>
       </h:panelGroup>
       </a4j:outputPanel>
       <h:message for="depryears" />
       <h:outputText />
       <h:panelGroup>
       <a4j:commandButton action="#{editasset_backing.saveAsset}"
       value="#{inv['assets.editasset.save']}"
       reRender="assetPropertyView, assetsTable, content" />
       <a4j:commandButton action="#{assets_backing.disablePropertyView}"
       value="#{inv['assets.editasset.cancel']}"
       reRender="assetPropertyView, content" />
       </h:panelGroup>
       </h:panelGrid>
       <a4j:outputPanel>
       <h:messages />
       </a4j:outputPanel>
      </a4j:form>