[Webwork-user] WebWorkVelocityServlet views
Brought to you by:
baldree,
rickardoberg
From: G.L. G. <ga...@gr...> - 2002-07-10 04:20:01
|
Still trying to figure this one out. Below is my original action where I would compare the values of 'view' and return a view mapping pending the value of view ... public class Products extends ActionSupport implements ParameterAware { private Map params; ... public void setParameters(Map map) { this.params = map; } public String doExecute() throws Exception { if (view.equals("myview.a")) { return "selectA.success"; } else if (view.equals("myview.b")) { return "selectB.success"; } return "select.error"; } Then I needed to capture the parameter from within the action (coming from the velocity *.vm template) so I changed the class I extended from and now have ... public class Products extends WebWorkVelocityServlet implements ParameterAware { private Map params; ... public void setParameters(Map map) { this.params = map; } public Template handleRequest(Context context) { HttpServletRequest request = (HttpServletRequest) context.get(REQUEST); HttpServletResponse response = (HttpServletResponse) context.get(RESPONSE); } } As I understand it, I now have the handleRequest() method above so that I can get a query string parameter from the servlet now and write something like this in the template page ... --- *.vm file #if ( $reqParser.getParameter("myParam").equals("this_string") ) ## do something #end The problem is that whereas I had the execute() method from the first ex. (extended from ActionSupport) to compare views and return a different view pending on the value of view, I don't know how to do this (return views pending a query string parameter in the servlet request) w/ the WebWorkVelocityServlet. So what I have is a query string coming from the template to the action, and then I'll return a view mapping w/ query string parameters back to the browser. Any help much appreciated. |