Results 1 to 2 of 2

Thread: Event parameters from HTML submit buttons.

  1. #1
    Join Date
    May 2005
    Location
    London, UK
    Posts
    11

    Default 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. #2
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    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

Similar Threads

  1. Replies: 9
    Last Post: Apr 24th, 2007, 06:59 AM
  2. Event parameter usage
    By akw in forum Web Flow
    Replies: 1
    Last Post: Aug 28th, 2005, 02:50 AM
  3. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •