aspose file tools*
The moose likes Struts and the fly likes Submitting a form from table item Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Submitting a form from table item" Watch "Submitting a form from table item" New topic
Author

Submitting a form from table item

Rick Smith
Greenhorn

Joined: Oct 04, 2004
Posts: 24
Hello.

I am trying to add table functionality to my page, but am having difficulty getting it to work properly.

I have a table and I am tying to add feature to remove a row item by clicking on a delete type icon at the end of th row.



Now, in order to pass an identifier of the row to my action handler I need to call a bit of java script to set a hidden input field. In addition to

this, my action handler is is an instance of DispatchActionSupport so I need to pass a parameter on the 'button'

As I said I want to use an icon so I tried using the line:



Unfortunatly this causes a javascript error with IE (6 and 7) telling me "Error: expected')'" I get the same outcome attempting if I attempt to use <html:submit ...>


I have had slightly more luck in simply using a standard html input of type submit which works, and allows me to prove my action work correctly:




But that gives me a column of big, uninspiring and ugly buttons but for some reason I cannot do a similar trick with the standard html input of type image:



when clicking on the icon I get the server side handler error:



This must be a common feature that people want to add to their tables, am I going about this in the wrong way?

If not then does anyone know why this isn't working as I expect?

Many thanks for any help
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

The original JSP doesn't work because you can't nest custom tags like that.

If you're using a JSP 2+ container, just use:



(I also don't think there's any real reason to use the "javascript:" prefix.)
Rick Smith
Greenhorn

Joined: Oct 04, 2004
Posts: 24
David, many thanks for your reply.

I certainly does make the JSP much more readable, although unfortunatly I still get the error relating to (I think) the fact that I'm trying to use a DispatchActionSupport based Action handler.



I've taken a longer look at this and found that the request doesn't contain what I expected it to do so, it appears that when the request is submitted instead of a request parameter called method being submitted two request parameters method.x and method.y are submitted, I presume (*) that this specifies the location on the image that was clicked on. The upshot being that I cannot use the method parameter to identify the action handler method needed.

So what would be the recomendation here, to refactor to separate action handler methods to avoid having to pass this parameter, or is there an alternative tag that I can use to provide a clickable icon?


EDIT: * Ok I obviously didn't properly read or take in what the documentation says about thisTag image
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

You could probably use JavaScript to set a hidden parameter with the non-.x/.y value of the image and use that as the dispatch value instead.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Submitting a form from table item