我正在爲我的應用程序使用JSF 1.2。<h:CommandButton>操作屬性在JSF 1.2中不起作用
在下面的代碼中,Account Details
按鈕的action屬性不起作用,即該方法沒有被調用,並且當我單擊該按鈕時沒有任何反應。
<h:panelGrid columns="2">
<h:outputLabel id="lblCustomerDetails" value="Details of CustomerId: "></h:outputLabel>
<h:outputText id="txtCustomerId" value="#{customerInfo.customerId }"></h:outputText>
<h:outputLabel id="lblCustomerName" value="Customer name: "></h:outputLabel>
<h:outputText id="txtCustomerName" value="#{customerInfo.customerNAme }"></h:outputText>
<h:outputLabel id="lblAccounts" value="Accounts: "></h:outputLabel>
<h:selectOneMenu id="drpdownAccounts">
<f:selectItems value="#{customerInfo.accounts }"/>
</h:selectOneMenu>
<h:outputLabel id="lblEmail" value="Email: "></h:outputLabel>
<h:outputText id="txtEmail" value="#{customerInfo.email }"></h:outputText>
<h:outputLabel id="lblAccountDetails" value="Select an account no. for details"></h:outputLabel>
<h:commandButton id="btnAcountDetails" value="Account Details" action="#{accountBean.accountDetails }"></h:commandButton>
<h:messages></h:messages>
</h:panelGrid>
下面是AccountBean
:
public class AccountBean {
private int accountNo;
private String customerName;
private double accountBalance;
private String accountType;
//Getters and setters
public String accountDetails(){
//Some logic and return
return "success";
}
}
這是目前在faces-配置外商投資企業管理bean:
<managed-bean>
<managed-bean-name>customerInfo</managed-bean-name>
<managed-bean-class>com.bean.CustomerInfo</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>accountBean</managed-bean-name>
<managed-bean-class>com.bean.AccountBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
有可能是somethng傻,我在代碼中失蹤但無法弄清楚,浪費了很多時間,因此想到發佈。指針是令人滿意的。
請排除此處列出的原因http://stackoverflow.com/questions/2118656/hcommandlink-hcommandbutton-is-not-being-invoked/2120 183#2120183第一個嫌疑犯:哪裏是''?你如何提交沒有表格的表單?然而,這在每個理智的JSF教程的第1章中都有介紹,所以它會有點太明顯的錯誤,表明對基本的HTML缺乏瞭解(在進入JSF之前最好先學習,因爲JSF最終基本上是「只是「一個HTML代碼生成器)。 –
BalusC
2013-04-11 03:30:08