gpt4 book ai didi

java - 从对话框中的数据表更改变量

转载 作者:行者123 更新时间:2023-12-01 15:39:39 25 4
gpt4 key购买 nike

我有一个关于更新 dataTable 组件内部变量的问题,该变量已发送到对话框组件。

我想要一个带有选项的对话框。有关于用户的信息(用户数据编辑)。ManageUsers 类具有 UserDAO selectedUser 属性,UserDAO 类包含用户 POJO(登录、电子邮件等)。
ManageUsers.updateUser 将数据保存在数据库中。

如何通过 inputText 更新 selectedUser?我无法使用 p:inplace 组件,因为我的 h:formsfacelets 存在问题(更改到生产阶段并不能解决此问题)。

玻璃鱼:3.1
Primefaces:2.2
JSF:2.1(现在是 MyFaces 2.1.3)

<h:form prependId="false"> 

<p:growl id="growl"/>

<!-- Data table with all users-->
<p:dataTable id="userTable" var="u" value="#{manageUsers.users}">

<p:column headerText="login" style="width:150px" filterBy="#{u.user.login}" filterMatchMode="contains">
<h:outputText value="#{u.user.login}" />
</p:column>

<p:column headerText="email" style="width:150px" filterBy="#{u.user.email}" filterMatchMode="contains">
<h:outputText value="#{u.user.email}" />
</p:column>

<p:column headerText="apikey" style="width:150px" filterBy="#{u.user.apikey}" filterMatchMode="startsWith">
<h:outputText value="#{u.user.apikey}" />
</p:column>

<p:column headerText="Options" >
<p:commandButton update="display" oncomplete="userDialog.show()"
image="ui-icon ui-icon-search">
<f:setPropertyActionListener value="#{u}" target="#{manageUsers.selectedUser}" />
</p:commandButton>
</p:column>

</p:dataTable>

<!-- Dialog box with options-->
<p:dialog appendToBody="true" header="User Detail" widgetVar="userDialog" resizable="false"
width="500" showEffect="explode" hideEffect="explode" onCloseUpdate="growl,userTable">
<h:panelGrid id="display" columns="2" cellpadding="4">

<h:outputText value="Login" />
<p:inputText required="true" value="#{manageUsers.selectedUser.user.login}" />

<h:outputText value="Email" />
<p:inputText required="true" value="#{manageUsers.selectedUser.user.email}" />

<p:commandButton value="save and exit" action="#{manageUsers.updateUser}" update="growl,userTable" onclick="userDialog.hide()" />

</h:panelGrid>
</p:dialog>

</h:form>

Example view

最佳答案

PROBLEM RESOLVED. Setters was not fired. I don't know why, but when I remove appendToBody="true", then setters work perfectly. Anyone know why?

setter 没有被触发,因为将 appendToBody 设置为 true 可能会导致对话框脱离表单> 组件。来自 Primefaces 用户指南 (3.0.M4):

    Use appendToBody with care as the page definition and html dom would be different, for
example if dialog is inside an h:form component and appendToBody is enabled, on the browser
dialog would be outside of form and may cause unexpected results. In this case, nest a form inside
a dialog.

关于java - 从对话框中的数据表更改变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8274924/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com