*
The moose likes Struts and the fly likes Struts 1.2 mapping.getInputForward() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 1.2 mapping.getInputForward()" Watch "Struts 1.2 mapping.getInputForward()" New topic
Author

Struts 1.2 mapping.getInputForward()

Ritesh Pareek
Ranch Hand

Joined: Nov 04, 2008
Posts: 50
Hi,

I am using Dispatch action. My Problem is regarding multiple inputs.

in Struts-config action is ::

<action
input=""
name="MemberFormBean"
parameter="action"
path="/member"
validate="true"
scope="session"
type="com.monsoon.manglish.controller.MemberController">

<forward name="memberMainPage" path="/pages/members/memberMainPage.jsp" />
<forward name="membersListPage" path="/pages/members/membersListPage.jsp"/>
<forward name="memberViewPage" path="/pages/members/memberViewPage.jsp"/>
<forward name="myProfileViewPage" path="/pages/members/myProfileViewPage.jsp"/>
<forward name="loginPage" path="/login.do?action=loginPage"/>

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


and in Form bean is all getter setter with
private String validationKey;

public String getValidationKey(ActionMapping mapping, HttpServletRequest request) {
sop("validation key is in memberform ..... " + validationKey + "....... super " + super.getValidationKey(mapping, request));
return (validationKey == null) ? super.getValidationKey(mapping, request) : validationKey;
}


void setValidationKey(String validationKey) {
this.validationKey = validationKey;
}

and finally in action


MemberFormBean memberForm = (MemberFormBean) form;
memberForm.setValidationKey("/login.do?action=loginPage");
sop("VALIDATION KEY IS ...... " + memberForm.getValidationKey(mapping, request));
sop("Will forword us to ...... " + mapping.getInputForward()); // Getting "" Here
sop("Will forword us to ...... " + mapping.getInputForward().getPath()); // Getting NULL Here
sop("Will forword us to ...... " + mapping.getInputForward().getName());
sop("Will forword us to ...... " + mapping.getInputForward().getModule());
ActionMessages errors = memberForm.validate1(mapping, request);

if (errors != null && !errors.isEmpty()) {
saveErrors(request, errors);
return mapping.getInputForward();
}

How can i set inputForward???
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You have an empty string for your "input" action mapping attribute, so there's no input. The "input" attribute defines the input forward.
Ritesh Pareek
Ranch Hand

Joined: Nov 04, 2008
Posts: 50
Thanks a lot David Newton.

But i left it empty because i am hitting "member.do" from multple jsp's e.g. addMember.jsp or editMember.jsp ..... and if there is any error or exception in my action then i need to send it back to that particular jsp from where it come from.

So, we can summraize it as... we can getInputForward() in our action. But can we set input at runtime??


Thanks a lot for reply.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You're welcome, Willy Willy.

I'd probably use a DispatchAction (or LookupDispatchAction, whatever it's called) rather than try to work around the single-input limitation.
Ritesh Pareek
Ranch Hand

Joined: Nov 04, 2008
Posts: 50
Thanks again David.

I am also using Dispatch Action,

n Struts-config action is ::

<action
input="" ///// Here how can we define multiple Inputs?
name="MemberFormBean"
parameter="action"
path="/member"
validate="true"
scope="session"
type="com.monsoon.manglish.controller.MemberController">

That is, if i am adding a member member and got some validation error then it will sent it back to whatever i have defined in "<action input=""". But i need to get it back on that particular Jsp (add or edit jsp). so i need to define multiple input
>
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

No, you need to return the appropriate ActionForward depending on where you came from, based on which method you're executing. Using getInputForward() is merely a convenience: you don't *have* to use it if it doesn't suit your needs.
Ritesh Pareek
Ranch Hand

Joined: Nov 04, 2008
Posts: 50
Thanks a lot David. Then i'll use Action Forward. But it will be interesting if i done that
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts 1.2 mapping.getInputForward()
 
Similar Threads
forward action
Problem with Struts validator
problem in getting data from request
Struts - got a blank page
Configuration problem with first struts example