6
我正在使用可点击行数据的primefaces,并且我需要找到如何从支持bean中设置选定行的方法。在primefaces数据表中设置支持bean中的选定行
还有就是我的数据表的定义:
<p:dataTable id="cablePathTable" var="cablePath" value="#{commonTableBean.cableLazyModel}" rows="100"
selectionMode="single" selection="#{commonTableBean.selectedCablePathTblRow}"
rowIndexVar="rowIndex" widgetVar="datatableVar"
emptyMessage="---">
<p:ajax event="rowSelect" process="@this" update=":form:portFieldset" />
<p:column headerText="No">
<h:outputText value="#{cablePath.column1}" />
</p:column>
<p:column headerText="Port A">
<h:outputText value="#{cablePath.column4}" />
</p:column>
<p:column headerText="Port B">
<h:outputText value="#{cablePath.column5}" />
</p:column>
我曾尝试下面的方法,但没有成功。 在支持bean我已经加入方法:
public void test(){
DataTable dataTable = (DataTable) FacesContext.getCurrentInstance().getViewRoot().findComponent("form:cablePathTable");
dataTable.setRowIndex(2);
}
而且我已经加入测试butoon到XHTML页面:
<p:commandButton process="@this" update=":form:cablePathTable" value="set2row" action="commonTableBean.test"/>
但理智最多改变的数据表,选择没有改变...
请有任何想法如何解决这个问题?
D'Oh!这很容易!非常感谢你! –
不客气。既然你是新来者,请不要忘记标记接受的答案,只要它有助于解决问题。另请参阅[如何接受答案的工作?](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235) – BalusC
是否有可能做到这一点时该页面显示为?没有按下一个命令按钮? – roel