我有个用户编辑页面,editUser.xhtml,因为编辑用户和新增用户共用这个页面,所以用户ID需要在编辑状态设置成只读.<h:inputText styleClass="midInput" disabled="true" value="#{userBean.user.userId}" rendered="#{userBean.type == 'update'}" id="userId" required="true" requiredMessage="用户ID不能为空" maxlength="8">
<f:validateLength minimum="1" maximum="8" />
</h:inputText> <h:inputText styleClass="midInput" value="#{userBean.user.userId}" rendered="#{userBean.type == 'add'}" id="userId" required="true" requiredMessage="用户ID不能为空" maxlength="8">
<f:validateLength minimum="1" maximum="8" />
得到异常:java.lang.IllegalStateException: component with duplicate id "editForm:userId" foundCaused by:
java.lang.IllegalStateException - component with duplicate id "editForm:userId" found
说userId重复 ,这种情况如何处理呢?
<f:validateLength minimum="1" maximum="8" />
</h:inputText> <h:inputText styleClass="midInput" value="#{userBean.user.userId}" rendered="#{userBean.type == 'add'}" id="userId" required="true" requiredMessage="用户ID不能为空" maxlength="8">
<f:validateLength minimum="1" maximum="8" />
得到异常:java.lang.IllegalStateException: component with duplicate id "editForm:userId" foundCaused by:
java.lang.IllegalStateException - component with duplicate id "editForm:userId" found
说userId重复 ,这种情况如何处理呢?
js怎么控制? 给个例子贝
=================
这样应该是可以的, 就是代码有点ugly, 我不知道有没有别的简单的办法, js是一条路.
val = $('#editForm').find("[name='editForm:userId']").val(); if(val != ""){ $('#editForm').find("[name='editForm:userId']").attr('readonly','true'); } });