DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22371>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22371

DynaActionForm is unable to return nulls

           Summary: DynaActionForm is unable to return nulls
           Product: Struts
           Version: 1.1 Final
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Controller
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


The documentation UserGuide/ControllerComponents says about DynaFormBeans:
If you do not supply an initial attribute, numbers will be initialized to 0 
and objects to null. 

The original sourcecode of DynaActionForm looks like this:
  public void initialize(ActionMapping mapping) {
    ...
    FormPropertyConfig props[] = config.findFormPropertyConfigs();
    for (int i = 0; i < props.length; i++) {
      set(props[i].getName(), props[i].initial());
    }
  }
This code initializes the DynaActionForm with values from the struts-
config.xml. If no initial attribute is provided the initial() method of 
FormPropertyConfig creates a new instance of the class specified in the type 
attribute. Therefore an empty String is returned instead of the expected null. 
This behaviour makes it impossible to decide, whether the form did not contain 
a field or the user did not provide a value for the field.
A possible workaround might be the following:
  public void initialize(ActionMapping mapping) {
    ...
    FormPropertyConfig props[] = config.findFormPropertyConfigs();
    for (int i = 0; i < props.length; i++) {
      if(null != props[i].getInitial()) {
        set(props[i].getName(), props[i].initial());
      }
      else {
        set(props[i].getName(), null);
      }
    }
  }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to