Portlet 符合JSR286的命名空间参数
在portlet中,在action方法中读取名称空间参数的最佳方法是什么。 我的表格包含Portlet 符合JSR286的命名空间参数,portlet,liferay-6,websphere-portal,jsr286,Portlet,Liferay 6,Websphere Portal,Jsr286,在portlet中,在action方法中读取名称空间参数的最佳方法是什么。 我的表格包含 <input id="<portlet:namespace/>param1" name="<portlet:namespace/>param1" value='hello'/> 备选案文2: request.getParameter("param1"); 选项1在liferay中不起作用,但似乎在websphere中也能起作用。选项2在liferay 6.2中运行良
<input id="<portlet:namespace/>param1" name="<portlet:namespace/>param1" value='hello'/>
备选案文2:
request.getParameter("param1");
选项1在liferay中不起作用,但似乎在websphere中也能起作用。选项2在liferay 6.2中运行良好。选项1似乎适用于6.1之前的版本
有人能告诉我什么是JSR286兼容方式吗 没有“JSR286兼容方式”,您可以同时使用这两种方法。usage标记的主要用途是在同一门户页面上有多个portlet实例时,将exact参数传递给exact porlet。在这种情况下,不同portlet的相同html输入具有不同的名称,每个portlet将获得自己的页面值。没有“符合jsr 286的方法”,您可以同时使用这两种方法。usage标记的主要用途是在同一门户页面上有多个portlet实例时,将exact参数传递给exact porlet。在这种情况下,不同portlet的相同html输入具有不同的名称,每个portlet将获得自己的页面值。最后的日志语句来自于在WebSphere中运行代码
<%@ taglib uri='http://java.sun.com/portlet' prefix='portlet'%>
<form name="<portlet:namespace />"
action="<portlet:actionURL windowState='normal'> <portlet:param name='action' value='processAction' /></portlet:actionURL>"
method="post"><br />
<input id="<portlet:namespace/>renderPage"
name="<portlet:namespace/>renderPage"
value='<%=request.getAttribute(Constants.RENDER_PAGE)%>'><br />
</form>
@Override
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException
{
if (mLogger.isDebugEnabled())
{
mLogger.debug("processAction:: Request Parameter Map:" + request.getParameterMap());
}
// Make all ActionRequest Parameter for RenderRequest
response.setRenderParameters(request.getParameterMap());
if (mLogger.isDebugEnabled())
{
mLogger.debug("processAction:: Latest changes are there");
mLogger.debug(Constants.RENDER_PAGE + "==Namespace=>"+request.getParameter(response.getNamespace()+Constants.RENDER_PAGE));
mLogger.debug(Constants.RENDER_PAGE + "==withoutnamespace=>"+request.getParameter(Constants.RENDER_PAGE));
}
@凌驾
public void processAction(ActionRequest请求、ActionResponse响应)抛出PortletException、IOException
{
if(mLogger.isDebugEnabled())
{
调试(“processAction::请求参数映射:”+Request.getParameterMap());
}
//为RenderRequest设置所有ActionRequest参数
response.setRenderParameters(request.getParameterMap());
if(mLogger.isDebugEnabled())
{
调试(“processAction::有最新的更改”);
调试(Constants.RENDER_PAGE+“==Namespace=>”+request.getParameter(response.getNamespace()+Constants.RENDER_PAGE));
调试(Constants.RENDER_PAGE+“==withoutnamespace=>”+request.getParameter(Constants.RENDER_PAGE));
}
2014-02-12 19:35:23877调试……renderPage==名称空间=>站点/组件指南/主页
2014-02-12 19:35:23877调试..renderPage==withoutnamespace=>null末尾的日志语句来自在WebSphere中运行代码
<%@ taglib uri='http://java.sun.com/portlet' prefix='portlet'%>
<form name="<portlet:namespace />"
action="<portlet:actionURL windowState='normal'> <portlet:param name='action' value='processAction' /></portlet:actionURL>"
method="post"><br />
<input id="<portlet:namespace/>renderPage"
name="<portlet:namespace/>renderPage"
value='<%=request.getAttribute(Constants.RENDER_PAGE)%>'><br />
</form>
@Override
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException
{
if (mLogger.isDebugEnabled())
{
mLogger.debug("processAction:: Request Parameter Map:" + request.getParameterMap());
}
// Make all ActionRequest Parameter for RenderRequest
response.setRenderParameters(request.getParameterMap());
if (mLogger.isDebugEnabled())
{
mLogger.debug("processAction:: Latest changes are there");
mLogger.debug(Constants.RENDER_PAGE + "==Namespace=>"+request.getParameter(response.getNamespace()+Constants.RENDER_PAGE));
mLogger.debug(Constants.RENDER_PAGE + "==withoutnamespace=>"+request.getParameter(Constants.RENDER_PAGE));
}
@凌驾
public void processAction(ActionRequest请求、ActionResponse响应)抛出PortletException、IOException
{
if(mLogger.isDebugEnabled())
{
调试(“processAction::请求参数映射:”+Request.getParameterMap());
}
//为RenderRequest设置所有ActionRequest参数
response.setRenderParameters(request.getParameterMap());
if(mLogger.isDebugEnabled())
{
调试(“processAction::有最新的更改”);
调试(Constants.RENDER_PAGE+“==Namespace=>”+request.getParameter(response.getNamespace()+Constants.RENDER_PAGE));
调试(Constants.RENDER_PAGE+“==withoutnamespace=>”+request.getParameter(Constants.RENDER_PAGE));
}
2014-02-12 19:35:23877调试……renderPage==名称空间=>站点/组件指南/主页
2014-02-12 19:35:23877调试…..renderPage==withoutnamespace=>null正如我在回答这个问题的评论中提到的,问题在于Liferay 6.2,因为IBM WebSphere和Liferay的早期版本按预期工作 为了解决这个问题,我在portlet的
/WEB-INF
目录的liferayportlet.xml
中添加了元素false
。通过这样做,HTML表单的参数就不会“名称空间化”
/WEB-INF/liferay portlet.xml
示例:
<?xml version="1.0" encoding="UTF-8"?>
<liferay-portlet-app>
<portlet>
<portlet-name>Portlet name</portlet-name>
<requires-namespaced-parameters>false</requires-namespaced-parameters>
<instanceable>true</instanceable>
<ajaxable>false</ajaxable>
</portlet>
</liferay-portlet-app>
Portlet名称
假的
真的
假的
如果将此元素添加到liferayportlet.xml
,则该portlet在以前版本的liferay中仍能正常工作(我使用版本5.5和6.1进行了测试)。它还可以与其他portlet包含一起工作,因为它们忽略了此文件
我声称Liferay的行为不正确,因为JSR-286规范说明了以下内容(位于规范第76页顶部):
如果portlet命名空间或编码URL参数或表单参数,则它们也负责删除命名空间。portlet容器不会删除portlet对这些参数所做的任何命名空间。”
正如我在回答这个问题的评论中提到的,问题出在Liferay 6.2上,因为IBM WebSphere和Liferay的早期版本按预期工作 为了解决这个问题,我在portlet的
/WEB-INF
目录的liferayportlet.xml
中添加了元素false
。通过这样做,HTML表单的参数就不会“名称空间化”
/WEB-INF/liferay portlet.xml
示例:
<?xml version="1.0" encoding="UTF-8"?>
<liferay-portlet-app>
<portlet>
<portlet-name>Portlet name</portlet-name>
<requires-namespaced-parameters>false</requires-namespaced-parameters>
<instanceable>true</instanceable>
<ajaxable>false</ajaxable>
</portlet>
</liferay-portlet-app>
Portlet名称
假的
真的
假的
如果将此元素添加到liferayportlet.xml
,则该portlet在以前版本的liferay中仍能正常工作(我使用版本5.5和6.1进行了测试)。它还可以与其他portlet包含一起工作,因为它们忽略了此文件
我声称Liferay的行为不正确,因为JSR-286规范说明了以下内容(位于规范第76页顶部):
如果portlet命名空间或编码URL参数或表单参数,则它们也负责删除命名空间。portlet容器不会删除portlet对这些参数所做的任何命名空间。”
嗨,Georgy Gobozov,谢谢你的回答。嗨,Georgy Gobozov,谢谢你的回答。让我们假设我正在创建一个使用名称空间进行参数传递的portlet,我想在不同的环境中部署该portlet,如liferay、websphere和weblogic等。所以我希望编写能在所有平台上运行的代码。那么你是说不可能吗?它应该在所有平台上都能工作。这是portlet规范的一部分,如果门户实现JSR168或JSR286,那么这个标记应该能工作。我测试了它,request.getParameter(“param