This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Extracting a parameter from c:out value

 
James Haville
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • 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

 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic