JSF El表达式删除不必要的逗号
在PrimeFaces 5.1中,我使用命令显示dataTable学生主题显示JSF El表达式删除不必要的逗号,jsf,primefaces,jstl,Jsf,Primefaces,Jstl,在PrimeFaces 5.1中,我使用命令显示dataTable学生主题显示 <p:dataTable id="student" var="stud" value="#{stud.details}"> <p:column headerText="studentName"> .... </p:column> <p:column headerText="subject">
<p:dataTable id="student" var="stud" value="#{stud.details}">
<p:column headerText="studentName">
....
</p:column>
<p:column headerText="subject">
<c:forEach begin="1" items="#{stud.typeNameList}" varStatus="selectedSTypeIndex" var="text">
<ui:fragment rendered="${dept.sstTypeSelected[selectedTypeIndex.index] eq true}">
<h:outputLabel value=","/>
<h:outputLabel value="#{text}"/>
</ui:fragment>
</c:forEach>
</p:column>
</p:daTable>
我的疑问是,如何使用JSF或任何其他方式删除泰米尔语主题前面的逗号?使用
使如果其他..
条件,
更新代码如下:
<p:dataTable id="student" var="stud" value="#stud.details}">
<p:column headerText="studentName">
....
</p:column>
<p:column headerText="subject">
<c:forEach begin="1" items="#{stud.typeNameList}" arStatus="selectedSTypeIndex" var="text">
<ui:fragment rendered="${dept.sstTypeSelected[selectedTypeIndex.index] eq true}">
<c:choose>
<c:when test="${selectedSTypeIndex.first}">
<!--if first element, do nothing -->
</c:when>
<c:otherwise>
<c:choose>
<c:when test="${dept.sstTypeSelected[selectedTypeIndex.index-1] eq false}">
<!--if last elemnt wasn't rendererd so do nothing -->
</c:when>
<c:otherwise>
<h:outputLabel value=","/>
</c:otherwise>
</c:choose>
</c:otherwise>
</c:choose>
<h:outputLabel value="#{text}"/>
</ui:fragment>
</c:forEach>
</p:column>
</p:daTable>
....
selectedSTypeIndex.index==1(或0,不记得了),然后不显示
在上面的泰米尔语、英语、数学中不允许逗号(,)是可以的。但是一些学生没有泰米尔语科目,我为泰米尔语设置了false,当时英语科目剩下一个逗号,因为我使用了rendered=“${dept.ssttypeselectedTypeIndex.index]eq true}显示部门主题我不明白,你的意思是当学生没有泰米尔语主题时,主题开头会出现逗号?@prem我更改了代码,如果我理解了,它现在可能会起作用!
<p:dataTable id="student" var="stud" value="#stud.details}">
<p:column headerText="studentName">
....
</p:column>
<p:column headerText="subject">
<c:forEach begin="1" items="#{stud.typeNameList}" arStatus="selectedSTypeIndex" var="text">
<ui:fragment rendered="${dept.sstTypeSelected[selectedTypeIndex.index] eq true}">
<c:choose>
<c:when test="${selectedSTypeIndex.first}">
<!--if first element, do nothing -->
</c:when>
<c:otherwise>
<c:choose>
<c:when test="${dept.sstTypeSelected[selectedTypeIndex.index-1] eq false}">
<!--if last elemnt wasn't rendererd so do nothing -->
</c:when>
<c:otherwise>
<h:outputLabel value=","/>
</c:otherwise>
</c:choose>
</c:otherwise>
</c:choose>
<h:outputLabel value="#{text}"/>
</ui:fragment>
</c:forEach>
</p:column>
</p:daTable>