struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anuj Agrawal <agrawala...@yahoo.com>
Subject RE: query parameters
Date Mon, 09 Dec 2002 16:00:59 GMT
Marcus -

Well, i certainly hope you are not wrong, cos this was the path i was going
down.  :)  The only thing is when i use
http://your.url.com/do/viewrecord?id=someIdToData (or
http://your.url.com/viewrecord.do?id=someIdToData), it will then forward to
http://your.url.com/view.jsp with the appropriate data filled in.  So when
the user looks at the URL, they will cut-and-paste
http://your.url.com/view.jsp which will most likely display a blank form (at
a later time).  So i still haven't solved the original problem.

Anuj.

> -----Original Message-----
> From: Marcus Andersson [mailto:marcus.andersson@active-tv.com]
>
> Example to help clarify:
>
> You should create an action mapping that looks something like:
>
> <action type="yourpack.ShowRecordAction" path="/viewrecord">
>    <forward name="success" path="/view.jsp" />
>    <forward name="fail" path="/error.jsp"/>
> </action>
>
> ShowRecordAction looks something like:
> package yourpack.ShowRecordAction;
>
> //imports.....
>
> public class ShowRecordAction extends org.apache.struts.action.Action {
>     public ActionForward execute(ActionMapping mapping,
>                                  ActionForm form,
>                                  HttpServletRequest request,
>                                  HttpServletResponse response)
>             throws IOException, ServletException  {
> 	  // Use the request parameter (for example id) that you provide to
>         // do the lookup and put the record (or whatever object that you
>         // want to print) in some scope
> 	  request.setAttribute("record", yourRecordObject);
> 	  // You can also find out the next and previous record ids here and
> put them
> 	  // in some scope to
> 	  // if all is ok you return mapping.findForward("success")
> 	  // if something is not ok you can return
> mapping.findForward("fail");
> 	  return yourActionForward;
>     }
> }
>
> You are then free to use the record object in your jsp according to your
> needs, just retrieve it from whatever scope you put it in.
>
> To invoke the action you do:
> http://your.url.com/do/viewrecord?id=someIdToData
> (or http://your.url.com/viewrecord.do?id=someIdToData depending on the
> mapping in web.xml)
> Which in turns forwards to the jsp for display.
>
> This should work but I'm just a novice in Struts so...
>
> If I'm wrong I hope somebody corrects me


--
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