@ManagedProperty is not the right tool for the job of converting a submitted value and setting it as a bean property. HTTP request parameters are inherently strings. Better use <f:viewParam>, you can attach a converter to it like as you would do to <h:inputText>.
Source page:
<h:link value="Consulter Détails" outcome="question"> <f:param name="quesId" value="#{quests.quesPk}" /> </h:link> Target page (question.xhtml):
<f:metadata> <f:viewParam name="quesId" value="#{questionBean.quesPk}" converter="javax.faces.Long" /> </f:metadata> With
private Long quesPk; // +setter ###See also:
- ViewParam vs @ManagedProperty(value = "#{param.id}")ViewParam vs @ManagedProperty(value = "#{param.id}")
- What can <f:metadata>, <f:viewParam> and <f:viewAction> be used for?What can <f:metadata>, <f:viewParam> and <f:viewAction> be used for?
Unrelated to the concrete problem, doing business logic in getter methods is a bad idea. Don't do that. Use <f:event type="preRenderView"> or <f:viewAction> listener method.
###See also: