• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Submitting a form from table item

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
There is no beard big enough to make me comfortable enough with my masculinity to wear pink. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic