验证Portlet首选项后添加确认消息

pro*_*ton 1 portlet liferay

我想在验证表单时添加确认消息和重定向到我的jsp.

我在liferay的源代码中看到了这个

SessionMessages.add(actionRequest, config.getPortletName() + ".doConfigure");
Run Code Online (Sandbox Code Playgroud)

这会显示绿色样式的消息Param has been saved successfully.但是不起作用.它显然使用配置菜单(打开一个弹出窗口),我使用首选项菜单,我仍然可以调整这行代码吗?

当我更改首选项时,我想在我的portlet中进行重定向,但是现在,它仍然在首选项页面上,我必须单击Return to full page.

此外,如果未验证首选项,是否可以显示错误消息?

问候.谢谢

Ola*_*ock 5

每一个

  SessionMessages.add(actionRequest, "successfully-handled-some-action");
  SessionErrors.add(actionRequest, "problem-occurred");
Run Code Online (Sandbox Code Playgroud)

你将需要一个部分在你的jsp中捡起它(否则没有人会知道你希望它出现在页面上):

  <liferay-ui:success key="successfully-handled-some-action" message="localization-key-for-this-message"/>
  <liferay-ui:error key="problem-occurred" message="localization-key-for-this-message"/>
Run Code Online (Sandbox Code Playgroud)

  • 使用此actionResponse.setPortletMode(PortletMode.VIEW) (2认同)