由于jsf中标签都是使用id来识别的,因此在jsf中标签最好给id取一个名字,否则很可能会出现一些问题
比如:下面这段程序
<td>
<c:if test="${FLAG}">
<h:commandButton id="dfdf" value="#{msg['unsalable.save.approve']}" action=""></h:commandButton>
<h:commandButton id="ddd" value="#{msg['unsalable.cancel.buhuo']}" action=""></h:commandButton>
</c:if>
<c:if test="${!FLAG}">
<h:commandButton id="ff" value="#{msg['unsalable.out.addPage.cancel']}"></h:commandButton>
</c:if>
</td>
如果第一个按钮的id和第三个按钮的id没有标识,那么
<c:if test="${!FLAG}">
<h:commandButton id="ff" value="#{msg['unsalable.out.addPage.cancel']}"></h:commandButton>
</c:if>
显示后再显示
<c:if test="${FLAG}">
<h:commandButton id="dfdf" value="#{msg['unsalable.save.approve']}" action=""></h:commandButton>
<h:commandButton id="ddd" value="#{msg['unsalable.cancel.buhuo']}" action=""></h:commandButton>
</c:if>
那么第一个按钮显示的值就会和第三个按钮显示的值一样,不会按照你自己的定义的标签显示
比如:下面这段程序
<td>
<c:if test="${FLAG}">
<h:commandButton id="dfdf" value="#{msg['unsalable.save.approve']}" action=""></h:commandButton>
<h:commandButton id="ddd" value="#{msg['unsalable.cancel.buhuo']}" action=""></h:commandButton>
</c:if>
<c:if test="${!FLAG}">
<h:commandButton id="ff" value="#{msg['unsalable.out.addPage.cancel']}"></h:commandButton>
</c:if>
</td>
如果第一个按钮的id和第三个按钮的id没有标识,那么
<c:if test="${!FLAG}">
<h:commandButton id="ff" value="#{msg['unsalable.out.addPage.cancel']}"></h:commandButton>
</c:if>
显示后再显示
<c:if test="${FLAG}">
<h:commandButton id="dfdf" value="#{msg['unsalable.save.approve']}" action=""></h:commandButton>
<h:commandButton id="ddd" value="#{msg['unsalable.cancel.buhuo']}" action=""></h:commandButton>
</c:if>
那么第一个按钮显示的值就会和第三个按钮显示的值一样,不会按照你自己的定义的标签显示
本文通过一个具体的示例说明了在JSF框架中为组件指定唯一ID的重要性。当两个按钮的ID未正确设置时,可能导致按钮的行为混乱,显示错误的文本。文章强调了合理分配ID对于维护组件状态和交互逻辑的必要性。
71

被折叠的 条评论
为什么被折叠?



