我正在为我的应用程序使用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