0

我现在挣扎了整整一个星期,但没有得到它的工作。用户对象没有得到更新......这是重要的 xhtml 部分:

<p:dataTable id="usersTable" var="user" value="#{userBean.allUsers}">  
<p:ajax event="rowToggle" listener="#{userBean.onRowToggle}" update=":form_user_management:tabView_viewUsers:messages" />  
<f:facet name="header">  
    User
</f:facet>  

<p:rowExpansion>  
    <h:panelGrid id="display" columns="2" cellpadding="10" style="width:300px;"  
                 styleClass=" ui-widget-content grid">  

        <p:panel id="panel" header="Benutzer bearbeiten">

            <p:messages id="msgs"/>

            <h:panelGrid columns="3" >
                <h:outputLabel for="firstname" value="Firstname: *" />
                <p:inputText id="firstname" value="#{user.userFirstName}" required="true" label="Firstname">
                    <f:validateLength minimum="2" />
                </p:inputText>
                <p:message for="firstname" display="icon"/>

                <h:outputLabel for="surname" value="Surname: *" />
                <p:inputText id="surname" value="#{user.userLastName}" label="Surname" required="true">
                    <f:validateLength minimum="2" />
                    <p:ajax update="msgSurname" event="keyup" />
                </p:inputText>
                <p:message for="surname" id="msgSurname" display="icon"/>

                <p:commandLink id="changepw" value="Passwort ändern" onclick="dlg.show()" title="Passwort ändern">
                    <f:setPropertyActionListener value="#{user}" target="#{userBean.currentUser}" />
                </p:commandLink>

                <p:commandButton ajax="true" id="btnUpdateUser" value="Update" update=":form_user_management @all" actionListener="#{userBean.updateUser(user)}"/>
                <p:commandButton ajax="true" id="btnDeleteUser" value="Delete" update=":form_user_management" actionListener="#{userBean.deleteUser(user)}"/>  

            </h:panelGrid> 
        </p:panel>  
    </h:panelGrid>
</p:rowExpansion>  

当我单击“保存”时,展开的行消失了,但没有显示新值,Java 方法“userBean.updateUser(user)”只获取用户对象的旧值。

UserBean 的头部是:

@Named
@SessionScoped
public class UserBean implements Serializable {

SessionScoped 来自 javax.enterprise.context

我也尝试使用旧的 @ManagedBean 东西,但这也没有帮助。我认为问题出在 xhtml 文件和 ajax 文件中......哦,我使用了其他模板文件。

使用 Primefaces 3.4 和 Glassfish 3+

Full UserBean: http://pastebin.com/yQCgiM4E Full Xhtml: http://pastebin.com/19TWt3Dv (line 110 is the interesting thing)

4

1 回答 1

0

Ok my mate solved the problem himself by adding return action.getActionEvent()+"?faces-redirect=true";

in the action attribute, like so<h:commandButton action="page1?faces-redirect=true" value="Page1" />

this solved the ajax-delay-shit

于 2013-04-04T00:36:04.443 回答