10 Replies Latest reply on Sep 9, 2011 11:57 AM by Benniu Ji

    4.1.0 M1 rich:orderingList Validation error

    Benniu Ji Newbie

      In the test.xhml:

       

      <rich:messages />

                  <rich:orderingList id="list" value="#{planManager.values}" columnVar="item">

                  <rich:column>

                                            <f:facet name="header">Id</f:facet>

              <h:outputText value="#{item.title}" />

              </rich:column>

         <rich:column>

                                                     <f:facet name="header">title</f:facet>

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

         </rich:column>

                  </rich:orderingList>

                  <br/>

      <a4j:commandButton value="submit" action="#{planManager.submit()}" />

       

      PlanManager:

          public PlanManager(){

                          values.add(new EntityBean("Option 1", "1"));

                          values.add(new EntityBean("Option 2", "2"));

                          values.add(new EntityBean("Option 3", "3"));

                          values.add(new EntityBean("Option 4", "4"));

                          values.add(new EntityBean("Option 5", "5"));

       

                }

       

                public List<EntityBean> getValues(){return values;}

       

                public void setValues(List<EntityBean> values){this.values=values;}

       

                public String submit(){

                          System.out.println("call submit");

                          for (int i=0; i<values.size(); i++){

                                    System.out.println(values.get(i).getTitle());

                          }

       

        return "failure";

                }

       

      When I click submit button on the page, it alaways show up a error msg:  "j_idt30:list: Validation Error: Value is not valid"

       

      What's wrong?

        • 1. Re: 4.1.0 M1 rich:orderingList Validation error
          Benniu Ji Newbie

          I would really appericiate if someone could show me a sample on how to use the new ordering list in 4.1.0 M1

          • 2. Re: 4.1.0 M1 rich:orderingList Validation error
            iabughosh Master

            Hi Ji,

            ex:

            <rich:orderingList value="#{user.values}">

                                      <f:selectItem itemLabel="Item 1"

                                      itemValue="1"/>

                                      <f:selectItem itemLabel="Item 2"

                                                                                        itemValue="2"/>

            </rich:orderingList>

             

            where user.values is a List<String> ,

             

            regards.

            • 3. Re: 4.1.0 M1 rich:orderingList Validation error
              Brian Leathem Master

              Hi Benniu Ji,

               

              With the orderingList, you need to provide a converter if your list objects are not simple Strings.. 

              • 4. Re: 4.1.0 M1 rich:orderingList Validation error
                Benniu Ji Newbie

                Yes, I did use a converter but it didn't work.

                Actually, I'm doing almost the same as it is in the sample in github.

                https://github.com/richfaces/dev-examples/blob/develop/input-demo/src/main/webapp/examples/orderingList.xhtml

                • 5. Re: 4.1.0 M1 rich:orderingList Validation error
                  Benniu Ji Newbie

                  Hi, Ibrahim

                   

                  You solution works, but the problem is when I rerender the ordering list after changing the order, it will show both the values and the selectItems lables

                  Like:

                       2

                       Item 2

                       1

                       Item 1

                       3

                       Item 3

                       4

                       Item 4

                  • 6. Re: 4.1.0 M1 rich:orderingList Validation error
                    iabughosh Master

                    please post your .xhtml & bean code.

                    • 7. Re: 4.1.0 M1 rich:orderingList Validation error
                      Ilya Shaikovsky Master

                      if you seeing "j_idt30:list: Validation Error: Value is not valid" - that definitelly means that the value still can't be succesfully converted.

                       

                      In order to do clean test of your data and converter correctness and confirm that it's not (or it is) a component issue - change ordering list to any JSF selectMany* components and try to submit some selection using the same model.

                      • 8. Re: 4.1.0 M1 rich:orderingList Validation error
                        Benniu Ji Newbie

                        Thanks. Finally, I made it work.

                         

                        <rich:orderingList id="tc_orderList" value="#{executionSetManager.sortedExecutionCases}" columnVar="item" maxListHeight="500" listWidth="700">

                          <f:selectItems value="#{executionSetManager.executionCases}" />

                            <f:converter converterId="ExecutionCaseConverter" />

                            <rich:column>

                                <f:facet name="header">Id</f:facet>

                                <h:outputText value="#{item.exId}" />

                                </rich:column>

                           <rich:column>

                               <f:facet name="header">Test Case Name</f:facet>

                               <h:outputText value="#{item.tcName}" />

                           </rich:column>

                           <rich:column>

                               <f:facet name="header">Test Script Name</f:facet>

                               <h:outputText value="#{item.tsName}" rendered="#{item.tsName != null}"/>

                               <h:outputText style="color: Red" value="Script Not Found" rendered="#{item.tsName eq null}"/>

                           </rich:column>

                          </rich:orderingList>

                         

                         

                        The strange thing is that, if the value of tcName contains a comma, the getAsObject method will got the wrong string.

                         

                        For example, if the name is "test case 1, no test data", the getAsObject will be called twice. First one is for string 'test case 1' and seconde one is for 'no test data'. I can't understand why it will devided into 2 string if there is a comma in the string. The expect result is that getAsOjbec will receive the string 'test case 1, no test data'.

                        • 9. Re: 4.1.0 M1 rich:orderingList Validation error
                          Brian Leathem Master

                          Glad to hear you got it working!  What you noticed w.r.t. commas in the value, is becuase the list of selected values is submitted from the browser to! the server as a comma seperated list.  This comma separated list is then exploded and the converter run on each piece.

                           

                          At the time of writing the component, we figured no one would use a comma in the value portion of a converter - I guess you proved us wrong.  If you feel we should use a different character, or allow for the character used to be configured, please file a jira requesting that.

                          • 10. Re: 4.1.0 M1 rich:orderingList Validation error
                            Benniu Ji Newbie

                            Ok, I understand why that happened. Thanks for you info, Brian!

                            From my side, I have a walk around. I replaced commna with another symble and change it back after it was converted. I have to do this because I can't gerentee that the user will not use a comma in the string.

                             

                            Rather than hanlding it myself, I think this could be done in your component. I think the better solution is to encode the selected values and decode it before convert. After the encode, no comma or other special character should exist in the values.