10 Replies Latest reply on Jul 18, 2013 2:31 PM by Brian Leathem

    j_idt56_3Aattrid002_3Av is not defined: rich:validator

    Maxim Kuzmik Newbie

      Hello to All.

       

      When i have the dynamic generation of h:input with rich:validator there is the next JS error: j_idt56_3Aattrid002_3Av is not defined. So as result no JS function generated for dynamic field.

       

      Can any body explain how fix this?

       

       

      <h:form>
         <!-- Форма редактирования -->
         <rich:popupPanel id="essenceEditPanel" modal="true" resizeable="true"
          onmaskclick="#{rich:component('essenceEditPanel')}.hide()"
          width="800" height="400" domElementAttachment="parent">
          <f:facet name="header">
           <h:outputText
            value="Редактирование: #{uiManager.tableTreeManager.editedEssence.title}" />
          </f:facet>
          <f:facet name="controls">
           <a4j:commandLink value="Закрыть"
            onclick="#{rich:component('essenceEditPanel')}.hide(); return false;" />
          </f:facet>
          <rich:tabPanel switchType="client" id="groupTabs"
           style="height:500px; width:700px;"
           rendered="#{not empty uiManager.tableTreeManager.editedEssence}">
           <c:forEach items="#{uiManager.tableTreeManager.groupForDisplay}"
            var="group" varStatus="groupStatus">
            <rich:tab header="#{group.name}">
             <c:forEach items="#{group.attributes}" var="groupAttribute"
              varStatus="groupAttributeStatus">
              <!-- Строка -->
              <!-- a4j:region
                rendered="#{(groupAttribute.type=='string') and (groupAttribute.readonly)}">
                <h:outputText value="#{groupAttribute.name}: "
                 style="font-weight:bold;" />
                <h:outputText
                 value="#{uiManager.tableTreeManager.editedEssence.dataAsMap[groupAttribute.code]}" />
               </a4j:region>
               <a4j:region
                rendered="#{(groupAttribute.type=='string') and (!groupAttribute.readonly)}">
                <h:outputText value="#{groupAttribute.name}:"
                 style="font-weight:bold;" />
                <h:inputText id="attrid#{groupStatus.index}#{groupAttributeStatus.index}1"
                 value="#{uiManager.tableTreeManager.editedEssence.dataAsMap[groupAttribute.code]}"
                 required="true" requiredMessage="asdfasdfafads"/>
                <rich:message for="attrid#{groupStatus.index}#{groupAttributeStatus.index}1" />
               </a4j:region-->
              <!-- Число -->
              <!-- a4j:region
                rendered="#{(groupAttribute.type=='integer') and (groupAttribute.readonly)}">
                <h:outputText value="#{groupAttribute.name}: "
                 style="font-weight:bold;" />
                <h:outputText
                 value="#{uiManager.tableTreeManager.editedEssence.dataAsMap[groupAttribute.code]}" />
                <h:panelGroup />
               </a4j:region>
               <a4j:region
                rendered="#{(groupAttribute.type=='integer') and (!groupAttribute.readonly)}">
                <h:outputText value="#{groupAttribute.name}:"
                 style="font-weight:bold;" />
                <h:inputText id="attrid#{groupStatus.index}#{groupAttributeStatus.index}2"
                 value="#{uiManager.tableTreeManager.editedEssence.dataAsMap[groupAttribute.code]}"
                 required="true" requiredMessage="asdfasdfafads">
                 <f:validateLongRange />
                </h:inputText>
                <rich:message id="#{groupAttribute.code}Message2"
                 for="attrid#{groupStatus.index}#{groupAttributeStatus.index}2" />
               </a4j:region-->
              <h:outputText value="#{groupAttribute.name}:"
               style="font-weight:bold;" />
              <h:inputText
               id="attrid#{groupStatus.index}#{groupAttributeStatus.index}2"
               value="#{uiManager.tableTreeManager.editedEssence.dataAsMap[groupAttribute.code]}"
               required="true" requiredMessage="asdfasdfafads"
               validatorMessage="Должно быть целочисленное число"
               converterMessage="Должно быть целочисленное число">
               <f:validateRequired />
               <rich:validator />
              </h:inputText>
              <rich:message
               for="attrid#{groupStatus.index}#{groupAttributeStatus.index}2" />
             </c:forEach>
            </rich:tab>
           </c:forEach>
          </rich:tabPanel>
          <a4j:commandButton value="Сохранить"
           action="#{uiManager.tableTreeManager.storeEssence}"
           render="dataTable" execute="essenceEditPanel"
           oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('essenceEditPanel')}.hide();}" />
          <a4j:commandButton value="Отмена" execute="@this"
           onclick="#{rich:component('essenceEditPanel')}.hide(); return false;" />
         </rich:popupPanel>
        </h:form>
      
      
        • 1. Re: j_idt56_3Aattrid002_3Av is not defined: rich:validator
          Ilya Shaikovsky Master

          using the

          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

          <ui:composition xmlns="http://www.w3.org/1999/xhtml"

                    xmlns:h="http://java.sun.com/jsf/html"

                    xmlns:f="http://java.sun.com/jsf/core"

                    xmlns:ui="http://java.sun.com/jsf/facelets"

                    xmlns:a4j="http://richfaces.org/a4j"

                    xmlns:rich="http://richfaces.org/rich"

                          xmlns:c="http://java.sun.com/jsp/jstl/core">

                    <h:form>

                              <c:forEach items="#{capitalsBean.capitals}" var="cap">

                                        <h:inputText value="#{cap.name}">

                                                  <f:validateRequired/>

                                                  <rich:validator/>

                                        </h:inputText>

                              </c:forEach>

                              <rich:messages></rich:messages>

                    </h:form>

          </ui:composition>

          I'm getting:

          val_and_c_for.png

          • 2. Re: j_idt56_3Aattrid002_3Av is not defined: rich:validator
            eoin81 Newbie

            was there ever a solution to this?

             

            i see the same thing.

             

            It happens in fileds (that have <rich:validator> attached) that are dynamically displayed based on a previous event:

             

            Like displaying a <a4j:panel> area with <h:input...> tags after a user clicks a booleanSelect.

             

            The fileds that were "hidden" when the page loads dont seem to have their javascript functions ready/loaded when the user tabs out of the input text.

            • 3. Re: j_idt56_3Aattrid002_3Av is not defined: rich:validator
              Ilya Shaikovsky Master

              provide more info(code)... as you could see from my comment -  works for me.

              • 4. Re: j_idt56_3Aattrid002_3Av is not defined: rich:validator
                eoin81 Newbie

                Hi llya,

                 

                Below is my scenario: (my problem is when the check box is selected, the panel is rendered, which is fine. But when validation is attempted as the user tabs out of a field (JSR bean validation) I get Javascript errors $field_id is not defined)

                 

                <ui:composition 
                    xmlns="http://www.w3.org/1999/xhtml" 
                    xmlns:c="http://java.sun.com/jsp/jstl/core" 
                    xmlns:f="http://java.sun.com/jsf/core"
                    xmlns:h="http://java.sun.com/jsf/html" 
                    xmlns:sf="http://www.springframework.org/tags/faces"
                    xmlns:s="http://myfaces.apache.org/sandbox"
                    xmlns:ui="http://java.sun.com/jsf/facelets"
                    xmlns:a4j="http://richfaces.org/a4j"
                    xmlns:rich="http://richfaces.org/rich"
                    template="/WEB-INF/layouts/layout.xhtml">
                    
                    <h:form id="myform">
                    
                                        <h:selectBooleanCheckbox id="selectid" 
                                                                        immediate="true"  
                                                                                 value="#{form.selected}">                                                      
                                                <a4j:ajax event="click" render="testoutput" />
                                        </h:selectBooleanCheckbox>
                                        
                            <a4j:outputPanel id="testoutput">
                                
                                <rich:panel rendered="#{form.selected}">
                            
                                            <rich:message styleClass="errorText" for="addressLine1"/>                        
                                            <h:inputText id="addressLine1" size="30" maxlength="35"  
                                                         value="#{form.addressLine1}">                                
                                                <rich:validator />    
                                            </h:inputText>                        
                    
                                            <rich:message styleClass="errorText" for="addressLine2"/>                        
                                            <h:inputText id="addressLine2"
                                                         value="#{form.addressLine2}">                                
                                                <rich:validator />    
                                            </h:inputText>
                                        
                                </rich:panel>
                            
                            </a4j:outputPanel>
                                
                    </h:form>    
                        
                </ui:define>
                </ui:composition>
                
                
                
                • 5. Re: j_idt56_3Aattrid002_3Av is not defined: rich:validator
                  Ilya Shaikovsky Master

                  please try to remove conditional rendering just to test

                  • 6. Re: j_idt56_3Aattrid002_3Av is not defined: rich:validator
                    eoin81 Newbie

                    hi llya, all works fine without the conditional rendering

                     

                    would you know why the Javascript isnt available for those components when they are surrounded with conditional tags/outputPanels?

                    • 7. Re: j_idt56_3Aattrid002_3Av is not defined: rich:validator
                      eoin81 Newbie

                      Hi llya, is this an issue or is there a workaround?

                      • 8. Re: j_idt56_3Aattrid002_3Av is not defined: rich:validator
                        Antonio Senatore Newbie

                        All.

                         

                        I have the exact same problem here, same as Eoin81.

                        Have you found a workaround? Or a fix?

                         

                        Thanks

                        • 9. Re: j_idt56_3Aattrid002_3Av is not defined: rich:validator
                          Antonis Katsikadamos Newbie

                          So!!! Conditional rendering breaks the rich:validator functionality... Did you find any workaround / solution to this problem ?

                          It seems that the corrensponding js functions do not load when the region that contains the rich:validator is not rendered during the first page load...

                           

                           

                          Any help, workaround ??

                           

                          Thanks in advanced!!!

                          • 10. Re: j_idt56_3Aattrid002_3Av is not defined: rich:validator
                            Brian Leathem Master

                            You can use the resource optimization techinoque to preload all resources on a page.  See this blog post for more details:

                            http://lukas.fryc.eu/blog/2012/02/optimizing-resource-loading-with.html