<f:metadata>、<f:viewParam>、および <f:viewAction> は何に使用できますか?
レンダリング前のビュー イベント リスナーがあります。
<f:metadata>
<f:event type="preRenderView" listener="#{loginBean.performWeakLogin()}" />
</f:metadata>
次のメソッドを呼び出します。
public String performWeakLogin() {
FacesContext facesContext = FacesContext.getCurrentInstance();
String parameter_value = (String) facesContext.getExternalContext().getRequestParameterMap().get("txtName");
if (parameter_value != null && parameter_value.equalsIgnoreCase("pippo")) {
try {
return "mainPortal";
} catch (IOException ex) {
return null;
}
} else {
return null;
}
}
および次のナビゲーション ルール:
<navigation-rule>
<from-view-id>/stdPortal/index.xhtml</from-view-id>
<navigation-case>
<from-outcome>mainPortal</from-outcome>
<to-view-id>/stdPortal/stdPages/mainPortal.xhtml</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
ただし、ナビゲーションは実行しません。次のようにコマンドボタンを使用すると機能します。
<p:commandButton ... action="#{loginBean.performWeakLogin()}" />