无法在Struts2 Liferay Portlet中将Window State设置为Exclusive

时间:2014-09-18 11:54:24

标签: java struts2 liferay portlet

概述:将struts2 web-appp移植到liferay struts2 6.2 portlet

问题:无法将windowState设置为&#34; Exclusive&#34;在struts2标记<s:url ..../>

描述:我需要将windowState设置为&#34; Exclusive&#34;在struts2标记<s:url ..../>

我正在尝试以下选项,但无法将网址状态设置为独占。

<s:url var="billingOverview" action="%{billingOverviewURL}"
       portletMode="view" portletUrlType="struts.portlet.action"
       windowState=<%=LiferayWindowState.EXCLUSIVE.toString()%> />

最初我得到了异常:&#34;根据tld或属性windowState,不接受任何表达式&#34;。我修改了struts2核心jar(struts2-core-2.3.7.jar)&#39; s&#34; struts-tags.tld&#34;通过将rtexprvalue更改为TRUE,我在其中进行了以下更改以接受windowState标记中的表达式:

<attribute>
      <description><![CDATA[The resulting portlet window state]]></description>
      <name>windowState</name>
      <required>false</required>
      <rtexprvalue>true</rtexprvalue>
</attribute>

如果我可以在上面的问题上得到一些指针,那真的很棒。在此先感谢!

1 个答案:

答案 0 :(得分:0)

您无法在Struts标记内嵌套不应在其他任何地方使用的scriptlet(<%...%>

您需要在struts.xml中启用静态方法访问

<constant name="struts.ognl.allowStaticMethodAccess" value="true" />

然后使用以下语法引用FQCN:

将其更改为:

<s:url portletUrlType="struts.portlet.action"
          portletMode="view" 
                  var="billingOverview" 
               action="%{billingOverviewURL}"   
          windowState="%{@com.liferay.portal.kernel.portlet.LiferayWindowState@EXCLUSIVE}" />

更多关于the documentation