8 Replies Latest reply on Feb 1, 2008 5:29 PM by Joseph Nusairat

    Ordering List Validation Error

    Justin Cobb Newbie

      I am trying to use an ordering list component. I can get it to add fine but I am getting a validation error whenever I try to perform an onclick event. I assume I am just missing an override in my class that handles the orderinglist. I am not sure if this is like the listshuttle where you need to override those couple other functions. The one override I do have in there is for the toString() method.

      The validation is returning "Validation Error: Value null is not valid", but I know the value is valid since it is showing the correct names in the ordering list when I add them into it.

        • 1. Re: Ordering List Validation Error
          Ilya Shaikovsky Master

          check demosite sample and use documentation. You should define your converter and in your item object should provide equals and hashCode methods implemented.

          • 2. Re: Ordering List Validation Error
            Justin Cobb Newbie

            I have used the demo site, and I do not see a bean example on the website. I have used the equals and hashcode overrides similar to how I used them in the list shuttle. Is the bean code for the example posted somewhere?

            • 3. Re: Ordering List Validation Error
              Ilya Shaikovsky Master

              in our wiki - there is SVN url to our demosite sample.

              • 4. Re: Ordering List Validation Error
                alexander winizki Newbie

                The documentation says nothing about the converter except that it should be a converter. Neither does it say that the elements of the value collections should implement equals and hashCode. Not a single word about what the converter should convert and why. It is absolutely inacceptable if a developer has to perform reverse engineering (looking into source code that has to be searched for somewhere) in order to find out how to use a component. The documentation should be fixed as soon as possible.

                • 5. Re: Ordering List Validation Error
                  Felix Khazin Newbie

                  I'm having the same exact problem, have you solved it?

                  • 6. Re: Ordering List Validation Error
                    Nick Belaevski Master

                    Could you please provide converter & page code?

                    • 7. Re: Ordering List Validation Error
                      Joseph Nusairat Newbie


                      soo has this been resolved what exactly the converter does? how its defined?

                      • 8. Re: Ordering List Validation Error
                        Joseph Nusairat Newbie


                        OK ... so being that my JSF skills are not very good. I have looked at the problem more.

                        The problem is NOT In the RichFaces team lack of doco, its our understanding of JSF (including mine). The converter is a standard JSF component and if you google it you will see you can customize one, etc.

                        However, so ok ... i got mine working with submission, i was mainly using orderingList because i wanted horizontal scroll bars.

                        So heres the JSF -

                        <rich:orderingList id="selectPrioritySource"
                         value="#{substanceSetRun.prioritySourceList}"
                         fastOrderControlsVisible="false" orderControlsVisible="false"
                         selection="#{substanceSetRun.prioritySources}"
                         var="item" listWidth="200" rows="5" styleClass="listBox"
                         converter="nameValueConverter">
                        <rich:column>
                         <h:outputText value="#{item.name}" />
                        </rich:column>
                        /rich:orderingList>
                        


                        So what do we have here. Ok i have a selection defined called prioritySources, the object it references is a Collection of Strings (Collection).

                        Then i have for the value to populate the list, a prioritysourcelist. This is an object of List .. which is a simple bean of ... name value objects.

                        So then you see i also have a converter de fined "nameValueConverter". Creating this is soo simple you are gonna smack yourself. (i smacked myself .... wait that sounds bad)

                        Anyway create the object that implements converter and define two methods ... here's mine

                        public class NameValueConverter implements Converter {
                        
                         public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
                         return arg2 == null ? new NameValueDTO("") : new NameValueDTO(arg2);
                         }
                        
                         public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
                         return arg2 == null ? "" : ((NameValueDTO)arg2).getValue();
                         }
                        
                        }
                        


                        Basically i am using the value as the key to move things around on. And in your faces-config ... define the converter

                        <converter>
                         <converter-id>nameValueConverter</converter-id>
                         <converter-class>c.web.NameValueConverter</converter-class>
                         </converter>


                        Thats it.

                        NOW my problem still exists that its passing into my String array on my bean (in this case a SB since i am suing seam) A name and not a value.

                        I am not sure on how to resolve that, i think one had to do it with the converter, not 100% sure but their are some state based interfaces for it.

                        here are some doco on the converter

                        http://download-east.oracle.com/docs/html/B25947_01/web_val006.htm