根据PortletPreferences显示不同的portlet页面
我有一个处理关税和关税类别的 portlet。我正在使用 Liferay 5.2.3 和 Spring Portlet 框架。
添加到页面上时,Portlet 应该以两种模式工作:
- 显示主屏幕 - 标准模式 (MainScreenController)
- 显示关税类别详细信息 (TariffCategoryController) - 当设置了 Portlet 首选项“showCategoryDetail”时,
我不知道如何更改/转发请求当设置 portlet 首选项时,将返回到 TariffCategoryController。你能给我一个提示吗?谢谢你!
@Controller("mainScreenController")
@RequestMapping("VIEW")
public class MainScreenController {
@RenderMapping
public String handleRenderRequest() {
return "mainScreen";
}
...
}
@Controller("tariffCategoryController")
@RequestMapping("VIEW")
public class TariffCategoryController {
@RenderMapping(params = "myaction=showTariffCategory")
public String handleRenderRequest() {
return "tariffCategory";
}
...
}
I've a portlet that handles tariffs and tariff categories. I'm using Liferay 5.2.3 and Spring Portlet framework.
The portlet should work in two modes when added on page:
- display main screen - the standard mode (MainScreenController)
- display tariff category detail (TariffCategoryController) - when a portlet preference "showCategoryDetail" is set
I cannot figure out how to change/forward the request to TariffCategoryController when the portlet preference is set. Can you please give me a hint? Thank you!
@Controller("mainScreenController")
@RequestMapping("VIEW")
public class MainScreenController {
@RenderMapping
public String handleRenderRequest() {
return "mainScreen";
}
...
}
@Controller("tariffCategoryController")
@RequestMapping("VIEW")
public class TariffCategoryController {
@RenderMapping(params = "myaction=showTariffCategory")
public String handleRenderRequest() {
return "tariffCategory";
}
...
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
标准 Spring 的 DefaultAnnotationHandlerMapping 不适用于 portlet 首选项。如果您需要这样的功能,那么编写自己的自定义 HandlerMapping 实现。
但我建议采用不同的方法。无论任何首选项如何,都显示默认视图。如果未设置首选项,则显示一条消息,指出“需要配置”,并带有指向编辑模式的链接。为什么?因为首选项只能在编辑模式下编辑,并且您不需要基于 portlet 首选项进行路由。
Standard Spring's DefaultAnnotationHandlerMapping is not working with portlet preferences. If you need such functionality, it should be pretty easy to write your own custom HandlerMapping implementation.
But I would suggest a different approach. Show default view regardless any preference, If the preference is not set, show a message saying "configuration required" with link to EDIT mode. Why? Because preferences should be edited only in EDIT mode and you won't need routing based on portlet preferences.