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

Discussion in 'Java' started by alexjaquet@gmail.com, Jun 18, 2006.

  1. Guest

    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
    , Jun 18, 2006
    #1
    1. Advertising

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

    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.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()
    Frank Langelage, Jun 18, 2006
    #2
    1. Advertising

  3. JeremyStein

    Joined:
    Aug 25, 2006
    Messages:
    1
    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>
    JeremyStein, Aug 25, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pia
    Replies:
    0
    Views:
    518
  2. HARI OM
    Replies:
    0
    Views:
    9,346
    HARI OM
    May 4, 2005
  3. Replies:
    0
    Views:
    3,596
  4. Dix
    Replies:
    0
    Views:
    11,886
  5. Replies:
    5
    Views:
    2,258
Loading...

Share This Page