我正在开发 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 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;
}
}
xhtml页面
<h:form id="hidden" style="display:none">
<h:commandLink id="link">
<f:ajax event="click" listener="#{customer.getCustomerDetails}"/>
</h:commandLink>
</h:form>
面孔-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>
建议我如何解决这个问题。