You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2003/01/14 15:16:53 UTC

DO NOT REPLY [Bug 16063] New: - do ActionForms have to be true JavaBeans?

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=16063>.
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=16063

do ActionForms have to be true JavaBeans?

           Summary: do ActionForms have to be true JavaBeans?
           Product: Struts
           Version: Unknown
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Documentation
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: edgar@blue-moose.net


ActionForms are added to a servlet context (session or request) as beans.  What 
this means is for certain functionality to be available your ActionForms will 
have to follow a few simple rules.

The first and only requirement is that they the implement 
java.io.Serializable.  This applies for all complex objects included in your 
ActionForm as well.  Certain containers validate that beans follow this rule, 
others don't.  If the container pages your bean and it is not serializable the 
errors will appear at random.

If you want the fields of the form to be available they have to supply getter 
and setter methods of the form:

    private <type> fieldName;
    public <type> getFieldName() {
        return fieldName;
    }
    public void setFieldName(<type> newvalue) {
        fieldName = newvalue;
    }

Other fields which don't have to be manipulated don't need to follow this 
convention.

There are other rules to follow if you want other features of the Java Beans 
specification to be exposed.  These include indexed attributes and mapped 
attributes.  They are covered in detail in other areas of the documentation:

    http://jakarta.apache.org/struts/faqs/indexedprops.html

FYI this is the Java Beans specification

    http://java.sun.com/products/javabeans/docs/beans.101.pdf

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>