【发布时间】:2012-12-14 05:18:04
【问题描述】:
我已将primefaces-3.4RC1.jar 包含在WEB-INF/lib 目录中。在我的控制器中,我像
@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'。
【问题讨论】:
-
我认为你需要用 @ManagedBean 和一些范围注释 MyController,然后你需要一个获取 loc 的方法
-
@AkselWillgert 我已经编辑了问题以添加更多详细信息我已经用托管 bean 注释控制器并定义了范围
-
但是你有吸气剂吗?我认为也是一个错字:countryID vs countryId?
-
我已经删除了错字,即使我已经自动装配了成员,我是否还需要 getter 和 setter?顺便说一句,我刚刚尝试从
loc中删除@Autowired注释并定义了它的getter 和setter,没有运气 -
在上面的帖子中你不应该用
@Autowired注释Location loc。你应该用@ManagedProperty注释。改变它应该可以正常工作。
标签: eclipse jsf jsf-2 primefaces glassfish-3