Java 即使托管bean包含方法,抛出消息as的服务器也没有属性';获取客户详细信息';
iam正在处理JSF应用程序,甚至认为托管bean具有该方法,但服务器将消息作为 下面是托管bean代码Java 即使托管bean包含方法,抛出消息as的服务器也没有属性';获取客户详细信息';,java,jsf,Java,Jsf,iam正在处理JSF应用程序,甚至认为托管bean具有该方法,但服务器将消息作为 下面是托管bean代码 package retail.web.mbean; import java.io.Serializable; import java.util.List; import java.util.Properties; import javax.faces.bean.ManagedBean; import javax.faces.event.AjaxBehaviorEvent; import
package retail.web.mbean;
import java.io.Serializable;
import java.util.List;
import java.util.Properties;
import javax.faces.bean.ManagedBean;
import javax.faces.event.AjaxBehaviorEvent;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import retail.ejb.service.CustomerSessionBeanRemote;
import retail.model.vo.Customer;
@ManagedBean
public class CustomerMB implements Serializable{
/**
*
*/
private static final long serialVersionUID = -4402277663508618618L;
private Customer customer = new Customer();
public void CustomerMB(){
System.out.println("customer method +++++++++++++++++++++++"+getCustomer());
}
private List<Customer> customerList;
public Customer getCustomer() {
return customer;
}
public void setCustomer(Customer customer) {
this.customer = customer;
}
public List<Customer> getCustomerList() {
return customerList;
}
public void setCustomerList(List<Customer> customerList) {
this.customerList = customerList;
}
public String createCustomer() throws NamingException{
try{
System.out.println("in Create customer method +++++++++++++++++++++++");
Properties p = new Properties();
//p.put("java.naming.factory.initial","com.sun.jndi.cosnaming.CNCtxFactory");
p.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.impl.SerialInitContextFactory");
p.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
p.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
p.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
p.setProperty("org.omg.CORBA.ORBInitialPort", "3700"); //any configured port different from 3700 - 34513
InitialContext c = new InitialContext(p);
System.out.println("in Create customer method remote+++++++++++++++++++++++");
CustomerSessionBeanRemote remote = (CustomerSessionBeanRemote) c.lookup("java:global/RetailProducts/CustomerSessionBeanImpl!retail.ejb.service.CustomerSessionBeanRemote");
//java:global/RetailService/CustomerSessionBeanImpl!retail.ejb.service.CustomerSessionBeanRemote
//java:global/RetailProducts/CustomerSessionBeanImpl!retail.ejb.service.CustomerSessionBeanRemote
System.out.println("in Create customer method remote222+++++++++++++++++++++++");
remote.insterCustomerDetails(getCustomer());
remote.showCustDetails();
}catch(Exception e){
e.printStackTrace();
}
//System.exit(1);
return "viewCustomerDetails";
}
public void getCustomerDetails(AjaxBehaviorEvent event){
//List<Customer> customer = null;
try{
System.out.println("in Create customer method +++++++++++++++++++++++");
Properties p = new Properties();
//p.put("java.naming.factory.initial","com.sun.jndi.cosnaming.CNCtxFactory");
p.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.impl.SerialInitContextFactory");
p.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
p.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
p.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
p.setProperty("org.omg.CORBA.ORBInitialPort", "3700"); //any configured port different from 3700 - 34513
InitialContext c = new InitialContext(p);
System.out.println("in Create customer method remote+++++++++++++++++++++++");
CustomerSessionBeanRemote remote = (CustomerSessionBeanRemote) c.lookup("java:global/RetailProducts/CustomerSessionBeanImpl!retail.ejb.service.CustomerSessionBeanRemote");
//java:global/RetailService/CustomerSessionBeanImpl!retail.ejb.service.CustomerSessionBeanRemote
//java:global/RetailProducts/CustomerSessionBeanImpl!retail.ejb.service.CustomerSessionBeanRemote
System.out.println("in Create customer method remote222+++++++++++++++++++++++");
//remote.insterCustomerDetails(getCustomer());
//customer = remote.showCustDetails();
setCustomerList(remote.showCustDetails());
}catch(Exception e){
e.printStackTrace();
}
//System.exit(1);
// return customer;
}
}
package retail.web.mbean;
导入java.io.Serializable;
导入java.util.List;
导入java.util.Properties;
导入javax.faces.bean.ManagedBean;
导入javax.faces.event.AjaxBehaviorEvent;
导入javax.naming.Context;
导入javax.naming.InitialContext;
导入javax.naming.NamingException;
导入retail.ejb.service.CustomerSessionBeanRemote;
进口零售.model.vo.Customer;
@ManagedBean
公共类CustomerMB实现了可序列化{
/**
*
*/
私有静态最终长serialVersionUID=-4402277663508618618L;
私人客户=新客户();
public void CustomerMB(){
System.out.println(“客户方法+getCustomer());
}
私人名单客户名单;
公共客户getCustomer(){
退货客户;
}
公共作废设置客户(客户){
this.customer=customer;
}
公共列表getCustomerList(){
返回客户列表;
}
public void setCustomerList(列表customerList){
this.customerList=customerList;
}
公共字符串createCustomer()引发NamingException{
试一试{
System.out.println(“in-Create-customer方法+;
属性p=新属性();
//p、 put(“java.naming.factory.initial”、“com.sun.jndi.cosnaming.CNCtxFactory”);
p、 setProperty(“java.naming.factory.initial”、“com.sun.enterprise.naming.impl.SerialInitContextFactory”);
p、 setProperty(“java.naming.factory.url.pkgs”、“com.sun.enterprise.naming”);
p、 setProperty(“java.naming.factory.state”、“com.sun.corba.ee.impl.presentation.rmi.jndistratefactorympl”);
p、 setProperty(“org.omg.CORBA.ORBInitialHost”、“localhost”);
p、 setProperty(“org.omg.CORBA.ORBInitialPort”,“3700”);//任何不同于3700-34513的配置端口
InitialContext c=新的InitialContext(p);
System.out.println(“in-Create-customer-method-remote+;
CustomerSessionBeanRemote=(CustomerSessionBeanRemote)c.lookup(“java:global/RetailProducts/CustomerSessionBeanImpl!retail.ejb.service.CustomerSessionBeanRemote”);
//java:global/RetailService/CustomerSessionBeanImpl!retail.ejb.service.CustomerSessionBeanRemote
//java:global/RetailProducts/CustomerSessionBeanImpl!retail.ejb.service.CustomerSessionBeanRemote
System.out.println(“in-createcustomer方法remote222++++++++”;
remote.insterCustomerDetails(getCustomer());
remote.showCustDetails();
}捕获(例外e){
e、 printStackTrace();
}
//系统出口(1);
返回“viewCustomerDetails”;
}
public void getCustomerDetails(AjaxBehaviorEvent事件){
//列表客户=null;
试一试{
System.out.println(“in-Create-customer方法+;
属性p=新属性();
//p、 put(“java.naming.factory.initial”、“com.sun.jndi.cosnaming.CNCtxFactory”);
p、 setProperty(“java.naming.factory.initial”、“com.sun.enterprise.naming.impl.SerialInitContextFactory”);
p、 setProperty(“java.naming.factory.url.pkgs”、“com.sun.enterprise.naming”);
p、 setProperty(“java.naming.factory.state”、“com.sun.corba.ee.impl.presentation.rmi.jndistratefactorympl”);
p、 setProperty(“org.omg.CORBA.ORBInitialHost”、“localhost”);
p、 setProperty(“org.omg.CORBA.ORBInitialPort”,“3700”);//任何不同于3700-34513的配置端口
InitialContext c=新的InitialContext(p);
System.out.println(“in-Create-customer-method-remote+;
CustomerSessionBeanRemote=(CustomerSessionBeanRemote)c.lookup(“java:global/RetailProducts/CustomerSessionBeanImpl!retail.ejb.service.CustomerSessionBeanRemote”);
//java:global/RetailService/CustomerSessionBeanImpl!retail.ejb.service.CustomerSessionBeanRemote
//java:global/RetailProducts/CustomerSessionBeanImpl!retail.ejb.service.CustomerSessionBeanRemote
System.out.println(“in-createcustomer方法remote222++++++++”;
//remote.insterCustomerDetails(getCustomer());
//customer=remote.showCustDetails();
setCustomerList(remote.showCustDetails());
}捕获(例外e){
e、 printStackTrace();
}
//系统出口(1);
//退货客户;
}
}
xhtml页面
<h:form id="hidden" style="display:none">
<h:commandLink id="link">
<f:ajax event="click" listener="#{customer.getCustomerDetails}"/>
</h:commandLink>
</h:form>
faces config.xml
<managed-bean>
<managed-bean-name>customer</managed-bean-name>
<managed-bean-class>retail.web.mbean.CustomerMB</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
顾客
retail.web.mbean.CustomerMB
一场
建议我如何解决这个问题。我以前从未使用过人脸。 我认为问题在于你如何尝试访问你的方法。。。 试着改变
<f:ajax event="click" listener="#{customer.getCustomerDetails}"/>
到
或者(如果脸有魔力的话)
您的代码是有效的。异常只是表明EL表达式被解释为模板文本的一部分,就像在
{customer.getCustomerDetails}中一样。在呈现页面期间,表达式只是作为值表达式而不是方法表达式进行计算。值表达式需要getter方法,但在特定情况下不存在该方法
这反过来表明
名称空间没有注册,因此
不会被解释为标记,而是被解释为“普通HTML”
要修复此问题,请确保在XML根元素中包含JSF核心XML命名空间声明:
xmlns:f="http://java.sun.com/jsf/core"
与具体问题无关,您在类中混合了@ManagedBean
,在faces config.xml中混合了
<f:ajax event="click" listener="#{customer.customerDetails}"/>
xmlns:f="http://java.sun.com/jsf/core"