我正在項目中使用JSF primefaces和Hibernate。我已經使用了primefaces佈局單元。 當我點擊一個menuitem它更新panel.But當我嘗試從一個託管的bean執行一個方法,它什麼都不做。沒有錯誤信息也。命令按鈕操作在primefaces + hibernate應用程序中不起作用
託管bean中的代碼是:
@ManagedBean(name = "customerDetails")
@SessionScoped
@Entity
@Table(name = "CUSTOMER")
public class CustomerDetailsBean implements Serializable {
@Id
@GeneratedValue
@Column(name = "ID")
private long customerId;
@Column(name = "NAME")
private String customerName;
@Column(name = "DOB")
private Date DOB;
@Column(name = "ORG_NAME")
private String organizationName;
@Column(name = "MOBILE")
private String mobile;
@Column(name = "BEST_TIME_CALL")
private String bestTimeToCall;
@Column(name = "PROD_CAT")
private String productCategory;
@Column(name = "PROD")
private String product;
@Column(name = "REF_SRC")
private String referralSource;
@Column(name = "TELE_NAME")
private String telesalesName;
@Column(name = "TELE_CODE")
private String telesalesCode;
@Embedded
@ManagedProperty(value = "#{customerAddressDetails}")
private CustomerAddressDetailsBean addressDetailsBean;
@Embedded
@ManagedProperty(value = "#{customerLoanDetails}")
private CustomerLoanDetailsBean loanDetailsBean;
public String getCustomerName() {
return customerName;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
System.out.println(customerName);
}
public Date getDOB() {
return DOB;
}
public void setDOB(Date dOB) {
DOB = dOB;
}
public String getOrganizationName() {
return organizationName;
}
public void setOrganizationName(String organizationName) {
this.organizationName = organizationName;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getProductCategory() {
return productCategory;
}
public void setProductCategory(String productCategory) {
this.productCategory = productCategory;
}
public String getProduct() {
return product;
}
public void setProduct(String product) {
this.product = product;
}
public String getReferralSource() {
return referralSource;
}
public void setReferralSource(String referralSource) {
this.referralSource = referralSource;
}
public String getTelesalesName() {
return telesalesName;
}
public void setTelesalesName(String telesalesName) {
this.telesalesName = telesalesName;
}
public String getTelesalesCode() {
return telesalesCode;
}
public void setTelesalesCode(String telesalesCode) {
this.telesalesCode = telesalesCode;
}
public String getBestTimeToCall() {
return bestTimeToCall;
}
public void setBestTimeToCall(String bestTimeToCall) {
this.bestTimeToCall = bestTimeToCall;
}
public long getCustomerId() {
return customerId;
}
public void setCustomerId(long customerId) {
this.customerId = customerId;
}
public CustomerAddressDetailsBean getAddressDetailsBean() {
return addressDetailsBean;
}
public void setAddressDetailsBean(CustomerAddressDetailsBean addressDetailsBean) {
this.addressDetailsBean = addressDetailsBean;
}
public CustomerLoanDetailsBean getLoanDetailsBean() {
return loanDetailsBean;
}
public void setLoanDetailsBean(CustomerLoanDetailsBean loanDetailsBean) {
this.loanDetailsBean = loanDetailsBean;
}
public String insertCustomer() {
System.out.println("inserting Customer");
return "Login";
}
}
而對於XHTML代碼:
<p:commandButton id="btnSearch1" value="Search" type="Submit" action="#{customerDetails.insertCustomer}" update=":Centerform:Masters"/>
您已經添加了''某處在網頁上? –
雅我添加了每個輸入字段。但沒有提交時看到的錯誤消息。 – user2857867
你的p:commandButton是否在表單內? – Ioan