I am using JAVA STRUTS. I have an html form with an ActionForm class associated with it and the controls are created using tags. As I understand it, STRUTS will persist selections on an html form even if the form is refreshed. I need to prevent this behavior and force it to rebind the values from the ActionForm object.
Basically, I have a form with a radio button group that allows the user to select A, B, or C. I have an ActionForm that has the property "selection = A" set when the form is loaded. If the user selects B and submits it, the form is correctly set to "selection = B" and all is good. However, when I refresh the page, the ActionForm gets reset to "selection = A" (confirmed through debugging), but the radio buttons have B selected!
Does anyone know why this is or how I can prevent it from happening?
Regarding to your post i thought it was belongs to struts2
so,
According to struts2 it is not possible means, you have to give the static value or you have to make in programmatic manner through JPA (or)your java code
.
For JPA you refer this link it is helpful JPA way
This explanation is refer to static way
First in jsp page you have to import struts2 tags
through taglib uri
then it shows the available struts2 tags in those tags you have to select <s:radio></s:radio> tag
eg:
<s:radio label="Selections" name="your name" list="#{'A':'A','B':'B'}" value="2" />
in this code i typed the value as 2 so, it select B as a default if you remove the value it won't select any default values.
Basically what i am trying to say here is without value it won't select any radio buttons
you have to give value through static way or dynamic way.
For dynamic way you can refer this link dynamic radio button
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.