11 Replies Latest reply on May 9, 2008 10:33 AM by Joe Greene

    a4j:support events not triggered after validation errors on

    Mahesh M Newbie

      Hello,
      Can someone please tell me how to fix the following issue.

      Thanks,
      Mahesh

      I have a form with 3 components

      1) h:inputText for Amount. It is a required field.
      2) rich:calendar for effective date.
      3) rich:calendar for expiry date.

      I am using a4j:support "oninputchange" on Effective date (rich:calendar) component to set the expiration date (rich:calendar) value based on some logic in my backing bean.

      My problem is lets say the user doesn't enter the amount and hits done, the form throws validation errors for required fields.

      After the validation error, if the user enter the right value for amount and tries to change the effective date, the oninputchange event dosen't get fired.

      oninputchange event works perfectly fine if there are no validation errors.

      Below is the code.


      
       <h:panelGroup id="details">
      <h:form>
      
       <h:inputText id="amount" value="#{backingBean.amount}" required="true" />
      
       <rich:calendar id="effdate" enableManualInput="true" datePattern="MM/dd/yyyy" value="#{backingBean.effectiveDate}" >
       <a4j:support event="oninputchange" action="#{backingBean.handleDateChange}" reRender="details" />
      
       </rich:calendar>
      
       <rich:calendar id="expdate" enableManualInput="true" datePattern="MM/dd/yyyy" value="#{backingBean.expiryDate}" >
      
       </rich:calendar>
      
       <a4j:commandButton value="Done" action="#{backingBean.done}" />
      
      </h:form>
      
      </h:panelGroup>
      
      
      


        • 1. Re: a4j:support events not triggered after validation errors
          Sergey Smirnov Master

          add ajaxSingle="true" as an attribute to a4j:support

          • 2. Re: a4j:support events not triggered after validation errors
            Mahesh M Newbie

            Hello Sergey,
            Thanks for the response. But adding ajaxSingle=true did not solve the issue.

            Actually it creates a refresh issue when there are no validation errors. Upon adding ajaxSingle=true on a4j:support of effective date, the handleDateChange method gets fired but it does not refresh the expiration date with new value.

            Any other tips to make this work are greatly appreciated.

            Thanks.

            • 3. Re: a4j:support events not triggered after validation errors
              Sergey Smirnov Master

              what if you add process="amount"

              P.S. I hope we are speaking about RichFaces 3.2.0

              • 4. Re: a4j:support events not triggered after validation errors
                Mahesh M Newbie

                Hello Sergey,
                Sorry, my fault I should have mentioned before that I am using Rich faces 3.1.4.GA version.

                Can you please clarify where should I add process="amount" ?

                Thanks.

                • 5. Re: a4j:support events not triggered after validation errors
                  Ilya Shaikovsky Master

                  process - is a new ajax attribute added to all core a4j:* tags and ajax based components. It's added after 3.2.0 release and used when you need process some additional components except just current region or ajaxSingle component.

                  If you can't switch to 3.2.0 - please try to use a4j:region around your calendar (id="effdate) instead of ajaxSingle usage. If the result will be the same?

                  • 6. Re: a4j:support events not triggered after validation errors
                    Mahesh M Newbie

                    Hi,
                    Adding a4j:region around effective date component dosen't still trigger the handleDateChange event after validation errors.

                    Also adding a4j:region clears the value of amount when form is submitted.

                    Just for info, I am using the components on a rich:ModalPanel. I hope nothing different has to be done in case of using modalpanels.

                    Thanks.

                    • 7. Re: a4j:support events not triggered after validation errors
                      brett hu Newbie

                      Did you solve this problem? I got the same problem. If you got the answer, could you please let me know?
                      Currently I use richfaces 3.2.0GA and I also test (process="mytext" ajaxSingle="true") in a4j:support. Unfortunately there is no luck. Anyone can give me some suggestions? Thanks in advance.

                      • 9. Re: a4j:support events not triggered after validation errors
                        bin yorku Newbie

                        Thank you for your reply. Here is my code (btw I use seam framework):
                        (1) the page:

                        <h:form>
                        
                         <div class="actionbarTop">
                        
                         <h:commandButton value="Save &amp; List" styleClass="button"
                         action="#{probillRegularCartage.save}" />
                         <s:button view="/probill/list.xhtml" value="Cancel" styleClass="button" propagation="end" />
                        
                         </div>
                        
                        <s:validateAll>
                        
                         <h:panelGrid id="consigneePanel" columns="2"
                         columnClasses="formLabel, formInput">
                        
                         <h:outputText>
                         <b>Consignee</b>
                         </h:outputText>
                         <h:panelGroup>
                         <a4j:region id="consigneeAjaxRegion">
                         <h:inputText id="consigneeName" value="#{probill.nameConsignee}"
                         size="50" required="true">
                         <rich:suggestionbox id="consigneeSuggestionId" for="consigneeName"
                         tokens=",[" rules="none"
                         suggestionAction="#{probillAjaxAction.retrieveSugConsignees}"
                         var="consignee" fetchValue="#{consignee.name}" height="250"
                         width="400" minChars="3" requestDelay="750">
                         <a4j:support event="onselect"
                         action="#{probillAjaxAction.selectConsignee(consignee.id)}"
                         reRender="consigneePanel" />
                         <h:column>
                         <h:outputText value="#{consignee.name}" />
                         </h:column>
                         <h:column>
                         <h:outputText value="#{consignee.address.address1}" />
                         <h:outputText value="&#160;&#160;" />
                         <h:outputText value="#{consignee.address.address2}" />
                         <h:outputText value="&#160;&#160;" />
                         <h:outputText value="#{consignee.address.address3}" />
                         </h:column>
                         <h:column>
                         <h:outputText value="#{consignee.address.city}" />
                         <h:outputText value="&#160;" />
                         <h:outputText
                         value="#{consignee.address.provincialState.shortDescription}" />
                         </h:column>
                         </rich:suggestionbox>
                         </h:inputText>
                         </a4j:region>
                         <a4j:status for="consigneeAjaxRegion">
                         <f:facet name="start">
                         <h:graphicImage value="/images/spinner.gif" />
                         </f:facet>
                         </a4j:status>
                         <h:message for="consigneeName" styleClass="error" />
                         </h:panelGroup>
                        
                        <h:outputText value="Address" />
                         <h:panelGroup>
                         <h:inputText id="consigneeAddress1" size="50" maxlength="100"
                         value="#{probill.consigneeAddress1}">
                         <s:validate />
                         </h:inputText>
                         <h:message for="consigneeAddress1" styleClass="error" />
                         </h:panelGroup>
                        </h:panelGrid>
                         </s:validateAll>
                        
                        .....
                        
                        


                        (2) my ajaxAction class :
                        @Name("probillAjaxAction")
                        @Scope(ScopeType.CONVERSATION)
                        public class ProbillAjaxAction implements Serializable {
                        
                         .......
                        
                         public List<Entity> retrieveSugConsignees(Object hint) {
                         probill.setEntityConsignee(null);
                         String consignHint = (String) hint;
                         log.debug("The param is: " + consignHint);
                         List<Entity> consignees = companyDAO.findCompany("%" + consignHint + "%");
                         return consignees;
                         }
                        
                         public void selectConsignee(Long selectedConsigneeID) throws Exception{
                         log.debug("The consign is: " + selectedConsigneeID);
                         Entity entity = entityManager.find(Entity.class, selectedConsigneeID);
                         log.debug("entity: " + entity);
                         if (entity != null) {
                         probill.setEntityConsignee(entity);
                         probill.setNameConsignee(entity.getName());
                         probill.setAddressConsignee(entity.getAddress());
                         probill.setConsigneeAddress1(entity.getAddress().getAddress1());
                         probill.setConsigneeAddress2(entity.getAddress().getAddress2());
                         probill.setConsigneeAddress3(entity.getAddress().getAddress3());
                         probill.setConsigneeCity(entity.getAddress().getCity());
                         probill.setConsigneeProvStateType(entity.getAddress().getProvincialState());
                         probill.setConsigneeMailCode(entity.getAddress().getMailCode());
                        
                         log.debug("probill.ConsignAddress1: " + probill.getConsigneeAddress1());
                        
                         setHtmlInputTextValue("consigneeAddress1", probill.getConsigneeAddress1());
                         }else{
                         throw new Exception("Can not find the entity with id: " + selectedConsigneeID);
                         }
                         }


                        If I select one consignee from rich:suggestionbox, the field "consigneeAddress1" will be filled by "a4j:support". And "consigneeAddress1" will changed if I change my selection. Everything is good so far.
                        But if I click my save button, the validation "require=true" will run and error message will be display. After error occures, "a4j:support" dose not work anymore although "rich:suggestionbox" still works well. In another word, I still can select one value from suggestionbox, but consigneeAddress1 is not filled by a4j:support anymore.
                        Based on log information, a4j:support already send request to my ajax action class and probill.consigneeAddress1 already is updated in action class. But by using firebug, The value probill.consigneeAddress1 is not return which is empty.
                        Could you let me know how I can fix it. Thanks!

                        • 10. Re: a4j:support events not triggered after validation errors
                          Joe Greene Novice

                          Hi -
                          I think your problem is the same as mine, but with a slightly different symptom. Here's a link to my recent post:

                          http://www.jboss.com/index.html?module=bb&op=viewtopic&t=134497

                          Basically, if I try to save a user without a value for a required field, I correctly get a validation error. If I try to load another user after that using my suggestion box, the only data that gets updated on the form with the new user's data is the required data that I removed from the previous user. I now have a "mixture" of data on the form for user1 and user2. Wierd!

                          Maybe a JSF issue? Maybe SEAM? I still haven't received a response yet to my original post - maybe I rambled too much.