就是下面这段代码,主要的。通过add按钮可以弹出一个小窗口选择一条数据,添加。
但是我现在不想让s:iterator中有重复数据,不让postName重复。
<s:if test="functionGroupBO.postAccountVOs != null">
<script>existRow = 0;</script>
<s:iterator value="functionGroupBO.postAccountVOs" status="stat">
<tr class="dataRow">
<td>
<input type="checkbox" name="delDetail" value="tr0" />
<input type="hidden" name="postIds"
value='<s:property value="postId"/>' />
</td>
<td>
<input type="text" name="postNames" readonly="readonly"
value='<s:property value="postName"/>' />
</td>
<td>
<input type="text" name="userNames" readonly="readonly"
value='<s:property value="userAccountVO.userName"/>' />
</td>
</tr>
<script>existRow++;</script>
</s:iterator>
</s:if>
<s:else>
<tr class="dataRow">
<td>
<input type="checkbox" name="delDetail" value="tr0" />
<input type="hidden" name="postIds"
value='<s:property value="postId"/>' />
</td>
<td>
<input type="text" name="postNames" readonly="readonly"
value='<s:property value="postName"/>' />
</td>
<td>
<input type="text" name="userNames" readonly="readonly"
value='<s:property value="userAccountVO.userName"/>' />
</td>
</tr>
</s:else> </table>
</td>
</tr>
<tr>
<td colspan="3" align="right">
<input type="button" name="button3" id="addRowBtn" value="Add"
onclick="js:addRow()" />
<input type="button" name="button3" id="button4" value="Delete"
onclick="js:removeRow()" />
</td>
</tr>
但是我现在不想让s:iterator中有重复数据,不让postName重复。
<s:if test="functionGroupBO.postAccountVOs != null">
<script>existRow = 0;</script>
<s:iterator value="functionGroupBO.postAccountVOs" status="stat">
<tr class="dataRow">
<td>
<input type="checkbox" name="delDetail" value="tr0" />
<input type="hidden" name="postIds"
value='<s:property value="postId"/>' />
</td>
<td>
<input type="text" name="postNames" readonly="readonly"
value='<s:property value="postName"/>' />
</td>
<td>
<input type="text" name="userNames" readonly="readonly"
value='<s:property value="userAccountVO.userName"/>' />
</td>
</tr>
<script>existRow++;</script>
</s:iterator>
</s:if>
<s:else>
<tr class="dataRow">
<td>
<input type="checkbox" name="delDetail" value="tr0" />
<input type="hidden" name="postIds"
value='<s:property value="postId"/>' />
</td>
<td>
<input type="text" name="postNames" readonly="readonly"
value='<s:property value="postName"/>' />
</td>
<td>
<input type="text" name="userNames" readonly="readonly"
value='<s:property value="userAccountVO.userName"/>' />
</td>
</tr>
</s:else> </table>
</td>
</tr>
<tr>
<td colspan="3" align="right">
<input type="button" name="button3" id="addRowBtn" value="Add"
onclick="js:addRow()" />
<input type="button" name="button3" id="button4" value="Delete"
onclick="js:removeRow()" />
</td>
</tr>
解决方案 »
- struts 自定义标签问题.
- 关于org.apache.jasper.servlet.JspServlet
- java session取值
- myeclipse写mybatis配置问题
- JSP里取得的值传送到ACTION里是乱码,请问如何解决?
- 基于SpringSecurity3.x, JasperReport5.x等技术实现仿金蝶权限管理的企业信息管理系统
- 安装memcache时出现的问题,求大师指点
- 入门级问题,为什么要用hibernate?
- unicode,utf-8,utf-16,unicode escape sequence 等有什么区别?
- 用eclipse2.1.1开发easy struts的问题
- 关于getParameterMetaData()
- Date类型的格式化
如果你的容器是 List , 它里面是可以有重复数据的 ,
要想数据不重复,建议用 Set 。
var uri = "adminUGMemberSelect";
var rtnValue = window.showModalDialog(uri);
if (rtnValue) {
//add by:sc_zhang 2011-4-25
var postIds = document.getElementsByName("postIds");
var values;
values = rtnValue.split(",");
if (postIds.length != 0) {
for ( var i = 0; i < postIds.length; i++) {
if (postIds[i].value == values[0]) {
alert("Current Member已经存在,不能重复添加!");
return;
}
}
}
executeAddRow();
parseReturnValue(rtnValue, detailRow - 1);
}
//fo.action="adminUGMember";
}