Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JSF javax.servlet.ServletException: Cannot get value for expression '#{customerService.dummyString}'

Reply
Thread Tools

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

 
 
alexjaquet@gmail.com
Guest
Posts: n/a
 
      06-18-2006
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.DelegatingVariableReso lver
</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

 
Reply With Quote
 
 
 
 
Frank Langelage
Guest
Posts: n/a
 
      06-18-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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.DelegatingVariableReso lver
> </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()
 
Reply With Quote
 
 
 
 
JeremyStein JeremyStein is offline
Junior Member
Join Date: Aug 2006
Posts: 1
 
      08-25-2006
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>
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" Adem C++ 42 11-04-2008 12:39 PM
more JSF woes Cannot get value for expression timasmith@hotmail.com Java 0 08-15-2006 07:47 PM
Include JSF page within another JSF page BlackIce Java 1 07-05-2006 11:24 PM
JSF debugging / JSF newsgroup Sebastian Fey Java 1 04-07-2006 08:52 PM
[JSF]Need to deploy a jsf application on SunApplicationServer. dudu Java 0 03-03-2006 12:09 PM



Advertisments