f:param和ManagedProperty - 如何设置faces-config.xml

时间:2014-06-02 09:07:03

标签: java jsf javabeans param

我正在尝试使用commandLink来显示有关对象的更多详细信息(我在foreach标记中)

<h:commandLink
action="#{controller.findProduct}" value="#{p.name}">
<f:param name="id" value="#{p.id}" />
</h:commandLink>

这是我的ManagedBean

@ManagedBean
public class Controller {

@ManagedProperty(value="#{param.id}")
private Long id;
private String name;
    private Product product;
    ....
    public String findProduct() {
    this.product = facade.getProduct(id);
    return "details";
}

这是我的faces-config.xml

<managed-bean>
<managed-bean-name>controller</managed-bean-name>
<managed-bean-class>html.controller.Controller</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
    <property-name>id</property-name>
    <property-class>Long</property-class>
    <value>#{param.id}</value>
</managed-property>
</managed-bean> 

但是我收到了这个错误:

Property id references object in a scope with shorter lifetime than the target scope session

为什么呢?我想我没有在faces-config-xml中设置好属性名称,那么我应该把它放在哪里呢?

0 个答案:

没有答案