• No results found

Action Mappings page

In document Web Application Developer s Guide (Page 171-175)

You use the Action Mapping page to create the <action-mappings> element of struts-config.xml. The <action-mappings> element configures the mappings from submitted request paths to the corresponding Action classes that should be used to process these requests.

A sample entry in struts-config.xml looks like this: <action-mappings>

<action name="submitForm" type="myproject.SubmitAction" input= "/submit.jsp" scope="request" path="/submit">

<forward name="success" path="/submit.jsp" /> <forward name="failure" path="/submit.jsp" /> </action>

</action-mappings>

Table 13.6 Global Forwards page context menu

Node Menu command Description

Global Forwards node

Add Forward Displays the Forward attribute

page, where you add a

<global-forward> element. Global Forwards

element

Add Forward Adds a new <global-forward>

element. Global Forwards

element

A c t i o n M a p p i n g s p a g e

To display the Action Mappings overview page of the Struts Config Editor, choose the Action Mappings node in the structure pane. The Action Mappings overview page displays existing <action> elements. You use this page to add and remove elements.

• To add a new <action> element, click the Add button. A new element is added with a default name of /action.

• To remove an element, select it and choose Remove.

• To edit the newly added element or an existing one, select it and choose Edit.

Figure 13.7 Action Mapping overview page

You use the Action attribute page to configure the attributes of an element. The attribute page looks like this:

E d i t i n g t h e s t r u t s - c o n f i g . x m l f i l e 13-13

A c t i o n M a p p i n g s p a g e The following table explains the attributes on the page:

Table 13.7 Action attributes

Field Name

Attribute

Name Description

Implementation Class

type Fully qualified Java class name of the Action class

to be used to process requests for this mapping. If this field is selected, the Forward and Include fields are not available.

Forward forward Context-relative path of the servlet or JSP

resource that will process this request, instead of

instantiating and calling the Action class specified

in the Implementation Class field. If this field is selected, the Implementation Class and Include fields are not available.

Include include Context-relative path of the servlet or JSP

resource that will process this request, instead of

instantiating and calling the Action class specified

in the Implementation Class field. If this field is selected, the Implementation Class and Forward fields are not available.

Path path The context-relative path of the submitted

request, starting with a forward slash (“/”), and without the filename extension if extension mapping is used.

Configuration Bean

className Fully qualified Java class name of the

ActionMapping implementation class to use.

Defaults to the value configured as the mapping

initialization parameter to the Struts controller servlet.

Parameter parameter General purpose configuration parameter that

can be used to pass extra information to the

Action selected by this mapping. Handle Unknown

Requests

unknown Set to true if this action should be configured as the default for this application, to handle all requests not handled by another action. Only one action can be defined as a default within a single application.

Form Bean (Form Bean tab)

name Name of the form bean, if any, that is associated

with this action. Prefix

(Form Bean tab)

prefix Prefix used to match request parameter names to form bean property names, if any. Optional if the Form Bean field is used, otherwise, not available. Scope

(Form Bean tab)

scope Identifier of the scope (request or session) within which the form bean is accessed, if any. Optional if the Form Bean field is used, otherwise, not available.

A c t i o n M a p p i n g s p a g e

Input

(Form Bean tab)

input Context-relative path of the input form to which control should be returned if a validation error is encountered. Required if the Form Bean field is used and the input bean returns validation errors. Optional if the Form Bean field is used and the input bean does not return validation errors. Not allowed if the Form Bean field is not used.

Attribute (Form Bean tab)

attribute Name of the request-scope or session-scope attribute under which this form bean is accessed, if it is other than the name entered in the Form Bean field. Optional if the Form Bean field is used, otherwise, not available.

Suffix

(Form Bean tab)

suffix Suffix used to match request parameter names to form bean property names, if any. Optional if the Form Bean field is used, otherwise, not available. Validate

(Form Bean tab)

validate Set to true if the validate() method of the form bean should be called prior to calling this action,

or set to false if you do not want validation

performed. Property (Set

Properties tab)

property Specifies the name and value of an additional JavaBeans configuration property whose setter method will be called by the object that represents the surrounding element. This is especially useful when an extended implementation class (with additional

properties) is configured on the <global-forwards>

or <action-mappings> elements. Value (Set

Properties tab)

value String representation of the value to which this property will be set, after suitable type conversion.

Path (Forwards tab)

path The context-relative path of the mapped

resource. Logically overrides a global forward of

the same name. Name (Forwards

tab)

name The unique identifier for this forward. Logically

overrides a global forward of the same name.

Large Icon (Description tab)

large-icon Specifies the location, relative to the Struts configuration file, of a resource containing a large (32x32 pixel) icon image, suitable for use in GUI tools.

Small Icon (Description tab)

small-icon Specifies the location, relative to the Struts configuration file, of a resource containing a small (16x16 pixel) icon image, suitable for use in GUI tools.

Table 13.7 Action attributes (continued)

Field Name

Attribute

E d i t i n g t h e s t r u t s - c o n f i g . x m l f i l e 13-15

A c t i o n M a p p i n g s p a g e

In document Web Application Developer s Guide (Page 171-175)