首页 > 解决方案 > 如果对象的引用发生更改,Ajax 渲染将不起作用

问题描述

当对象用户使用新引用更改时,不会渲染 render="form01:name" 但是当我使用来自服务的数据将名称设置到现有对象时,它可以工作。你能告诉我为什么吗。

<h:inputText id="username" styleClass="form-control "
     value="#{inscription.user.username}" />
</h:inputText>

<h:commandLink role="button" styleClass="btn btn-primary" id="" render="true" title="title">
    <f:ajax listener="#{inscription.loadData(inscription.user)}" execute="username" 
    render="form01:name"/>
</h:commandLink>
User user = new User();

public void loadData(User user) {
     // this.user is remplace with an User from the service, the render doesn't works
     this.user = userService.getUser(user.getUsername)); ---> not working
     //---------------------
     // if I remplace the code above with this code, the render works
     User u = userService.getUser(user.getUsername));      
     this.user.setName(u.getName()); ---> working
}

标签: jsf

解决方案


推荐阅读