5 Replies Latest reply on Oct 30, 2014 4:02 PM by ricardo.jr

    How to interpret empty strings as null in WildFly

    domme

      I am currently struggling with a migration from JBoss 7.1 to Wildfly.

      I have a simple bean with a string property and a JSF 2.2 form that displays this value and adds an h:inputText component for editing.

      Whenever the user leaves the field open, the setter method is invoked with an empty string as parameter (instead of null).

       

      I set the javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL property to true - without success.

      In JBoss 7.1 it was possible to set the org.apache.el.parser.COERCE_TO_ZERO property to false, but this seems to have no effect in Wildfly.

       

      Any ideas how to convert "empty fields" into null values? Any special converters possible?

       

      Many thanks for the smallest hint...

      Dominik

        • 1. Re: How to interpret empty strings as null in WildFly
          ctomc

          What version of WildFly are you using?

           

          it appears to be mojarra issue https://java.net/jira/browse/JAVASERVERFACES-3071 which was fixed in 2.2.5

          WildFly got 2.2.5 mojarra recently, so can you try if it is any different with newer latest version of wildfly:  WildFly-latest-master [Jenkins]

           

           

          --

          tomaz

          • 2. Re: How to interpret empty strings as null in WildFly
            domme

            I just updated to WildFly 8.0.0.Final-SNAPSHOT including Mojarra 2.2.5 (Mojarra 2.2.5-jbossorg-3 20140128-1641).

            Unfortunately, I cannot see any difference. Still, my setText(String s) method is called with an empty string when I leave the field blank.

             

            The only way I currently see is surrounding the setter method with an interceptor method that transforms an empty string to null. But this requires annotating all string setter methods in my bean and shows a significant change in behaviour from JBoss 7.1 to Wildfly which I did not expect.

             

            Any other ideas?

             

            Many thanks and best regards,

            Dominik

            • 3. Re: How to interpret empty strings as null in WildFly
              ctomc

              do you by any chance have jboss-el.jar in your deployment?

              • 4. Re: How to interpret empty strings as null in WildFly
                domme

                I am afraid not.

                What I see in my WEBINF\lib folder:

                bild.png

                So the el-Library is obviously taken from the provided JBoss pool, isn't it?

                 

                The only thing I changed in the standard WildFly libraries was the adding of the MS SQL driver.

                Is there any sensitive standalone.xml configuration that I could have damaged.

                Do you have an example .war (with source files) that shows a proper handling of null values?

                 

                Many thanks!

                • 5. Re: How to interpret empty strings as null in WildFly
                  ricardo.jr

                  I had the same problem Dominik, using wildfly-8.1.0.Final and jsf mojarra-1.2_15.

                   

                  The Strings arrived empty instead of null.

                   

                  I solved this updating the wildfly EL implementation to javax.el-3.0.1-b05.jar on module org.glassfish.javax.el.

                   

                  I didn't use javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL property in my web.xml