I'm playing with Stripes and I wonder if it is possible to send Javascript generated data to ActionBean. To be more specific, when I click with my mouse on certain element on page, I want to send ID of that element back to ActionBean after clicking on stripes:link
. Providing I already have that ID saved in a JS variable id
, how do I do that?
views:
216answers:
2
+1
A:
create a hidden input element in your html
<input type="hidden" name="?" id="?" />
use javascript to set the value of it
document.getElementById("?").value = ??;
and the value will be posted with your form submission.
pstanton
2009-12-06 05:37:23
Just tried it, but it doesn't work. Maybe it would if I was using form, but I want to run event via link. Any ideas?
marioErr
2009-12-06 09:13:59
yes that would only work with a form. i'll leave it to someone else to explain how to do it without a form as it would be a bit more of a hack.
pstanton
2009-12-06 09:28:36
+2
A:
Are you using parameterised link?
<stripes:link id="mylink" href/beanclass="..." event="...">
<stripes:param name="id" value="some_default_value"/>
Click on me!
</stripes:link>
Which would most probably generate: http://mysite.com/...?id=some_default_value
, which you would later use javascript to change some_default_value
to the id
you want?
Note: Suggestion unverified. I've no dev tool installed on this old lappie.
Edit: On second thought, why not just write some javascript to append "?id=" + id;
to the link's url address?
Zefi
2009-12-11 14:04:53