struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Mulligan <david.mulli...@LECAN.ie>
Subject Return an ActionForward with additional query data?
Date Fri, 05 Jul 2002 11:37:34 GMT

> Is it possible to return an ActionForward with additional query
> data/parameters that may arise in the Business logic of the system?
> 
> public class UserPrefAction extends org.apache.struts.action.Action {
> 	public ActionForward perform(......) {
> 		String userId = request.getParameter("userId");
> 		//Do some database stuff here
> 		.....
> 		.....		
> 		//If success, then forward to the User Display page which is
> '/settings/userDisplay.do?userId=xxxxx'
> 		return new ActionForward("success");
> 	}
> }
> 
> 
> If my struts-config.xml
> 
>     <action path="/settings/userPref"
>             type=".......UserPrefAction"
>             scope="request"
>             input="/settings/userPref.vm">
>       <forward name="success" path="/settings/userDisplay.do"/>
>     </action>
> 
> 
> 
> The problem is that I don't know what the userId is until the
> UserPrefAction is preformed.  
> How do/Can I create an ActionForward with query data that may arise in the
> Business logic?
> 
> Would it be logical to extend the struts framework to do use the
> java.util.Message.format and do something like 
> 
> In the XML
> 
>       <forward name="success" path="/settings/userDisplay.do?userId=$1"/>
>  
> In the Java code 
> 
> 	ActionForward forward = new ActionForward("success");
> 	forward.bind(userId);
> 	return forward;
> 
Where $1 would be replaced with the toString() value of the first object 
that is bound to the ActionForward using .bind(Object ojb)


> I know it's possible to save the userId in the HttpSession, but I don't
> really 
> want to take that path. I know as soon as I allow general access to
> HttpSession 
> it will be used to save all types of objects between transactions.
> 
> Thanks in advance.
> Dave.

--
To unsubscribe, e-mail:   <mailto:struts-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-user-help@jakarta.apache.org>


Mime
View raw message