Null Property Access and conversion errors

Samuel Goldberg <[email protected]> Wed, 20 Dec 2006 02:00:14 CST
Newsgroups gmane.comp.java.open-symphony.webwork
Message-ID <21197162.1166602376189.JavaMail.os-j2ee@opensymphony01.managed.contegix.com>
Using Webwork 2.2.4

The problem:

If there is an Integer field on an Action (may be a Double too, or suchlike) and the user enters a value which cannot be converted to an Integer - say, 'a', then this form field

[code]<input type='text' name='foo' value='$!foo' />[/code]
displays 'a' (along with a conversion error) which is the desired effect.

This field, however:

[code]<input type='text' name='bean.foo' value='$!bean.foo' />[/code]
does not display anything.

If the user enters a correct value for Bean.foo, then the value is set all right and is displayed.

Here is an example:

[code]
public class TestAction extends ActionSupport {
    
    private Integer foo;
    private Bean bean;
    
    public static final class Bean {
    
        public Bean () {  }       
        private Integer foo;
        public Integer getFoo() { return foo; }
        public void setFoo(Integer foo) { this.foo = foo; }
    
    }
    
    public Integer getFoo() { return foo; }   
    public void setFoo(Integer foo) { this.foo = foo; }
    public Bean getBean() { return moo; }
    public void setBean(Bean bean) { this.bean = bean; }
 
}

[/code]
The TestAction-Validation.xml looks like

[code]
    <field name="bean.foo">
       <field-validator type="conversion" short-circuit="true">
          <param name="repopulateField">true</param>
          <message>Not a number</message>
       </field-validator>
        <field-validator type="required" short-circuit="true">
            <message>Foo is required</message>
        </field-validator>
        <!--  More irrelevant stuff -->
    </field>
    <field name="foo">
       <field-validator type="conversion" short-circuit="true">
          <param name="repopulateField">true</param>
          <message>Not a number</message>
       </field-validator>
        <field-validator type="required" short-circuit="true">
            <message>Foo is required</message>
        </field-validator>
        <!--  More irrelevant stuff -->
    </field>
[/code]
What could it be? Cannot believe I am the only one with this problem - but haven't found anything similar here in the forum. I must be missing something.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=54457&messageID=109063#109063

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]