DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12297>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12297 Simplified DispatchAction ------- Additional Comments From [EMAIL PROTECTED] 2002-09-05 11:01 ------- Even more flexibility if you need iterated submit:buttons gives this DispatchAction handler: ------------------------------------------------------------------------- public ActionForward execute(ActionMapping mapping,...) throws Exception { // Identify the method name to be dispatched to String name = "unspecified"; java.util.Enumeration enum = request.getParameterNames(); while (enum.hasMoreElements()) { String item = (String)enum.nextElement(); int i=item.indexOf("method="); if(i<0) continue; name=item.substring(i+7); if(i>0) { // Was a nested:submit Button, identify the clicked object String prop=item.substring(0,i-1); Object obj=PropertyUtils.getProperty(form,prop); request.setAttribute("clickedOBJ",obj); // store for later use } break; } return dispatchMethod(mapping,form,request,response,name); } public Object getClickedObject(HttpServletRequest request) { return request.getAttribute("clickedOBJ"); } ---------------------------------------------------------------------------- In the JSP you can have something like this: <nested:form action="/list.do"> <table> <nested:iterate property="list"> <tr> <td><nested:submit property="method=delete" value="Delete this"/></td> <td><nested:submit property="method=insert" value="Empty here"/></td> <td><nested:text property="this/" /></td> </tr> </nested:iterate> </table> <html:submit property="method=save">Save everything</html:submit> <html:submit property="method=append">append empty to list</html:submit> </nested:form> ----------------------------------------------------------------------------- And the Action-Class must implement these methods: public ActionForward save(ActionMapping mapping,...) throws Exception { // ... do something when the Save-Button was clicked } public ActionForward delete(ActionMapping mapping,...) throws Exception { Object obj=getClickedObject(request);// Delete for this obj was clicked } public ActionForward append(ActionMapping mapping,...) throws Exception { //... do something, because the Append-Button was clicked } public ActionForward insert(ActionMapping mapping,...) throws Exception { Object obj=getClickedObject(request); // Insert was clicked for this object } ---------------------------------------------------------------------------- I think this is pretty comfortable. Oliver Henning -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>