The Struts Dynamic Form creation is part of XDoclet 1.2.2.  A snapshot
of 1.2.2 was recently made available on the sf.net site.  If you can't
upgrade to 1.2.2, the old version of the patch providing support for
DynaForms can be found at:

http://www.systemmobile.com/code/xdoclet-apache-module-sm-1_2.zip

The extracted JAR is a replacement for the XDoclet Apache module.  The
important difference between the version on my site and the 1.2.2
version is Validator support - the version on my site doesn't have it.
 I would encourage you to upgrade to XDoclet 1.2.2 snapshot.

Usage:

Creating DynaForm configs in struts-config.xml WITHOUT validation
doesn't require any extra steps in the Ant build file.  Just using the
standard <strutsconfigxml .../> tag will work.  To create the
validation config, you need to also use the
<strutsdynaformvalidationxml/> tag.

Here's an annotated example of creating a DynaForm definition and
Validation code block with XDoclet:

/**
   This class serves to provide an example of the @struts.dynaform
xdoclet tags.  The name, type, and description attributes are used to
create the dynaform config in struts-config.xml.  The validate
attribute is used to tell the validation template to create a form
validation block in the validation.xml file.

   @author Nick Heudecker

   @struts.dynaform name="personForm"
                    type="org.apache.struts..validator.DynaValidatorForm"
                    description="This is an example form."
                    validate="true"
*/
public class Person {


    /**
       @struts.validator type="required"
    */
    public void setId(Long id) {
        this.id = id;
    }

    /**
       This tag demonstrates the shortest possible dynaform-field. 
The field name
       will "id" and the type will be "java.lang.Long".

       @struts.dynaform-field
    */
    public Long getId()  {
        return this.id;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    /**
       The displays the usage of the 'name' and 'type' attributes. 
This is effectively
       the same thing as the above example for the 'id' property.

       @struts.dynaform-field name="firstName"
       type="java.lang.String"
    */
    public String getFirstName()  {
        return this.firstName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    /**
       @struts.dynaform-field name="lastName"
       type="java.lang.String"
    */
    public String getLastName()  {
        return this.lastName;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    /**
       @struts.dynaform-field name="phoneNumber"
       type="java.lang.String"
    */
    public String getPhoneNumber()  {
        return this.phoneNumber;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    /**
       @struts.dynaform-field name="email"
       type="java.lang.String"
    */
    public String getEmail()  {
        return this.email;
    }

    public void setContacts(Contact[] contacts) {
        this.contacts = contacts;
    }

    /**
       This tag will create a config entry with:
       <ul>
       <li>name="contacts"</li>
       <li>type="<em>[package name]</em>.Contact[]"</li>
       <li>size="5"</li>
       </ul>

       @struts.dynaform-field
       size="5"
    */
    public Contact[] getContacts()  {
        return this.contacts;
    }


    private Long id;
    private String firstName;
    private String lastName;
    private String phoneNumber;
    private String email;
    private Contact[] contacts;

}


-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM. 
Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to