Jpa添加记录空

时间:2015-12-26 14:59:09

标签: java jsf jpa primefaces eclipselink

这是我的xhtml页面

`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

                <h:outputLabel for="password" value="Sifre: " />
                <p:password id="password" match="passwordAgain" feedback="false"
                    value="#{management.memberBean.password}" weakLabel="Zayif"
                    goodLabel="Orta seviye" strongLabel="Güçlü" required="true"
                    requiredMessage="Sifre Tanimlayin"
                    validatorMessage="Sifreler uyusmuyor">
                    <p:message for="password" />
                </p:password>

                <h:outputLabel for="passwordAgain" value="Sifre Tekrar: " />
                <p:password id="passwordAgain" required="true"
                    requiredMessage="Sifrenizi yeniden girin.">
                    <p:message for="passwordAgain" />
                </p:password>
                <p:commandButton value="KAYDET" update=":form2:uyeKaydetPanel"
                    action="#{management.addNewMember()}"></p:commandButton>
                <p:commandButton value="VAZGEÇ" onclick="PF('uyeOl').hide();">

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

` 这是控制器类。

public void addNewMember(Member member) {
    try {
        entityManager.getTransaction().begin();
        member.setName(member.getName());
        member.setSurname(member.getSurname());
        member.setBirthday("12/10/2015");
        member.setEmail(member.getEmail());
        member.setUsername(member.getUsername());
        member.setPassword(member.getPassword());
        member.setTel(member.getTel());
        entityManager.persist(member);
        entityManager.getTransaction().commit();
        System.out.println("ok");

    } catch (Exception e) {
        e.printStackTrace();
        entityManager.getTransaction().rollback();
        // TODO: handle exception
    } finally {
        entityManager.close();
        entityManagerFactory.close();
    }
}

我总是拿NullPointerException.I不明白为什么。请帮帮我???我可以达到方法。我控制调试模式成员是好的。但我收到错误信息。

0 个答案:

没有答案