• 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

Extracting a parameter from c:out value

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

Need some help on the following.

I have a project overview jsp which displays project activity and a view comments button for each activity belonging to the project:




What I want to do is extract the activity id according to which view comments button the user has pressed. I can do this with checkboxes by getting an array of parameter values but with submit buttons it just seems to take the most recent activity id. I've played around with hidden fields etc but cant get it to work.

Thanks in advance,

James

 
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
I'm not entirely clear what you want to do, but if you mean you want to send the appropriate activity id on a submit you could just use JavaScript to set a hidden field, just use the activity id as an argument in an on click/whatever call. Although I'd say if you're not really doing anything other than that I'd probably just use a link rather than a form.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Once the page gets to the browser, the fact that <c:out> was used is completely moot. So this really isn't a JSP question. Moved to the HTML forum.
 
James Haville
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:I'm not entirely clear what you want to do, but if you mean you want to send the appropriate activity id on a submit you could just use JavaScript to set a hidden field, just use the activity id as an argument in an on click/whatever call. Although I'd say if you're not really doing anything other than that I'd probably just use a link rather than a form.



There may be several activity updates on the page each with different IDs. The user can click 'view comments' on each one. I want to be able to get the appropriate ID on the activity they have selected in my servlet by getting the parameter. At the moment if I try to get the ID it just gives me the last activity ID and not the specific one they have selected to view the comments on.

I think I understand what you are saying with the JavaScript. But I am not too familiar with it so could you clarify the process for me or point me to a resource(s) that will do this. What do you mean when you say 'use JavaScript to set a hidden field'?

Thanks
 
James Haville
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can get the id doing this...



And this in the servlet...


However when I introduce a hidden field i.e....



I have the problem where it only recognises the last activity id.
 
James Haville
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I managed to do it.

Here is the solution if anyone has a similar problem in the future:


and the javascript



 
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'll actually want to return false from the onclick handler, either by returning the results of your handler function, or by explicitly returning false on the onclick attribute, otherwise it'll attempt to submit the form twice.
 
reply
    Bookmark Topic Watch Topic
  • New Topic