rabs
rabs

Reputation: 1827

struts action mapping action input attribute

I am a noob when it comes to Java and Struts ( I feel like .Net boy in Java world ).

What is the input attribute on the action element used for? So in the example below the input is someinput.jsp.

<action path="/somepath" 
        type="SomeAction" 
        name="SomeForm" 
        scope="session"
        input="someinput.jsp">

Upvotes: 22

Views: 51583

Answers (5)

Ken Chan
Ken Chan

Reputation: 90527

If the form bean SomeForm returns validation errors, it will return the page someinput.jsp. To quote the corresponding DTD:

Valid only when "name" is specified. Required if "name" is specified and the input bean returns validation errors. Optional if "name" is specified and the input bean does not return validation errors.

Upvotes: 31

Ahmed MANSOUR
Ahmed MANSOUR

Reputation: 2559

It's for redirection to the jsp in the input attribute. But in your Action controller you need to specify mapping.getInputForward() instead of mapping.findForward().

Struts-config file:

<action input="test.jsp"
        name="testActionForm"
        path="/test" 
        scope="session"      type="package.TestActionController">
</action>

Action Controller:

public ActionForward doMethod(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
        return mapping.getInputForward();
}

Upvotes: 0

Nagappa L M
Nagappa L M

Reputation: 1480

Struts validator plug-in will intecept the created form bean instance from the view and does validation before going to controller and if the data is against the end-user validation rules then errors object is digested in input attribute view which is specified as a value

Upvotes: 0

HJW
HJW

Reputation: 23443

Notwithstanding the above, it is also possible in your action execution (whether it is a single unit of action, or multiple units of action), to specify the result, i.e. SUCCESS, FAILURE, or INPUT.

Upvotes: 1

highlycaffeinated
highlycaffeinated

Reputation: 19867

Struts will forward the user to the page/action specified in the input attribute if validation fails on the form specified in the name attribute.

Upvotes: 4

Related Questions