webtier@glassfish.java.net

Re: jsf 2 not work the inject a another bean with annotation ...

From: <forums_at_java.net>
Date: Sun, 17 Jul 2011 10:37:24 -0500 (CDT)

escuse me .

how i public the code and the  errors:

------------------------------------

my managedbeans:

//requestscoped:


-------------------------------------------------

package managed;

import entity.Customer;

import javax.enterprise.context.SessionScoped;

import javax.faces.bean.ManagedBean;

/**

*

* @author mauro

*/

@ManagedBean(name = "customerSession")

@SessionScoped

public class CustomerSession {

private Customer customer;

/** Creates a new instance of CustomerSession */

public CustomerSession() {

}

/**

* @return the customer

*/

public Customer getCustomer() {

return customer;

}

/**

* @param customer the customer to set

*/

public void setCustomer(Customer customer) {

this.customer = customer;

}

 

}

 

 

-------------------------------
An Error Occurred:

/index.xhtml @17,59 value="#{customerForm.name}": Target Unreachable,
identifier 'customerForm' resolved to null

javax.el.PropertyNotFoundException: /index.xhtml @17,59
value="#{customerForm.name}": Target Unreachable, identifier 'customerForm'
resolved to null

at
com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100)

at
com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95)

at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1030)

at javax.faces.component.UIInput.validate(UIInput.java:960)

at javax.faces.component.UIInput.executeValidate(UIInput.java:1233)

at javax.faces.component.UIInput.processValidators(UIInput.java:698)

at javax.faces.component.UIForm.processValidators(UIForm.java:253)

at
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)

at
javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1214)

at javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1172)

at
com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)

at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)

at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)

at
org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)

at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)

at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

at
org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)

at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)

at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)

at
com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)

at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)

at
org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)

at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)

at
com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)

at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)

at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)

at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)

at
com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)

at
com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)

at
com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)

at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)

at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)

at
com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)

at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)

at com.sun.grizzly.ContextTask.run(ContextTask.java:71)

at
com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)

at
com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)

at java.lang.Thread.run(Thread.java:619)

<UIViewRoot id="j_id1" inView="true" locale="it_IT" renderKitId="HTML_BASIC"
rendered="true" transient="false" viewId="/index.xhtml">

<?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Transitional//EN" "

 

http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd [1]">

<html xmlns="http://www.w3.org/1999/xhtml">

<UIOutput id="j_idt4" inView="true" rendered="true" transient="false">

<title>Facelet Title</title>

</UIOutput>

<UIOutput id="j_idt6" inView="true" rendered="true" transient="false">

crete new customer

<HtmlForm enctype="application/x-www-form-urlencoded" id="create"
inView="true" prependId="true" rendered="true" submitted="true"
transient="false">

Name:

<HtmlInputText disabled="false" id="namecustomer" immediate="false"
inView="true" localValueSet="false" maxlength="-2147483648" readonly="false"
rendered="true" required="true" size="-2147483648" submittedValue="pippo"
transient="false" valid="true"/>

<HtmlCommandButton action="#{customerForm.saveCustomerintodb}"
actionExpression="#{customerForm.saveCustomerintodb}" disabled="false"
id="submit" immediate="false" inView="true" readonly="false" rendered="true"
transient="false" type="submit" value="Create"/>

</HtmlForm>

</UIOutput>

</html>

</UIViewRoot>

----------------

Request ParametersName Value

create create

create:namecustomer pippo

create:submit Create

View AttributesName Value

None

Request AttributesName Value

None

Flash AttributesName Value

None

Session AttributesName Value

None

Application AttributesName Value

csfcff com.sun.faces.context.flash.ELFlash_at_b16391

package managed;

import ejb.CustomerFacade;

import entity.Customer;

 

import javax.ejb.EJB;

import javax.faces.bean.ManagedBean;

import javax.faces.bean.ManagedProperty;

import javax.faces.bean.RequestScoped;

/**

*

* @author mauro

*/

@ManagedBean(name = "customerForm")

@RequestScoped

public class CustomerForm {

@EJB

private CustomerFacade customerFacade;

private String name;

@ManagedProperty(value="#{customerSession}")

private CustomerSession customerSession;

/** Creates a new instance of CustomerForm */

public CustomerForm() {

}

/**

* @return the name

*/

public String getName() {

return name;

}

/**

* @param name the name to set

*/

public void setName(String name) {

this.name = name;

}

/**

* @return the customerSession

*/

public CustomerSession getCustomerSession() {

return customerSession;

}

/**

* @param customerSession the customerSession to set

*/

public void setCustomerSession(CustomerSession customerSession) {

this.customerSession = customerSession;

}

 

public String saveCustomerintodb(){

Customer newcustomer= new Customer();

newcustomer.setName(name);

Customer customersaved= this.customerFacade.saveCustomer(newcustomer);

this.customerSession.setCustomer(customersaved);

return "viewcustomer";

 

}

}


[1] http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd

--
[Message sent by forum member 'mauro2011']
View Post: http://forums.java.net/node/823175