Curious... are the values based off an enum (as opposed to a String)? This was an issue for me at one point.

------ Original Message ------
From "Pranish Srigiri" <srigiri...@gmail.com>
To user@struts.apache.org
Date 1/5/2024 2:46:36 PM
Subject Trouble with <s:radio /> tag after upgrading from struts v2.5.31 to v6.3.0.2

Hi All,
I have a situation in my project where the radio buttons are not selected
by default. This has only started happening after I upgraded struts to
v6.3.0.2
Just a heads up, I've upgraded all the dependencies like OGNL, Freemarker,
after I upgraded struts to v6.3.0.2
I have a tag which looks like this.
<s:radio list="YesNo" listKey="key" listValue="value" name="sshCompress"
value="sshCompress" />

I set the list 'YesNo' in my Action class that looks like this.
ActionContext.getContext().put("YesNo",
PageData.getInstance().getRadioYesNo(params));
Here PageData.getInstance().getRadioYesNo(params) returns a HashMap.

In my action class sshCompress is set to "N":
sshCompress = "N";
The above variable also has its getter and setter.

When the page loads, the above struts radio tag is rendered like this in
v2.5.31:
<input type="radio" name="sshCompress" id="sshCompressY" value="Y">
<label for="sshCompressY">Yes</label>
<input type="radio" name="sshCompress" id="sshCompressN" checked="checked"
value="N"><label for="sshCompressN">No</label>

but it's rendered like this in v6.3.0.2
<input type="radio" name="sshCompress" id="sshCompressY" value="Y">
<label for="sshCompressY">Yes</label>
<input type="radio" name="sshCompress" id="sshCompressN" value="N">
<label for="sshCompressN">No</label>

If you notice, the radio button with value="N" is not checked by default in
v6.3.0.2 even though sshCompress is being set to "N" in the Action.

I can see this behaviour with all the <s:radio /> tags where the list
attribute is used, I'm not sure what has changed in the new version or if I
have missed adding something.

Like I said, no code has been changed in the project. The dependencies were
upgraded and the necessary compiler issues were resolved.

Please let me know if you need any more information.
Really appreciate all your help.

Thanks and Regards,
Pranish Srigiri

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to