renderRequest属性在renderRequest中不存在

时间:2016-03-01 09:25:01

标签: java liferay

我正在尝试实现显示所有用户或搜索输入的portlet,具体取决于操作。

如果我理解了所有内容,渲染阶段就在行动阶段之后,那么ActionRequest应该传递到RenderRequest。我的方法:

JSP file:

<portlet:actionURL var="showAllAction" name="showAll"/>
<portlet:actionURL var="searchAction" name="search"/>

<div class="container">
  <ul>
    <li class="one"><a class="underline" href="${searchAction}">Search</a></li>
    <li class="two"><a class="underline" href="${showAllAction}">Show All</a></li>
    <hr />
  </ul>
</div>


<c:choose>
    <c:when test="${option}.equals('all')">
        <table name="userTable" id="userTable" class="display" cellspacing="0" width="100%">
            <thead>
                <tr>
                    <td>First Name</td>
                    <td>Email</td>
                    <td>login</td>
                </tr>
            </thead>
            <tbody>
                <c:forEach items="${roles}" var="user">
                    <tr>
                        <td><c:out value="${user.firstName}"/> <c:out value="${user.lastName}"/></td>
                        <td><c:out value="${user.emailAddress}"/></td>  
                        <td><c:out value="${user.screenName}"/></td>
                    </tr>
                </c:forEach>
            </tbody>

        </table>
    </c:when>
    <c:otherwise>
        <label for='person'>insert login</label><br/>
        <input id='person' name='person' type='text' />
    </c:otherwise>
</c:choose>

控制器代码:

@Override
     public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {

         super.doView(renderRequest, renderResponse);
     }

    @ProcessAction(name="showAll")
    public void showAll(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException{
        try {
            List<User> userList = UserLocalServiceUtil.getUsers(1, UserLocalServiceUtil.getUsersCount());
            actionRequest.setAttribute("roles", userList);
            actionRequest.setAttribute("option", "all");
        } catch (SystemException e) {
            e.printStackTrace();
        } 

    }

但是,无论${option}为空,并且正在呈现<c:otherwise>。我做错了什么?

0 个答案:

没有答案