Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts 1.2 mapping.getInputForward()

 
Ritesh Pareek
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot David. Then i'll use Action Forward. But it will be interesting if i done that
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic