Struts2:单选按钮、迭代和列表问题
我有一个复杂的问题,我希望能够清楚地解释它......
我有 2 个列表。在我的 jsp 上,我有一个包含这 2 个列表的嵌套迭代,其中有一个标签。
这是代码:
<s:iterator value="listSurveyToRender" var="s" status="counterS">
<s:iterator value="listSurveyValuesToRender" var="sv" status="counterSv" >
<s:if test="%{#s.idsurvey==#sv.survey.idsurvey}">
<td><s:radio list="sv" listValue="valoreTesto" name="provaRadio1" />
</s:if>
</s:iterator>
这是这个 jsp 的结果:
Question 1: (first iterator)
resp 1: (second iterator)
resp 2:
resp 3:
Question 2: (first iterator)
resp 1: (second iterator)
resp 2:
问题是,当我选择收音机时,因为列表对于所有收音机都是唯一的,所以选择排除了其他收音机...
我需要在第二个迭代器上限制此排除。
谢谢!
I have a complicated problem and I hope to explain it clearly possible...
I have 2 list. On my jsp I have a nested iteration with this 2 lists, inside this there is a tag.
This is the code:
<s:iterator value="listSurveyToRender" var="s" status="counterS">
<s:iterator value="listSurveyValuesToRender" var="sv" status="counterSv" >
<s:if test="%{#s.idsurvey==#sv.survey.idsurvey}">
<td><s:radio list="sv" listValue="valoreTesto" name="provaRadio1" />
</s:if>
</s:iterator>
This is the result of this jsp:
Question 1: (first iterator)
resp 1: (second iterator)
resp 2:
resp 3:
Question 2: (first iterator)
resp 1: (second iterator)
resp 2:
The problem is that, when I select the radio, because the list is unique for all, the selection exclude the others...
I need to restrict this exclusion on the second iterator.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
重点是:要分隔单选按钮组,您需要为每个按钮组指定一个不同名称。
我不使用Struts,但理论上,替换
为
应该可以。
阅读/解释生成的 HTML 源代码(在浏览器中打开页面,右键单击,查看源代码)也应该会带来很多新的见解。
To the point: to separate radio button groups, you need to give them each a different name.
I don't do Struts, but in theory, replacing
by
should do.
Reading/interpreting the generated HTML source (open page in browser, rightclick, view source) should also give a lot of new insights.
也许可以做这样的事情:
我还没有机会对此进行测试,但基本上每次外部迭代都会增加 x ,并且 x 将用于为每个组的单选按钮创建唯一的 id 。
在您的操作中,您必须声明 provaRadio1、provaRadio2 等才能获取提交的值。
It may be possible to do something like this:
I haven't had a chance to test this but basically every outer iteration will increment x and x will be used to create a unique id for the radio button of each group.
In your action you will have to declare provaRadio1, provaRadio2 etc to get the value submitted.