0
我有一些代碼的麻煩。現在我嘗試修改/刪除個人信息,但我輸入了一個無效的值嘗試修改/刪除,它仍然彈出一個新窗口。我不知道如何修改這些代碼,因爲我輸入了一個無效的值,它不會彈出一個窗口。 我還有其他問題。當我輸入一個有效值時,值不能傳遞到彈出窗口,就像我輸入一個名稱以獲取id值,該值不能傳遞到彈出窗口,我該如何重新使用它。謝謝大家!JSF2無法將值傳遞到新的彈出窗口
HTML
<h:panelGrid columns="3" cellspacing="20">
<h:outputLabel for="name" value="Modify Name"/> <p:inputText value="#{modify.enName}"/>
<h:commandButton value="Modify System" style="height:35px" onclick="window.open('#{modify.domodify()}','modify',
'width=500,height=400,status=yes,resizable=yes,scrollbars=yes') ; return false;"/>
</h:panelGrid>
Java代碼的
public String domodify() {
try {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("com.mycompany_SuneCoolingSystem_war_1.0-SNAPSHOTPU");
EmployeeJpaController jpaController = new EmployeeJpaController(null, emf);
EntityManager e = jpaController.getEntityManager();
Query q = e.createNamedQuery("Employee.findByEnName");
q.setParameter("enName", getEnName());
System.out.println(getEnName());
List resultList = q.getResultList();
Employee result = (Employee) resultList.get(0);
id = result.getId();
name = result.getName();
idNumber = result.getIdNumber();
constellation = result.getConstellation();
email = result.getEmail();
enName = result.getEnName();
rego="CRUD/Modify.xhtml";
} catch (Exception ex) {
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN, "No Man", ""));
rego = "index.xhtml";
}
return rego;
}