You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Markus Schulz (JIRA)" <ji...@apache.org> on 2017/05/30 15:57:04 UTC
[jira] [Commented] (WW-1534) The value of checkbox getted in
server-side is "false" when no any checkbox been selected.
[ https://issues.apache.org/jira/browse/WW-1534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16029600#comment-16029600 ]
Markus Schulz commented on WW-1534:
-----------------------------------
No, this isn't solved by WW-2339. I guess the patch rev655721 mentioned in WW-2339 is now the git commit 9a22985c1f6554b908df14e53cda32b41f1e33ec.
This patch does't distinguish between a single rendered checkbox with a certain name (often used with boolean getter/setter in the action) and multiple rendered checkboxes with the same name (often used with a list getter/setter (e.g. ids) in the action), but the latter actually renders a single checkbox only.
This is the case if you e.g. iterate over a list and render a checkbox for every entry in the list. If the list contains only a single entry, then you will get a single checkbox.
As a workaround a hidden div containing two additional checkboxes can be used to ensure that there are more than one rendered checkboxes:
<div style="display:none;">
<s:checkbox name="myIds" fieldValue="0" value="false"/>
<s:checkbox name="myIds" fieldValue="0" value="false"/>
</div>
<s:iterator ...>
<s:checkbox name="myIds" fieldValue="..." value="..."/>
</s:iterator>
I know that this is ugly, but I don't see a chance to get this distinguished in the interceptor.
> The value of checkbox getted in server-side is "false" when no any checkbox been selected.
> ------------------------------------------------------------------------------------------
>
> Key: WW-1534
> URL: https://issues.apache.org/jira/browse/WW-1534
> Project: Struts 2
> Issue Type: Improvement
> Components: Value Stack
> Affects Versions: 2.0.1
> Environment: tomcat-5.5.20 / jdk1.5.0.08
> Reporter: Ling Chang Ming
> Fix For: Future
>
>
> jsp section:
> <s:iterator value="%{#request.rolePs.items}" id="role" status="status">
> <tr >
> <td height="25" width="5%">
> <s:checkbox name="roleId" fieldValue="%{id}" theme="simple"/>
> </td>
> </tr>
> ........
> </s:iterator>
> action section:
> ....
> private String[] roleId;
> public String[] getRoleId() {
> return roleId;
> }
> public void setRoleId(String[] roleId) {
> this.roleId = roleId;
> }
> .....
> the retrieved value of "roleId" is {"false"} when user doesn't select any checkbox elements. In my opinion, this case should returns null directly.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)