0

I'm trying to do a commandLink that shows more details about an object (I'm in a foreach tag)

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

This is my 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";
}

And this is my 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> 

But I get this error:

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

Why? I think I don't set well the property-name in faces-config-xml, so what should I put in it?

Min
  • 29
  • 6
  • possible duplicate http://stackoverflow.com/questions/11755679/jsf-property-references-object-in-a-scope-with-shorter-lifetime-than-the-target – Omar Jun 02 '14 at 09:27
  • I don't use a viewParam... I would like to know what should I put on my faces-config.xml, the other code is surely correct – Min Jun 02 '14 at 09:33
  • Try to change the managed-bean's scope to be `@RequestScoped`. – Omar Jun 02 '14 at 09:48
  • I suggest to use only the annotations feature and to abandon the `faces-config.xml` file. Then clean,build and run the project again. – Omar Jun 02 '14 at 10:21

0 Answers0