2 Replies Latest reply on Jul 26, 2007 2:10 AM by sammy8306

    [Bug?] noSelectionLabel, <s:selectItems>, equals()

    fmars

      Hi,

      After i added noSelecteionLabel to my <s:selectItems>, i got a NullPointerException in my entity's equals method, because the parameter was null. if noSelectionLabel is selected, the equals method of the entity is called and because "Please select ..." doesn't exists, it sent as null object.

      My suggestion: if noSelectionLabel is selected, then we don't need to call equals() method anymore. Am i right?

        • 1. Re: [Bug?] noSelectionLabel, <s:selectItems>, equals()
          matt.drees

          If I remember right, the equals() method gets called by jsf - it has to make sure that the selected value is one of the options in s:selectItems, so it does a list.contains() call or something, which uses the equals() method. I think you should just fix your equals method so that if it's passed null, you return false.

          • 2. Re: [Bug?] noSelectionLabel, <s:selectItems>, equals()
            sammy8306

             

            "matt.drees" wrote:
            I think you should just fix your equals method so that if it's passed null, you return false.


            Which is exactly what it should do according to the spec anyway: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#equals(java.lang.Object) (last bulletpoint)