4 Replies Latest reply on Apr 1, 2011 7:03 AM by azur666

    listShuttle: Validation Error

    azur666

      Hello!

       

      First of all: I'm sorry for my English!!!!

       

      I have a problem with the component listShuttle I hope someone can solve.

       

      My source code is:

       

      xhtml:

       

      <rich:listShuttle sourceValue="#{fichasExport.availableProperties}"

                       targetValue="#{fichasExport.selectedProperties}"

                   sourceListWidth="150"

                   targetListWidth="150"

                                id="listas"

                               var="properties"

                sourceCaptionLabel="${messages.listAvailableProperties}"

                targetCaptionLabel="${messages.listCurrentlyProperties}"

                  copyControlLabel="${messages.listCopy}"

               copyAllControlLabel="${messages.listCopyAll}"

                removeControlLabel="${messages.listDelete}"

             removeAllControlLabel="${messages.listDeleteAll}"

                   topControlLabel="${messages.listFirst}"

                bottomControlLabel="${messages.listLast}"

                    upControlLabel="${messages.listUp}"

                  downControlLabel="${messages.listDown}">

                      <rich:column>

                          <h:outputText value="#{properties}"></h:outputText>

                      </rich:column>

                       <a4j:support action="#{fichasExport.formPreliminarFile(0)}"

                                      event="onlistchanged"

                                   reRender="preliminarFile, listas"

                                     status="status"

                                      queue="exportCardsQueue"

                         ignoreDupResponses="true"/>

      </rich:listShuttle>

       

       


      Lists are defined as String

       

      privateList<String> availableProperties;

      private List<String> selectedProperties;

       

       

      public voidsetAvailableProperties(List<String> l)

      {

            availableProperties = l;

      }

       

      publicList<String> getAvailableProperties()

      {

            //Se ponen lascabeceras correctas

            this.returnHead();

       

            if (availableProperties == null)

            {

                  availableProperties = new ArrayList<String>();

       

                  availableProperties.add(category1);

                  availableProperties.add(category2);

                  availableProperties.add(user1);

                  availableProperties.add(user2);

            }

            return availableProperties;

      }

       

      public voidsetSelectedProperties(List<String> l)

      {

            selectedProperties = l;

      }

       

      publicList<String> getSelectedProperties()

      {

            if (selectedProperties == null)

            {

                  selectedProperties = new ArrayList<String>();

                  selectedProperties.add(mnemonic);

                  selectedProperties.add(deviceAddress);

                  selectedProperties.add(deviceType);

            }

            formPreliminarFile(0);

            return selectedProperties;

      }

       

       

      mnemonic, deviceAddress, deviceType are constants of type String and category1, category2, user1 and user2 are user-defined of type String.

       

      The problem occurs when setting, for example, Category2=”Cat  2 “(Cat+ two spaces+ 2). When there are two spaces or more in any field I have the following error when I select any data from the list for a second time.

       

       

       

       

      j_id288:listas: Validation Error: Value Cat 2 is not valid

       

       

      After this, the listShutlle is not working well.

       

      Plese, help me

      Thank you very much.

        • 1. Re: listShuttle: Validation Error
          azur666

          Code is not displayed properly. One more try:

           

          private List<String> availableProperties;

                    private List<String> selectedProperties;

           

           

          public void setAvailableProperties(List<String> l)

                    {

                              availableProperties = l;

                    }

           

           

                    public List<String> getAvailableProperties()

                    {

                              //Se ponen las cabeceras correctas

                              this.returnHead();

           

                              if (availableProperties == null)

                              {

                                        availableProperties = new ArrayList<String>();

                         availableProperties.add(category1);

                                        availableProperties.add(category2);

                                        availableProperties.add(user1);

                                        availableProperties.add(user2);

                                        availableProperties.add(ubicacionFichas);

           

                  }

                              return availableProperties;

                    }

           

           

                    public void setSelectedProperties(List<String> l)

                    {

                              selectedProperties = l;

                    }

           

           

                    public List<String> getSelectedProperties()

                    {

                              if (selectedProperties == null)

                              {

                                        selectedProperties = new ArrayList<String>();

                                        selectedProperties.add(mnemonic);

                                        selectedProperties.add(deviceAddress);

                                        selectedProperties.add(deviceType);

                              }

                              formPreliminarFile(0);

                              return selectedProperties;

                    }

          • 2. Re: listShuttle: Validation Error
            ilya_shaikovsky

            Tried the same at richfaces-demo code. (just added spaces to the label items in order to be sure that no problems with JS which collects values to send back).

             

            no errors and application works just as before. So check your converter method.

            • 3. Re: listShuttle: Validation Error
              azur666

                  Thank you very much

                  The problem is somewhere else, i'm still trying to figure out where.Thank you for your help.

              • 4. Re: listShuttle: Validation Error
                azur666

                Hi Ilya!

                 

                I've tried what you said and it worked indeed, but when mixed with my source code

                I have the same problem again.

                 

                I'll put my source  code to see if you can help me, because I do not know what I'm doing wrong.

                 

                 

                 

                @Stateful
                @Scope(CONVERSATION)
                @Name("fichasExport")
                public classFichasExportBeanAction implements FichasExportBean
                {
                      
                      private String mnemonic = "Name";
                      private String deviceAddress = "InternalIpAddress";
                      private String deviceType = "Model";
                      private String accessAddress = "AccessIpAddress";
                      private String SNMPCommunity = "SnmpCommunity";
                      private String userFTPName = "FtpUser";
                      private String userFTPPassword = "FtpKey";
                      private String category1 = "Category1";
                      private String category2 = "Cat  2";
                      private String user1 = "User1";
                      private String user2 = "User2";
                
                
                     private List<String>availableProperties;
                     private List<String>selectedProperties;
                
                
                
                     public voidsetAvailableProperties(List<String> l)
                      {
                            availableProperties = l;
                      }
                 
                      publicList<String> getAvailableProperties()
                      {
                
                            if (availableProperties == null)
                            {
                                  availableProperties = newArrayList<String>();
                                  availableProperties.add(accessAddress);
                                  availableProperties.add(SNMPCommunity);
                                  availableProperties.add(userFTPName);
                                  availableProperties.add(userFTPPassword);
                                  availableProperties.add(category1);
                                  availableProperties.add(category2);
                                  availableProperties.add(user1);
                                  availableProperties.add(user2);
                
                            }
                            return availableProperties;
                      }
                 
                      public void setSelectedProperties(List<String>l)
                      {
                            selectedProperties = l;
                      }
                 
                      publicList<String> getSelectedProperties()
                      {
                            if (selectedProperties == null)
                            {
                                  selectedProperties = newArrayList<String>();
                                  selectedProperties.add(mnemonic);
                                  selectedProperties.add(deviceAddress);
                                  selectedProperties.add(deviceType);
                            }
                            formPreliminarFile(0);
                            return selectedProperties;
                      }
                
                
                     public void formPreliminarFile(longuserGroupForCards)
                      {
                            String aux;
                 
                            FichasListlistaFichas = new FichasList();
                 
                            preliminarFile = "";
                 
                            // Primero buscamos enavailableProperties que no esté ni Mnemonico, @ip o tipoequipo
                            if (availableProperties.contains(mnemonic))
                            {
                                  int index = availableProperties.indexOf(mnemonic);
                                  selectedProperties.add(0, availableProperties.get(index));
                                  availableProperties.remove(index);
                            }
                            if (availableProperties.contains(deviceAddress))
                            {
                                  int index = availableProperties.indexOf(deviceAddress);
                                  selectedProperties.add(1, availableProperties.get(index));
                                  availableProperties.remove(index);
                            }
                            if (availableProperties.contains(deviceType))
                            {
                                  int index = availableProperties.indexOf(deviceType);
                                  selectedProperties.add(2, availableProperties.get(index));
                                  availableProperties.remove(index);
                            }
                
                
                               //Other operations to create the preview of the file
                
                
                
                      }//formPreliminarFile()
                
                
                }
                
                

                 

                 

                xhtml:

                <a4j:region>
                     <rich:modalPanel id="exportMP" height="500" top="50"left="200" zindex="2000"
                                       resizeable="false" width="600">
                          <f:facet name="header">
                               <h:outputText value="${messages.exportHeader}"/>
                          </f:facet>
                          <f:facet name="controls">
                               <h:graphicImage value="/img/close.png" style="cursor:pointer"
                                               onclick="Richfaces.hideModalPanel('exportMP')"/>
                          </f:facet>
                          <h:form>
                               <h:panelGrid columns="1" styleClass="panelModalPanelListShuttle"
                                           columnClasses="columnModalPanelListShuttle">
                                    <rich:listShuttle sourceValue="#{fichasExport.availableProperties}"
                                                      targetValue="#{fichasExport.selectedProperties}"
                                                  sourceListWidth="150"
                                                  targetListWidth="150"
                                                               id="listas"
                                                              var="properties"
                                               sourceCaptionLabel="${messages.listAvailableProperties}"
                                               targetCaptionLabel="${messages.listCurrentlyProperties}"
                                                 copyControlLabel="${messages.listCopy}"
                                              copyAllControlLabel="${messages.listCopyAll}"
                                               removeControlLabel="${messages.listDelete}"
                                            removeAllControlLabel="${messages.listDeleteAll}"
                                                  topControlLabel="${messages.listFirst}"
                                               bottomControlLabel="${messages.listLast}"
                                                   upControlLabel="${messages.listUp}"
                                                 downControlLabel="${messages.listDown}">
                                        <rich:column>
                                            <h:outputText value="#{properties}"></h:outputText>
                                        </rich:column>
                                             <a4j:support action="#{fichasExport.formPreliminarFile(0)}" 
                                                           event="onlistchanged"
                                                        reRender="preliminarFile,listas"
                                                          status="status"
                                                           queue="exportCardsQueue"
                                              ignoreDupResponses="true"/>
                                    </rich:listShuttle>
                
                
                                    <h:panelGrid columns="2"styleClass="panelExportLink">
                                        <h:outputText styleClass="filePreview" value="${messages.filePreview}"/>
                                        <a4j:status id="status" onstart="changePointer(true)"onstop="changePointer(false)">
                                             <f:facet name="start">
                                                   <h:graphicImage value="/img/ajax_process.gif"/>
                                             </f:facet>
                                        </a4j:status>
                                    </h:panelGrid>
                                    <h:inputTextarea value="#{fichasExport.preliminarFile}"
                                                               id="preliminarFile"
                                            styleClass="textAreaExport"
                                                     rows="10"
                                              readonly="true"/>
                                  </h:panelGrid>
                                  <h:panelGrid columns="2" styleClass="column1" columnClasses="columnLeftModalPanel,columnRightModalPanel">
                                        <h:outputText value="#{messages.cardImpExpSeparator}:" styleClass="filePreview"/>
                                        <h:inputText value="#{fichasExport.fieldSeparator}" maxlength="1" size="5"styleClass="modalPanelInput"/>
                                  </h:panelGrid>
                                  <h:panelGrid columns="2" styleClass="panelModalPanel" columnClasses="columnLeftModalPanel,columnRightModalPanel">
                                        <h:commandButton id="donwload"
                                                      value="${messages.download}"
                                                     action="#{fichasExport.exportFile()}"
                                                 styleClass="boton"
                                                onmouseover="this.style.backgroundColor='green';this.style.color='white';this.style.cursor='pointer'"
                                                 onmouseout="this.style.backgroundColor='';this.style.color='';this.style.cursor=''"/>
                                        <a4j:commandButton id="cancel"
                                                        value="${messages.actionDone}"
                                                   styleClass="boton"
                                                      onclick="javascript:Richfaces.hideModalPanel('exportMP')"
                                                  onmouseover="this.style.backgroundColor='green';this.style.color='white';this.style.cursor='pointer'"
                                                   onmouseout="this.style.backgroundColor='';this.style.color='';this.style.cursor=''"/>
                                  </h:panelGrid>
                          </h:form>
                     </rich:modalPanel>
                </a4j:region>
                
                

                 

                The problem is when   reRender="preliminarFile,listas", in particular when reRender==>"listas"

                 


                 

                I also tested with the richfaces-demo code and I still have the same problem:    j_id288:listas: Validation Error: Value Cat 2 is not valid

                 

                 

                 

                richfaces-demo code:

                <a4j:region>
                      <rich:modalPanel id="azuMP" height="500" top="50"left="200" zindex="2000"
                               resizeable="false" width="600">
                
                
                            <f:facet name="header">
                                  <h:outputText value="${messages.exportHeader}"/>
                            </f:facet>
                            <f:facet name="controls">
                                  <h:graphicImage value="/img/close.png" style="cursor:pointer"
                                                onclick="Richfaces.hideModalPanel('azuMP')"/>
                            </f:facet>
                
                            <h:form>
                
                            <rich:toolBar id="toolBar" itemSeparator="line" height="28px">
                            <c:forEach items="#{fichasExport.selectedProperties}" var="item">
                                <h:panelGroup>
                                   <h:outputLink value="#" style="color:#{a4jSkin.generalTextColor};text-decoration:none;" >
                                       <h:outputText value="#{item}"/>
                                   </h:outputLink>
                                </h:panelGroup>
                            </c:forEach>
                            </rich:toolBar>
                                <rich:spacer height="20" />
                
                
                
                                  <h:panelGrid columns="1" styleClass="panelModalPanelListShuttle"
                                         columnClasses="columnModalPanelListShuttle">
                
                                  <rich:listShuttle sourceValue="#{fichasExport.availableProperties}"
                                                    targetValue="#{fichasExport.selectedProperties}" 
                                                            var="items" 
                                                            id ="listas"
                                                sourceListWidth="150"
                                                targetListWidth="150"
                                             sourceCaptionLabel="Available Items"
                                             targetCaptionLabel="Currently Active Items">                    
                                        <rich:column>
                                            <h:outputText value="#{items}"></h:outputText>
                                        </rich:column>
                
                                        <a4j:support action="#{fichasExport.formPreliminarFile(0)}"
                                                      event="onlistchanged"
                                                   reRender="toolBar,listas"
                                                     status="status"
                                                      queue="exportCardsQueue"
                                         ignoreDupResponses="true"/>
                
                                  </rich:listShuttle>
                
                                  </h:panelGrid>
                                  <h:panelGrid columns="2" styleClass="column1" columnClasses="columnLeftModalPanel,columnRightModalPanel">
                                        <h:outputText value="#{messages.cardImpExpSeparator}:" styleClass="filePreview"/>
                                        <h:inputText value="#{fichasExport.fieldSeparator}" maxlength="1" size="5"styleClass="modalPanelInput"/>
                                  </h:panelGrid>
                                  <h:panelGrid columns="2" styleClass="panelModalPanel" columnClasses="columnLeftModalPanel,columnRightModalPanel">
                                        <h:commandButton id="donwload"
                                                           value="${messages.download}"
                                                          action="#{fichasExport.exportFile()}"
                                                    styleClass="boton"
                                                   onmouseover="this.style.backgroundColor='green';this.style.color='white';this.style.cursor='pointer'"
                                                    onmouseout="this.style.backgroundColor='';this.style.color='';this.style.cursor=''"/>
                                        <a4j:commandButton id="cancel"
                                                        value="${messages.actionDone}"
                                                   styleClass="boton"
                                                      onclick="javascript:Richfaces.hideModalPanel('azuMP')"
                                                  onmouseover="this.style.backgroundColor='green';this.style.color='white';this.style.cursor='pointer'"
                                                   onmouseout="this.style.backgroundColor='';this.style.color='';this.style.cursor=''"/>
                                  </h:panelGrid>
                            </h:form>
                      </rich:modalPanel>
                </a4j:region>