ポートレットのタイトル・バー上で対応するアイコンをクリックすると、そのポートレットのモードを手動で変更できます。
しかし、Faces アクションのパフォーマンスに基づいてポートレット・モードを変更したい場合は、その Faces アクションで適切なポートレット API メソッドを呼び出して、モード変更をトリガーすることができます。
たとえば、編集モード・ページの実行ボタンをクリックすると、編集モードのポートレットを表示モードに戻すことができます。
- JSR 168 ポートレット API の例
ActionResponse response = (ActionResponse)facesContext.getExternalContext().getResponse();
try {
response.setPortletMode(PortletMode.VIEW);
} catch (PortletModeException e) {
// Your exception handling code here
}
- IBM ポートレット API の例
PortletRequest request = (PortletRequest)facesContext.getExternalContext().getRequest();
try {
request.setModeModifier(Portlet.ModeModifier.PREVIOUS);
} catch (AccessDeniedException e) {
// Your exception handling code here
}