Jsf 如何在用户选择的行后显示对话框?
我有这个数据表:Jsf 如何在用户选择的行后显示对话框?,jsf,jsf-2,primefaces,datatable,Jsf,Jsf 2,Primefaces,Datatable,我有这个数据表: <h:form id="form"> <p:dataTable id="tblInfo" var="ref" value="#{consultasBean.listaRefacciones}" paginator="true" rows="10" selectionMode="single" selection="#{consultasBean.refaccionSeleccionada}" rowKey="#{ref.idRefaccion}">
<h:form id="form">
<p:dataTable id="tblInfo" var="ref" value="#{consultasBean.listaRefacciones}" paginator="true" rows="10" selectionMode="single" selection="#{consultasBean.refaccionSeleccionada}" rowKey="#{ref.idRefaccion}">
<p:column headerText="Equipo">
<h:outputText value="#{ref.equipo}" />
</p:column>
<p:column headerText="Marca">
<h:outputText value="#{ref.marca}" />
</p:column>
//More colums here...
</p:dataTable>
我想在用户选择一行后显示此对话框:
<p:dialog id="myDialog" widgetVar="refaccionDialog" header="Detalle Refaccion" resizable="false" width="300" showEffect="explode" hideEffect="explode">
<h:panelGrid id="display" columns="2" cellpadding="4">
<h:outputText value="Info:" />
<h:outputText value="#{consultasBean.refaccionSeleccionada.equipo}" />
</h:panelGrid>
//More things here...
</p:dialog>
这是我的bean ViewScope的一部分:
private List<RefaccionBean> listaRefacciones = null;
private RefaccionBean refaccionSeleccionada = null;
// setters and getters...
Listarefaciones已经有了信息,所以不要担心它是如何获得信息的
我知道我必须使用p:ajax,但就是不知道如何使用
我正在检查示例1是否符合我的要求,但信息太旧,现在无法使用
请帮帮我。只需在您的表中包含一个p:ajax即可
<p:ajax event="rowSelect" oncomplete="PF('refaccionDialog').show()" update=":dialogId" />
希望这有帮助。只需在表中包含一个p:ajax即可
<p:ajax event="rowSelect" oncomplete="PF('refaccionDialog').show()" update=":dialogId" />
希望这有帮助。数据表的rowKey属性写错了。
应该是这样的
rowKey="#{ref.idRefaccion}"
datatable代码应该如下所示
<h:form id="form">
<p:dataTable id="tblInfo" var="ref" value="#{consultasBean.listaRefacciones}" paginator="true" rows="10" selectionMode="single"
selection="#{consultasBean.refaccionSeleccionada}" rowKey="#{ref.idRefaccion}">
<p:column headerText="Equipo">
<h:outputText value="#{ref.equipo}" />
</p:column>
<p:column headerText="Marca">
<h:outputText value="#{ref.marca}" />
</p:column>
//More colums here...
</p:dataTable>
datatable的rowKey属性写入错误。
应该是这样的
rowKey="#{ref.idRefaccion}"
datatable代码应该如下所示
<h:form id="form">
<p:dataTable id="tblInfo" var="ref" value="#{consultasBean.listaRefacciones}" paginator="true" rows="10" selectionMode="single"
selection="#{consultasBean.refaccionSeleccionada}" rowKey="#{ref.idRefaccion}">
<p:column headerText="Equipo">
<h:outputText value="#{ref.equipo}" />
</p:column>
<p:column headerText="Marca">
<h:outputText value="#{ref.marca}" />
</p:column>
//More colums here...
</p:dataTable>
它不起作用,我在表中包括了这一行,并将id=myDialog放在标记中。现在更新的是update=myDialog。我做错了什么?我就是这样做的:问题是对话框没有向我显示信息,如果我有超过10行,将导致datatable有更多的页面,我选择一行;之后,我无法移动到datatable和导航的其他页面。我更新了问题的一些代码你有javascript错误吗?检查你的控制台。我想是的,在我选择一行之后,控制台已经满了。我能做些什么来解决这个问题?非常感谢!它是如此简单。。。感谢您的耐心。它不起作用,我在表中包括了这一行,并将id=myDialog放在标记中。现在更新的是update=myDialog。我做错了什么?我就是这样做的:问题是对话框没有向我显示信息,如果我有超过10行,将导致datatable有更多的页面,我选择一行;之后,我无法移动到datatable和导航的其他页面。我更新了问题的一些代码你有javascript错误吗?检查你的控制台。我想是的,在我选择一行之后,控制台已经满了。我能做些什么来解决这个问题?非常感谢!它是如此简单。。。谢谢你的耐心