Jsf 从primefaces数据表中删除行会中断页面
因此,我有两个表,Jsf 从primefaces数据表中删除行会中断页面,jsf,jsf-2,primefaces,Jsf,Jsf 2,Primefaces,因此,我有两个表,table1和table2。对于这两个按钮,我有两个按钮来添加行和删除行。 如果表2中没有任何行,我只能在表1中添加或删除行,并且我使用{myBean.table2HasRows}来测试这一点 所以我进入了页面。我在表1中有5行,在表2中有2行。我可以正常添加或删除表2中的行。然后我从表2中删除2行,这样我就可以删除表1中的行。 当我能够在表1中添加或删除行时,我可以正常添加,也可以删除我刚才正常添加的行。但是,当我删除我在页面中输入时加载的table1的任何行时(在bean中
table1
和table2
。对于这两个按钮,我有两个按钮来添加行和删除行。
如果表2中没有任何行,我只能在表1
中添加或删除行,并且我使用{myBean.table2HasRows}
来测试这一点
所以我进入了页面。我在表1
中有5行,在表2中有2行。我可以正常添加或删除表2中的行。然后我从表2
中删除2行,这样我就可以删除表1
中的行。
当我能够在表1
中添加或删除行时,我可以正常添加,也可以删除我刚才正常添加的行。但是,当我删除我在页面中输入时加载的table1
的任何行时(在bean中,我从{myBean.table1RowRepresentationList}
列表中删除了一个对象),行会被删除,但页面中的所有内容都会停止工作。我不能添加或删除任何其他行,也不能使用页面中的任何其他按钮,bean将不再被调用。
控制台中不显示任何错误
会发生什么
谢谢
<h:form>
<table width="1150x">
<tr>
<td>
<h:outputLabel styleClass="labelPublicacao" value="Table 1 " />
<h:outputLabel value="Table 1 description" />
</td>
<td colspan="2">
<h:panelGrid id="table1Panel" columns="2" styleClass="panelGridTop">
<p:dataTable
id="table1"
var="table1Var"
value="#{myBean.table1RowRepresentationList}"
editable="true" editMode="cell" style="align:center;" styleClass="geralBorderless">
<p:column headerText="" style="width:20px; " >
<p:commandLink
action="#{myBean.deleteTable1Row}"
update="table1,:form:wrongOption"
id="removeButton"
disabled="#{myBean.table2HasRows}"
>
<h:graphicImage value="/resources/icons/delete.gif" />
<f:setPropertyActionListener value="#{table1Var}"
target="#{myBean.table1RowRepresentation}" />
</p:commandLink>
</p:column>
<p:column headerText="Número de questões" style="width:70px;text-align:center">
<p:inputMask
value="#{table1Var.numberQuestions}"
style="width:25px;"
id="questionsField"
mask="9?9"
disabled="#{myBean.table2HasRows}"
/>
</p:column>
<p:column headerText="Error points" style="width:65px;text-align:center" rendered="#{myBean.wrongType}">
<p:inputText
value="#{table1Var.wrongField}"
style="width:25px;"
id="wrongPointsField"
onkeyup="formatDecimal(this);"
disabled="#{!myBean.wrongType}"
>
<f:convertNumber locale="pt_BR"/>
</p:inputText>
</p:column>
</p:dataTable>
<table>
<tr>
<td>
<p:commandButton value="ADD ROW"
update="table1,wrongOption"
id="addRowTable1Button"
actionListener="#{myBean.addRowForTabl1}"
disabled="#{myBean.table2HasRows}"
/>
</td>
</tr>
</table>
</h:panelGrid>
</td>
</tr>
<tr>
<td><h:outputLabel styleClass="labelPublicacao"
value="Table 2 " /> <h:outputLabel
value="Description of table 2" />
</td>
<td colspan="2">
<h:panelGrid id="table2Panel" columns="2" width="670" styleClass="panelGridTop">
<p:dataTable
id="table2"
var="table2Var"
value="#{myBean.table2RowRepresentationList}"
editable="true"
editMode="cell"
style="align:center;"
styleClass="geralBorderless">
<p:column headerText="" style="width:20px;">
<p:commandLink
action="#{myBean.deleteTable2Row}"
update="table2, :form:table1Panel"
id="remove3Button">
<h:graphicImage value="/resources/icons/delete.gif" />
<f:setPropertyActionListener
value="#{table2Var}"
target="#{myBean.table2RowRepresentation}" />
</p:commandLink>
</p:column>
<p:column headerText="Name" >
<p:inputText
value="#{table2Var.concursoBook.name}"
style="width:140px;"
id="nameField"
/>
</p:column>
<p:column headerText="Modal buttons" style="width:290px;text-align: center;">
<p:commandButton value="Modal 1"
id="modal2Button"
oncomplete="modal2.show();"
styleClass="internalButton">
</p:commandButton>
<p:commandButton value="Modal 2"
id="modal1Button"
oncomplete="modal2.show();"
styleClass="internalButton">
</p:commandButton>
</p:column>
</p:dataTable>
<p:commandButton value="ADD ROW"
update="table2, table1, :form:table1Panel, addRowTable1Button"
id="addRowTable2Button"
action="#{myBean.addRowForTable2}"
/>
</h:panelGrid>
</td>
</tr>
</table>
</h:form>
而不是使用面板网格。调试并查看控制台中是否存在任何错误(使用firebug进行Web brwoser调试)。chrome浏览器控制台中唯一的错误是未捕获类型错误:无法调用每次滚动页面时抛出的null方法“clearTimeout”
。。但我不认为这是问题所在。。。很奇怪,table2
与table1
非常相似。为什么只有在表1中才会发生这种情况?发布托管bean代码。