Re: [Actionframework-users] Proposals for 0.94
Status: Inactive
Brought to you by:
ptoman
From: Petr T. <Pet...@pi...> - 2002-09-07 13:44:57
|
>> Ah yes... but how can you pass the params arround if you have them >> in a separate namespace? > > via the context. In my context I would like an ActionServlet object I guess this is what I meant: (all) incoming parameters would be put to Context - like those for the action method. Presently, this can be achieved by overriding ActionServlet.handle() method: public Template handle(HttpServletRequest request, HttpServletResponse response, Context context) { for (Enumeration e = request.getParameterNames(); e.hasMoreElements(); ) { String name = (String) e.nextElement(); String[] values = request.getParameterValues(name); context.put(name, values.length == 1? (Object) values[0]: values); } return super.handle(request, response, context); } > which itself contains thinks like $SERVLET, it's own configuration > and the parameters. I should also be able to get this ActionServlet > object from Action Servlet so it is available even in methods that > are not passed the context. 1) you can access servlet instance in your components: public class MyComponent { private YourServlet servlet; public MyComponent(YourServlet servlet) { this.servlet = servlet. } public Template myMethod(String name) { servlet.getTemplate(name); } } 2) you can put $ActionServlet into Ccontext: public Template handle(HttpServletRequest request, HttpServletResponse response, Context context) { context.put("ActionServlet", this); return super.handle(request, response, context); } 3) you can access ActionServlet instance in ActionConfig: public class ActionServletInstantiator implements Instantiator { private ActionServlet servlet; public DefaultInstantiator(ActionServlet servlet) { this.servlet = servlet; } public Object createComponent(Context context, Class componentClass, String componentName) { return servlet; } } <component name="servlet" class="org.actionframework.ActionServlet" instantiator="ActionServletInstantiator " persistence="application"> <action name="/getTemplate" method="getTemplate(String name)"/> </component> Or did you mean something else? :) > http://www.sf.net/projects/visibleresults Good! I will take a look. Petr -- [ http://dione.zcu.cz/~toman40 - Pet...@pi... - ICQ=22957959 ] |