我有JSF页面。我想将参数从<f:param>
到CDI bean
<h:commandButton styleClass="form_button" id="login" action="#{user.forward}" value="LOGIN">
<f:param name="pageId" value="2"/>
</h:commandButton>
在ManagedBean中,我们可以使用@ManagedPropetry:
@ManagedProperty(value = "#{param.pageId}")
private String pageId;
在CDI中我们可以使用什么代替@ManagedProperty?
我解决了它。我希望这可以帮助别人。在方法中,我们称之为:
FacesContext context = FacesContext.getCurrentInstance();
Map<String, String> params = context.getExternalContext().getRequestParameterMap();
String pageId = params.get("pageId");
if (pageId.equals("2")) return "page2";