File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Extracting a parameter from c:out value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Extracting a parameter from c:out value " Watch "Extracting a parameter from c:out value " New topic
Author

Extracting a parameter from c:out value

James Haville
Greenhorn

Joined: Jul 19, 2010
Posts: 10
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

Joined: Sep 29, 2008
Posts: 12617

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

Joined: Jan 10, 2002
Posts: 61768
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
James Haville
Greenhorn

Joined: Jul 19, 2010
Posts: 10
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

Joined: Jul 19, 2010
Posts: 10
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

Joined: Jul 19, 2010
Posts: 10
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

Joined: Sep 29, 2008
Posts: 12617

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Extracting a parameter from c:out value