I am using
JSF 1.1_01 (MyFaces 1.1), Spring 1.2, Ajax4Jsf.
The JSF application has h:selectOneMenu .
On change event of h:selectOneMenu sets "selectedValue" in backing bean as shown below:
------------------
page.jsp
-------------------
<h:selectOneMenu value="#{test.selectedDevice}" >
<f:selectItem itemValue="0" itemLabel="--New--"/>
<f:selectItem itemValue="1" itemLabel="WorkStation"/>
<f:selectItem itemValue="2" itemLabel="Router"/>
<f:selectItem itemValue="3" itemLabel="Switch"/>
<ajax:support action="#{test.loadDevice}" event="onchange" reRender="t2,t3,t4,t5"/>
</h:selectOneMenu>
-----------------------
TestBean.java (Backing Bean)
-----------------------
public
String getSelectedDevice() {
logger.info(" *** In getSelectedDevice *** ");
if (selectedDevice == null) {
selectedDevice = "0"; // This will be the default selected item.
}
return selectedDevice;
}
public void setSelectedDevice(String selectedDevice) {
logger.info(" *** In setSelectedDevice *** ");
this.selectedDevice = selectedDevice;
}
Here are the configuration files for integrating JSF Spring
-------------
web.xml
-------------
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
---------------------------
faces-config.xml
---------------------------
<application>
<variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
</application>
<managed-bean>
<managed-bean-name>
test</managed-bean-name>
<managed-bean-class>test.TestBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>deviceManager</property-name>
<property-class> test.DeviceTypeManager </property-class>
<value>#{deviceManager}</value>
</managed-property>
</managed-bean>
The above code results in the following error
javax.faces.FacesException: Cannot get value for expression '#{test.selectedDevice}'
The error occurs only if i include <managed-property> inside the <managed-bean> in faces-config.xml.
The moment i remove <managed-property> from face-config.xml the error disappears & page gets rendered properly.
The purpose in using <managed-property> is to integrate JSF with Spring i.e. calling deviceManager
Any pointers/suggestions in resolving the error will be highly appreciated
Regards
Bansi