我已将primefaces-3.4RC1.jar
添加到WEB-INF/lib
目录中。在我的控制器中我自动装配我的模型bean,如
@ManagedBean
@RequestScoped
public class MyController{
@Autowired
Location loc;
//other stuff
}
我的Location
课程类似于
public class Location{
private Integer countryId;
//getters setters
}
我的观点看起来像
<?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">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<div class="contentBox cornerBorder border">
<p:dialog>
<table class="DialogTable">
<tr>
<td><label>Country</label></td>
<h:selectOneMenu required="true" id="contry" styleClass="text-box" value="#{myController.loc.countryId}">
----------------------------------------------------------------------------------------------^here it gives warning and if i run it crashes
</tr>
</table>
</p:dialog>
当我点击链接打开对话框时,会抛出错误,找不到属性countryId
。如果我删除value="myController.loc.countryId"
它运行正常...
任何指导我正确方向的人
P.S:我已在应用程序context.xml
中创建了相应的条目实际错误
严重:javax.el.PropertyNotFoundException: /WebPages/personal/personalDiv.xhtml @ 230,119 value =“#{myController.loc.countryId}”:该类 'com.deltasoft.controller.myController'没有该属性 'LOC'。
答案 0 :(得分:1)
您可能希望像这样更改代码。
@ManagedBean
@RequestScoped
public class MyController{
@ManagedProperty
private Location loc; // Getters and Setters.
//other stuff
}
和
@component
public class Location{
private Integer countryId;
//getters setters
}
并在你的spring.xml中你应该做
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan="path to Location class path"/>
</beans>