Eclipse PrimeFaces 3.4 RC1,对话框未识别托管Bean属性

Eclipse PrimeFaces 3.4 RC1,对话框未识别托管Bean属性,eclipse,jsf,jsf-2,primefaces,glassfish-3,Eclipse,Jsf,Jsf 2,Primefaces,Glassfish 3,我已经将primefaces-3.4RC1.jar包含在WEB-INF/lib目录中。在我的控制器中,我像豆子一样自动连接我的模型 @ManagedBean @RequestScoped public class MyController{ @Autowired Location loc; //other stuff } 我的位置类看起来像 public class Location{ private Integer countryId; //getters s

我已经将
primefaces-3.4RC1.jar
包含在
WEB-INF/lib
目录中。在我的控制器中,我像豆子一样自动连接我的模型

@ManagedBean
@RequestScoped
public class MyController{

@Autowired
Location loc;

//other stuff

}
我的
位置
类看起来像

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>
我的看法是

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”
它运行正常。。。 有人能指引我正确的方向吗

注意:我已经在applicationcontext.xml中创建了适当的条目


实际误差

严重:javax.el.PropertyNotFoundException: /网页/personal/personalDiv.xhtml@230119 value=“#{myController.loc.countryId}”:类 “com.deltasoft.controller.myController”没有该属性 “loc”


您可能希望像这样更改代码

@ManagedBean
@RequestScoped
public class MyController{

@ManagedProperty
private Location loc;   // Getters and Setters.

//other stuff

}

在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>

您可能希望像这样更改代码

@ManagedBean
@RequestScoped
public class MyController{

@ManagedProperty
private Location loc;   // Getters and Setters.

//other stuff

}

在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>


我认为您需要使用@ManagedBean和一些作用域对MyController进行注释,然后您需要一个getter来loc@AkselWillgert我已经编辑了这个问题以添加更多细节,我已经用托管bean注释了控制器并定义了作用域,但是你有getter吗?我想还有一个输入错误:countryID vs countryID?我已经删除了输入错误,即使我已经自动连接了成员,我是否也需要getter和setter?顺便说一下,我刚刚尝试从
loc
中删除
@Autowired
注释,并定义了它的getter和setter,不,luckIn在上面的帖子中,你不应该用
@Autowired
注释
位置loc
。你应该用
@ManagedProperty
注释。更改它,它应该可以正常工作。我想你需要用@ManagedBean和一些范围注释MyController,那你就需要一个吸气剂loc@AkselWillgert我已经编辑了这个问题以添加更多细节,我已经用托管bean注释了控制器并定义了作用域,但是你有getter吗?我想还有一个输入错误:countryID vs countryID?我已经删除了输入错误,即使我已经自动连接了成员,我是否也需要getter和setter?顺便说一下,我刚刚尝试从
loc
中删除
@Autowired
注释,并定义了它的getter和setter,不,luckIn在上面的帖子中,你不应该用
@Autowired
注释
位置loc
。你应该用
@ManagedProperty
注释。更改它,它应该可以正常工作。我需要定义托管道具的getter和setter吗?是的。这就像
@Autowired
一样,但是
Autowired
是将spring bean注入到另一个spring定义的bean中。而
ManagedProperty
是将Spring或JSF创建的bean注入JSF
@ManagedBean
。我需要定义托管属性的getter和setter吗?是的。这就像
@Autowired
一样,但是
Autowired
是将spring bean注入到另一个spring定义的bean中。而
ManagedProperty
是将Spring或JSF创建的bean注入JSF
@ManagedBean