All my web flows use HTML forms, and the events which move from one state to another are generated by HTML submit buttons, like this:
<input name="_eventId_eventname" type="submit" value="label">
That works well, but sometimes I have tables of sub-elements within a form, and I would like to have an "edit" button for each row of the table. The state transitions should not distinguish between "edit" buttons on different rows, but the target action should have some way to find out what the row number is. I solved this by subclassing HttpServletRequestEvent and HttpServletFlowExecutionManager, but I wonder if anyone knows of a neater way to do this without messing with these classes ? So the forms contain submit buttons a bit like this:
<input name="_eventId_edit_${row}" type="submit" value="Edit">
And the code looks like this:
Code:public class HttpServletRequestEvent2 extends HttpServletRequestEvent { public HttpServletRequestEvent2(HttpServletRequest request, HttpServletResponse response) { super(request,response); } protected Object searchForParameter(String logicalName, String delimiter) { String s = (String)super.searchForParameter(logicalName,delimiter); if (s==null) return null; String ss[] = s.split(delimiter); Map m = new HashMap(); for( int i=1; i<ss.length; i++) m.put("p"+i,ss[i]); addParameters(m); return ss[0]; } } public class HttpServletFlowExecutionManager2 extends HttpServletFlowExecutionManager { protected Event createEvent(HttpServletRequest request, HttpServletResponse response) { return new HttpServletRequestEvent2(request, response); } }


Reply With Quote