JSF javax.servlet.ServletException: Cannot get value for expression '#{customerService.dummyString}'

A

alexjaquet

Hi,

I'm new to JSF/Spring/Hibernate and I got an error with a simple jsf
test :
javax.servlet.ServletException: Cannot get value for expression
'#{customerService.dummyString}'

In my jsp page I've put the following code :

<f:view>
<h:form>
<h:inputText value="#{customerService.dummyString}" rendered="true"
required="false" />
</h:form>
</f:view>

in my java class I've the following code :

public class CustomerGUI {

private CustomerService customerService;
private String dummyString;

public String getdummyString() {
return "dummyString";
}
public void setdummyString(String dummyString) {
this.dummyString = "dummyString";
}
public List<Customer> getAllCustomers () {
if (customerService != null) {
return customerService.getAllCustomers();
}else {
return null;
}
}

and my faces-config is the following :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD
JavaServer Faces Config 1.1//EN"
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">

<faces-config >
<application>
<variable-resolver>
org.springframework.web.jsf.DelegatingVariableResolver
</variable-resolver>

<locale-config>
<default-locale>en</default-locale>
<supported-locale>en</supported-locale>
<supported-locale>fr</supported-locale>
<supported-locale>de</supported-locale>
</locale-config>
</application>

<navigation-rule>
<from-view-id>/customerList.jsp</from-view-id>
</navigation-rule>
<navigation-rule>
<from-view-id>/customerDetails.jsp</from-view-id>
</navigation-rule>
<navigation-rule>
<from-view-id>/index.jsp</from-view-id>
<navigation-case>
<from-outcome>doIndex</from-outcome>
<to-view-id>/index.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>doCustomerList</from-outcome>
<to-view-id>/customerList.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<managed-bean>
<managed-bean-name>customerGui</managed-bean-name>
<managed-bean-class>
com.test.gui.CustomerGUI
</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>customerService</property-name>
<property-class>
com.test.business.CustomerServiceImp
</property-class>
<value>#customerService</value>
</managed-property>
</managed-bean>
</faces-config>

any idea ? thx for responding
 
F

Frank Langelage

Hi,

I'm new to JSF/Spring/Hibernate and I got an error with a simple jsf
test :
javax.servlet.ServletException: Cannot get value for expression
'#{customerService.dummyString}'

In my jsp page I've put the following code :

<f:view>
<h:form>
<h:inputText value="#{customerService.dummyString}" rendered="true"
required="false" />
</h:form>
</f:view>

in my java class I've the following code :

public class CustomerGUI {

private CustomerService customerService;
private String dummyString;

public String getdummyString() {
return "dummyString";
}
public void setdummyString(String dummyString) {
this.dummyString = "dummyString";
}
public List<Customer> getAllCustomers () {
if (customerService != null) {
return customerService.getAllCustomers();
}else {
return null;
}
}

and my faces-config is the following :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD
JavaServer Faces Config 1.1//EN"
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">

<faces-config >
<application>
<variable-resolver>
org.springframework.web.jsf.DelegatingVariableResolver
</variable-resolver>

<locale-config>
<default-locale>en</default-locale>
<supported-locale>en</supported-locale>
<supported-locale>fr</supported-locale>
<supported-locale>de</supported-locale>
</locale-config>
</application>

<navigation-rule>
<from-view-id>/customerList.jsp</from-view-id>
</navigation-rule>
<navigation-rule>
<from-view-id>/customerDetails.jsp</from-view-id>
</navigation-rule>
<navigation-rule>
<from-view-id>/index.jsp</from-view-id>
<navigation-case>
<from-outcome>doIndex</from-outcome>
<to-view-id>/index.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>doCustomerList</from-outcome>
<to-view-id>/customerList.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<managed-bean>
<managed-bean-name>customerGui</managed-bean-name>
<managed-bean-class>
com.test.gui.CustomerGUI
</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
<property-name>customerService</property-name>
<property-class>
com.test.business.CustomerServiceImp
</property-class>
<value>#customerService</value>
</managed-property>
</managed-bean>
</faces-config>

any idea ? thx for responding

Your managed bean's name is 'customerGui'.
So the expression has to start with "#{customerGui...}".
The managed property's name is 'customerService'.
So the expression is "#{customerGui.customerService}".
In the bean you'll have to provide a method with this signature:
public com.test.business.CustomerServiceImp getCustomerService()
 
Joined
Aug 25, 2006
Messages
1
Reaction score
0
Check web.xml

Also, make sure that Spring is set to start up in web.xml:
Code:
<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/path/to/applicationContext.xml</param-value>
</context-param>
<listener>
  <listener-class>
    org.springframework.web.context.ContextLoaderListener
  </listener-class>
</listener>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top