Using Struts 2, I'm trying to set up a JSP file that has 3 radio buttons at the top of the page, and when the user selects one of them (without needing to hit a 'submit' button), an action will be called and a new page loaded into the browser. The content of the new page will depend on which of the three radio buttons is selected by the user.
In the JSP page I have these tags:
(1) document.write(value); – writes the value of "value" to the screen, and I can see that this aspect is working correctly (it shows the proper value for each button).
(2) the href property works great and executes the action which calls another JSP file. In this test case it is a generic JSP file that does not depend on "value."
but it didn't work. Error message: "value cannot be resolved."
The suggestions I've seen for making this work involve providing a hidden input field in your form and writing the value of the variable to this input field before you submit your form. My problem is that I'm not submitting a form in this case, just using the onclick attribute.
Any ideas for how I can pass this value to my action class? Thank you!
There's nothing secret about my attempt to control the way the user is sorting. My JSP page is a list of records obtained from a database table, and the radio buttons at the top are various choices for ways the data can be sorted. I'd like for the user to click on one of the radio buttons and have the page immediately regenerated with all items in the requested sort sequence.
From what you said, I guess using an Ajax request is the only way I can do this. I know nothing about Ajax, so I guess this is a good time to start learning.