You probably meant to use @ManagedProperty
. This isn't useable on a view scoped bean to set a request parameter, because the view scope is of a broader scope than the request scope.
The canonical JSF2 way of passing request parameters and invoking actions on them would be something like the following:
view.xhtml
view:
<h:link value="Edit" outcome="edit">
<f:param name="id" value="#{item.id}" />
</h:link>
edit.xhtml
view:
<f:metadata>
<f:viewParam name="id" value="#{edit.id}" />
<!-- You would normally also convert/validate it here. -->
<f:event type="preRenderView" listener="#{edit.init}" />
</f:metadata>
Edit
backing bean:
@ManagedBean
@ViewScoped
public class Edit {
private Long id;
public void init() {
// This method will be invoked after the view parameter is set.
}
// ...
}
See also: