Announcement Announcement Module
Collapse
No announcement yet.
Event parameters from HTML submit buttons. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Event parameters from HTML submit buttons.

    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 &#123;
        public HttpServletRequestEvent2&#40;HttpServletRequest request, HttpServletResponse response&#41; &#123;
            super&#40;request,response&#41;; &#125;
        protected Object searchForParameter&#40;String logicalName, String delimiter&#41; &#123;
            String s = &#40;String&#41;super.searchForParameter&#40;logicalName,delimiter&#41;;
            if &#40;s==null&#41; return null;
            String ss&#91;&#93; = s.split&#40;delimiter&#41;;
            Map m = new HashMap&#40;&#41;;
            for&#40; int i=1; i<ss.length; i++&#41; m.put&#40;"p"+i,ss&#91;i&#93;&#41;;
            addParameters&#40;m&#41;;
            return ss&#91;0&#93;;
        &#125;
    &#125;
    
    public class HttpServletFlowExecutionManager2 extends HttpServletFlowExecutionManager &#123;
    	protected Event createEvent&#40;HttpServletRequest request, HttpServletResponse response&#41; &#123;
    		return new HttpServletRequestEvent2&#40;request, response&#41;;
    	&#125;
    &#125;

  • #2
    You could ofcourse do it with a bit of JavaScript in your pages. Something like:

    <input type="button" value="edit" onclick="javascript:doEdit(<c:out value="${row}"/>)">

    function doEdit(row) {
    document.myForm["_eventId"].value="edit;
    document.myForm["row"].value=row;
    document.myForm.submit();
    }

    Erwin

    Comment

    Working...
    X