Primefaces ajax在页面导航JPA持久性之后没有从commandlink触发请求事件

时间:2016-01-21 13:54:46

标签: jquery ajax jsf jsf-2 primefaces

此问题是与Primefaces ajax not updating panel or panelGrid component in the same form

相关的MCVE

应用程序在两个JSF页面之间导航。第一个是用户注册表单,该表单持久保存新用户(Reg.xhtml)并导航到用户填写新配置文件的用户配置文件页面(UserProfile.xhtml)。

问题发生在UserProfile.xhtml中,其中ajax操作意味着触发一个面板,该面板显示用户在保留配置文件之前输入的值。在单击以触发ajax事件后,似乎没有触发ajax请求,并且验证用户输入的表单是空白的。 MCVE JSF和bean代码用于模拟从注册到配置文件页面的导航:

Reg.xhtml:

    <h:form id="newuser">

                        <p:commandLink id="makefinal" value="Navigate"     
                                   action="#{userBean.makeUser}"
                                   ajax="false"/>
            </h:form>


@Named(value = "userBean")
@SessionScoped
public class UserBean implements Serializable {


public String makeUser() {

    return "/Main/Users/UserProfile";
}

}

导航配置文件页面的JSF和bean代码(其中java操作的实际问题无法执行):

个人资料实体和表格:

@Entity
public class Enprofile implements Serializable {
@Id
private String firstname;
@Temporal(TemporalType.DATE)
private Date dateofbirth;

public Enprofile() {
}

   public Enprofile(String firstname, Date dateofbirth) {
   this.firstname = firstname;
   this.dateofbirth = dateofbirth;
   }
  }

 <h:form id="proform">

                <p:panelGrid id="userpro" columns="2">


                    <p:outputLabel value="First Name:"/>
                    <p:inputText value="#{profileBean.proFirstName}"/>


                    <p:outputLabel value="Date of Birth:"/>
                    <p:calendar value="#{profileBean.dateofbirth}"/>

                     <p:commandLink id="make" value="Create"
                                    action="#{profileBean.checkProfile}"
                              process="userpro make"
                              update="usercheck"/>

                </p:panelGrid>

                <p:panelGrid id="usercheck" columns="2">


                    <p:outputLabel value="#{profileBean.newPro.firstname}"/>
                    <p:outputLabel value="#{profileBean.newPro.dateofbirth}"/>

                </p:panelGrid>

            </h:form>

个人资料bean代码:

@Named(value = "profileBean")
@RequestScoped
public class ProfileBean {

private Enprofile newPro;

public void checkProfile() {
    newPro = new Enprofile(firstName, dateofbirth);

    firstName = getFirstname();
    newPro.setFirstname(firstname);

    dateofbirth = getDateofbirth();
    newPro.setDateofbirth(dateofbirth);

}
}

我无法使用上面的代码重现问题,如果页面运行没有持久操作(使用标准页面导航),它可以很好地工作。如果存在先前的持久操作(即:创建新用户然后导航到配置文件页面),则视图状态似乎以某种方式丢失,并且第二页(配置文件页面)上的ajax功能已经死亡。 < / p>

0 个答案:

没有答案