【问题标题】:Liferay Portlets are not working on upgrading from 6.1 to 6.2Liferay Portlet 无法从 6.1 升级到 6.2
【发布时间】:2016-03-18 16:14:11
【问题描述】:

我正在使用 struts 2 和 liferay 6.1.0 来开发网站。现在我想将 liferay 版本更新到 6.2。当我启动 liferay tomcat 服务器时,它显示所有的 portlet 都可以使用。但是当我填写表格时,值不会传递给 Action 类。我 sysout 进行检查,发现 s:textfield 值没有进入操作类,但 sysout 字符串正在控制台中打印。完全相同的是代码在 liferay 6.1 中工作。

任何帮助都是非常值得赞赏的。

jsp文件:

<s:form name="searchCallLogCategoryWise" id="searchCallLogCategoryWise" action="searchCallLogCategoryWise" method="post">
<table>
<tr>
    <td width="30%">Status</td>
    <td width="70%"><select name="caseCriteria" id="caseCriteria">
        <option value="Select">Select</option>
        <option value="Open">Open</option>
        <option value="Closed">Closed</option>
        <s:textfield name="callLogId" id="callLogId" value="1234"></s:textfield>
        </select> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; <s:submit
        action="searchCallLogCategoryWise" value="Search"></s:submit>
    </td>
</tr>
</table>
</s:form>

struts.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
    <constant name="struts.ui.theme" value="simple" />
    <package name="view" extends="struts-portlet-default"
        namespace="/view">
        <action name="searchCallLogCategoryWise" class="com.stp.portal.view.callLogModulePortlet" method="searchCallLogCategoryWise" >
            <result name="success">/WEB-INF/view/CallLogReportStartPage.jsp</result>    
        </action>
    </package>
</struts>

callLogModulePortlet.java

    public class callLogModulePortlet extends DefaultActionSupport {

    private String callLogId = "";
    private String caseCriteria = "";

    public String getCallLogId() {
        return callLogId;
    }

    public void setCallLogId(String callLogId) {
        this.callLogId = callLogId;
    }

    public String getCaseCriteria() {
        return caseCriteria;
    }

    public void setCaseCriteria(String caseCriteria) {
        this.caseCriteria = caseCriteria;
    }


    public String searchCallLogCategoryWise() throws Exception
    {
        System.out.println("i am in searchCallLogCategoryWise...");
        System.out.println("Call Log Id:: " + getCallLogId());
        System.out.println("case Criteria: " + getCaseCriteria());

        return "success";
    }

}

当我在控制台中运行它时:

i am in searchCallLogCategoryWise...
Call Log Id::
case Criteria:

我正在使用以下罐子:

struts2-core-2.2.3.jar

struts2-portlet-plugin-2.2.3.jar

xwork-core-2.2.3.jar

【问题讨论】:

标签: java jsp struts2 liferay liferay-6


【解决方案1】:

尝试将&lt;portlet:namespace/&gt; 添加到参数名称并正确关闭&lt;select&gt; 输入:

<select name="<portlet:namespace/>caseCriteria" id="caseCriteria">
  <option value="Select">Select</option>
  ....
</select>
<s:textfield name="<portlet:namespace/>callLogId" id="callLogId" value="1234"/>

我不确定s taglib 是否会自动添加它——但portlet 需要它知道参数实际上是定向到您的portlet。普通的&lt;select&gt; 肯定不会自动包含它。

【讨论】:

    【解决方案2】:

    通过在 liferay-portlet.xml 中添加 &lt;requires-namespaced-parameters&gt;false&lt;/requires-namespaced-parameters&gt; 解决了这个问题。

    【讨论】:

    • 这是正确命名参数的蛮力替代方案(请参阅我的答案)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多