請幫助我找到一個示例來更新p:inputtext,其中存儲的數據存儲在已設置(已解決)的bean中,方法是選擇一個p:對話框的數據表的行。我已經成功地以相同的方式更新輸出文本。通過對話框更新輸入文本
我使用(學習)的NetBeans 7.2 primefaces 3.2,GlassFish的3.1
thansk你的幫助
rs_ncs
請幫助我找到一個示例來更新p:inputtext,其中存儲的數據存儲在已設置(已解決)的bean中,方法是選擇一個p:對話框的數據表的行。我已經成功地以相同的方式更新輸出文本。通過對話框更新輸入文本
我使用(學習)的NetBeans 7.2 primefaces 3.2,GlassFish的3.1
thansk你的幫助
rs_ncs
看primefaces showcase和user guide,你會發現你所需要的一切;詳細搜索datatable組件的rowSelect事件。祝你好運=)
不幸的是沒有什麼差異更新h:outputtextand p:inputtext – user1893183
,因爲沒有 – Gnappuraz
如果你想從數據表中選擇一行更新一個組件,那麼你可以使用在rowselect
事件上監聽的<p:ajax>
的update
屬性。事情是這樣的:
<p:ajax event="rowSelect" update=":xx:xx" />
我可以從p:對話框更新h:outputtext組件。我需要幫助來從p:對話框更新p:inputtext組件 – user1893183
的建議通過BalusC代碼<p:ajax event="rowSelect" update=":xx:xx" />
應該工作....
這裏是更新這兩個inputText的和的outputText的一個例子。
<h:form>
<p:dataTable id="usertable" var="user" value="#{userManageBean.userList}"
rowKey="#{user.U_ID}" selection="#{userManageBean.selectedUser}"
selectionMode="single" paginator="true" rows="18" >
<p:ajax event="rowSelect" update=":useredit:edituser" />
<p:ajax event="rowSelect" update=":viewuser:displayuser" />
<p:column headerText="User Name">
<h:outputText value="#{user.username}" />
</p:column>
<p:column headerText="FName">
<h:outputText value="#{user.firstname}" />
</p:column>
<p:column headerText="LName">
<h:outputText value="#{user.lastname}" />
</p:column>
</p:dataTable>
</h:form>
<p:dialog id="userview" header="View User" widgetVar="dlg2" >
<h:form id="viewuser">
<h:panelGrid id="displayuser" columns="2" cellpadding="4">
<h:outputText value="User Name:" />
<h:outputText value="#{userManageBean.selectedUser.username}" />
<h:outputText value="First Name" />
<h:outputText value="#{userManageBean.selectedUser.firstname}" />
<h:outputText value="Last Name:" />
<h:outputText value="#{userManageBean.selectedUser.lastname}" />
</h:panelGrid>
</h:form>
</p:dialog>
<p:dialog id="user_edit" header="Edit User" widgetVar="dlgedit" >
<h:form id="useredit">
<h:panelGrid id="edituser" columns="2" cellpadding="4">
<h:outputText value="First Name" />
<h:inputText value="#{userManageBean.selectedUser.firstname}" />
<h:outputText value="Last Name" />
<h:inputText value="#{userManageBean.selectedUser.lastname}" />
<p:commandButton id="updateUser" value="Add" action="#{someaction}"
ajax="false" />
</h:panelGrid>
</h:form>
</p:dialog>
可能重複[如何引用JSF ajax中的組件?找不到標識符爲「foo」的組件在視圖中](http://stackoverflow.com/questions/8634156/how-to-reference-components-in-jsf-ajax-cannot-find-component-with-identifier) – BalusC
它不是重複的。我的問題不是識別問題,因爲我可以通過ID來更新輸出文本。我的問題是如何更新輸入文本。有什麼區別嗎? – user1893183
顯然你沒有閱讀過重複的答案。它精確地告訴你如何找到正確的客戶ID。 – BalusC