8 Replies Latest reply on Mar 24, 2009 10:38 AM by mthaxmiller

    suggestionbox triggering validation before a4j:support

    mthaxmiller

      I have a problem in that I need to call a4j:support from a suggestionbox
      but the validation is triggered before the a4j:support request can be
      called. I have tried the various suggestions in other posts
      (ajaxSingle="true" and renderRegionOnly="false" in the a4j:region) but
      no luck. Richfaces is 3.2.2. This is in a modal panel.

      Here is the code:

      <a4j:region>
       <tr>
       <td align="left">
       <h:selectOneMenu name="workSkillDescCombo"
       id="workSkillCodeCombo" label="Work Skill Description"
       value="#{MilitaryBean.occupation.workSkill.value}"
       required="true" requiredMessage="Work Skill Code: Value is required.">
       <f:selectItems value="#{CodeCacheBean.getASICodes$['ONETCODE'][true]}"/>
       <a4j:support ajaxSingle="true" event="onchange"
       actionListener="#{MilitaryBean.getIndustry}" reRender="militaryIndustry"/>
       </h:selectOneMenu>
       <h:inputText onkeypress="return event.keyCode!=13"
       id="workSkillSearch" maxlength="15" size="15" styleClass="stdTextUp"
       value="#{MilitaryBean.workSkillSearch}"/>
       <rich:suggestionbox height="120" width="400" usingSuggestObjects="true"
       suggestionAction="#{CodeCacheBean.getSearchedCodes}"
       var="ws" for="workSkillSearch" fetchValue="#{ws.code.value}"
       id="suggestion2" tokens=","
       minChars="3" nothingLabel="No Matches" zindex="5000" ajaxSingle="true">
       <f:param name="codeName" value="ONETCODE"/>
       <h:column>
       <h:outputText value="#{ws.code.value}" styleClass="stdLabelNoPad"/>
       </h:column>
       <h:column>
       <h:outputText value="#{ws.descriptionPreSearchValue}"
       styleClass="stdLabelNoPad"/><h:outputText value="#{ws.searchValue}"
       styleClass="stdLabelRedNoPad"/><h:outputText
       value="#{ws.descriptionPostSearchValue}" styleClass="stdLabelNoPad"/>
       </h:column>
       <a4j:support event="onselect" ajajaxSingle="true"
       actionListener="#{MilitaryBean.getIndustry}"
       reRender="workSkillCodeCombo, militaryIndustry, workSkillSearch"/>
       </rich:suggestionbox>
       </td>
       </tr>
       <tr>
       <td align="left">
       <h:selectOneMenu id="militaryIndustry" label="Military Industry"
       disabled="true" value="#{MilitaryBean.occupation.industry.value}">
       <f:selectItems value="${MilitaryBean.industry}"/>
       </h:selectOneMenu>
       </td>
       </tr>
      </a4j:region>
      


        • 1. Re: suggestionbox triggering validation before a4j:support
          nbelaevski

          Hello,

          <a4j:support event="onselect" ajajaxSingle="true"
          Have you copied this just from the page source?

          • 2. Re: suggestionbox triggering validation before a4j:support
            mthaxmiller

            Sorry, that's a typo caused by me formatting the code for easier reading on the forum. It is spelled correctly in the code. I can post the code again if it would be helpful.

            • 3. Re: suggestionbox triggering validation before a4j:support
              nbelaevski

              I think yes. Can you please add the piece defining input on which the validation error occurs?

              • 4. Re: suggestionbox triggering validation before a4j:support
                mthaxmiller

                The validation occurs on the selectOneMenu because required=true.
                Here is the code:

                <a4j:region>
                 <tr>
                 <td align="right">
                 <h:graphicImage value="../images/asterisk.gif"></h:graphicImage>
                 <h:outputLabel id="militaryWorkSkillLabel" for="workSkillCodeCombo" value=" Work Skill: " styleClass="stdLabel"/>
                 </td>
                 <td align="left">
                
                 <h:selectOneMenu name="workSkillDescCombo" id="workSkillCodeCombo" label="Work Skill Description" required="true" requiredMessage="Work Skill: Value is required." converter="selectonemenublank" value="#{MilitaryBean.occupation.workSkill.value}">
                 <f:selectItems value="#{CodeCacheBean.getASICodes$['ONETCODE'][true]}"/>
                 <a4j:support event="onchange" actionListener="#{MilitaryBean.getIndustry}" reRender="militaryIndustry"/>
                 </h:selectOneMenu>
                 <rich:spacer width="4px"></rich:spacer>
                 <h:inputText onkeypress="return event.keyCode!=13" id="workSkillSearch" maxlength="15" size="15" styleClass="stdTextUp" onfocus="clearText()" onblur="clearText()" value="#{MilitaryBean.workSkillSearch}"/>
                 <rich:suggestionbox height="120" width="400" usingSuggestObjects="true"
                 suggestionAction="#{CodeCacheBean.getSearchedCodes}" var="ws" for="workSkillSearch" fetchValue="#{ws.code.value}" id="suggestion2" tokens=","
                 minChars="3" nothingLabel="No Matches" zindex="5000">
                 <f:param name="codeName" value="ONETCODE"/>
                 <h:column>
                 <h:outputText value="#{ws.code.value}" styleClass="stdLabelNoPad"/>
                 </h:column>
                 <h:column>
                 <h:outputText value="#{ws.descriptionPreSearchValue}" styleClass="stdLabelNoPad"/><h:outputText value="#{ws.searchValue}" styleClass="stdLabelRedNoPad"/><h:outputText value="#{ws.descriptionPostSearchValue}" styleClass="stdLabelNoPad"/>
                 </h:column>
                 <a4j:support event="onselect" ajajaxSingle="true" actionListener="#{MilitaryBean.getIndustry}" reRender="workSkillCodeCombo, militaryIndustry"/>
                 </rich:suggestionbox>
                 </td>
                 </tr>
                 <tr>
                 <td align="right">
                 <h:outputLabel id="militaryIndustryLabel" for="militaryIndustry" value="Industry: " styleClass="stdLabel"/>
                 </td>
                 <td align="left">
                 <h:selectOneMenu id="militaryIndustry" label="Military Industry" disabled="true" value="#{MilitaryBean.occupation.industry.value}">
                 <f:selectItems value="${MilitaryBean.industry}"/>
                 </h:selectOneMenu>
                 </td>
                 </tr>
                 </a4j:region>
                


                • 5. Re: suggestionbox triggering validation before a4j:support
                  ilya_shaikovsky

                  will it help if you wrap the input with suggestion to a4j:region?

                  which version you using?

                  • 6. Re: suggestionbox triggering validation before a4j:support
                    mthaxmiller

                    Are you saying to also wrap the suggestionbox in an a4j:region? Currently the entire area of this page that is relevant to this suggestionbox is wrapped in an a4j:region.
                    Richfaces version is 3.2.2

                    • 7. Re: suggestionbox triggering validation before a4j:support
                      ilya_shaikovsky

                      I told just about input and suggestion related to this input.

                      • 8. Re: suggestionbox triggering validation before a4j:support
                        mthaxmiller

                        Works! Don't know why I didn't think of that before. Thanks Ilya.