Struts subtasks

struts

The Struts subtasks include tasks to generate Forms from entity beans, and to generate struts-config.xml from Form and Action classes.

<strutsform />

The <strutsform /> subtask is a subtask of the <ejbdoclet /> task. It processes all entity beans and generates struts form beans.

Form beans include getter and setter methods and also convenient bulk data setting methods (in form: <DataObjectType> getData() to return data object with only form fields set, and <DataObjectType> getData(<DataObjectType>) to merge form fields with actual EJB data)

Several forms can be defined for a single EJB, with different sets of properties. validate method of form beans shall be overriden with something more useful than default struts validation method.

PK fields are included by default, but can be excluded if necessary.

Parameters

Attribute Description Required
destdir Base destination directory for the generated source code. No, default is destdir parameter of ejbdoclet task
pattern The pattern by which the form bean classes are named. {0} designates the EJB name, {1} form bean name No, default is {0}{1}Form.

<strutsconfigxml />

The <strutsconfigxml /> subtask is a subtask of the <webdoclet /> task. It parses the source directories for Action and Form classes that contain @struts: tags and generates a struts-config.xml based on that data. It also relies on merging for additional global config options.

Parameters

Attribute Description Required
xmlencoding The encoding of the struts-config.xml file. No, default is "UTF-8"
destdir Destination directory for the struts-config file. No, default is destdir parameter of webdoclet task
mergedir Merge directory where strutsconfig looks for files to be merged with generated files. No, required, if the merge feature used
validateXml Validates the generated xml file according to the DTD file contained inside xdoclet.jar. No, default is false

Merge Points

Merge File Name Description Required
struts-forms.xml The file where additional forms are defined. No
global-forwards.xml The file where the global forwards are defined. No
struts-actions.xml The file where additional actions are defined. No

Class level Tags

@struts:action

Defines the action class and its attributes.

Parameter Usage
[name]: String The name of the action. Must be unique within the bounds of the Struts application.
[path]: String The path that the action will match.
[scope]: "request" | "session" | "application" Define the scope of the action. Defaults to request.
[input]: String The path to the input for the Action.
[validate]: "true" | "false" The validation flag for the action. Defaults to true.
[parameter]: String The optional parameter for the action.

@struts:action-forward

Defines local forwards for a Struts action class.

Parameter Usage
[name]: String The name of the forward
[path]: String The path of the forward.

@struts:form

Defines a form bean and its attributes.

Parameter Usage Required
[name]: String Define a unique name for the form. Yes.
[extends]: String Define which class the generated form must extend. No.
[implements]: String Define which class the generated form must implement. No.
[include-pk]: "true" | "false" Whether to include pk field in form. Default is true. If set to false, individual pk fields can still be included. No.
[include-all]: "true" | "false" Whether to include all persistent fields in form. Default is false. No.

Method level Tags

@struts:form-field

Parameter Usage Required
[form-name]: String to include this property in specified form. Yes.