I have AAA.jsf page with link:
<h:link value="To BBB" outcome="BBB">
<f:param name="id" value="10"/>
</h:link>
BBB.jsf:
<html>
<h:body>
<f:metadata>
<f:viewParam name="id"/>
</f:metadata>
<h:form>
<h:outputText value="#{bean.id}"/>
<h:commandButton value="Make some logic.." action="bean.doSomething"/>
</h:form>
</h:body>
</html>
Bean.class:
@ManagedBean
@ViewScoped
class Bean{
public String getId(){
Map<String,String> param = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
return param.get("id");
}
public void doSomething(){
//do some logic....
//I don't use id parameter
}
}
After I get from AAA page to BBB page and click on "Make some logic.." button all code from doSomething()
method is run. When this method end and i return from I get NullPointerException because i have to get id
param in getId()
method. This mean that i lose viewParam id
. Why?
Edit
Related issue: lose view page parameter