4

我在我的项目中使用 liferay ui 标签。我想通过单击选项卡来调用控制器。我使用 portlerURL 属性进行尝试,但它不起作用。

这是我的代码片段:-

视图.jsp

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet"%>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme"%>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@page import="com.liferay.portal.kernel.util.ParamUtil"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>


<liferay-theme:defineObjects />
<portlet:defineObjects />


<liferay-portlet:renderURL var="portletURL" />

<%
    //We must Specify a default value for tabs. In this example it is sunday. Else it //will throw an error.
    String tabValue = ParamUtil.getString(request, "tab", "sunday");
    String tabsURL = "/" + tabValue.trim() + ".jsp";
    String tabNames = "Sunday,Monday,Tuesday";
    String tabVal = "sunday,monday,tuesday";
    if (permissionChecker.isCompanyAdmin(themeDisplay.getCompanyId())) {
        tabNames += ",Admin";
        tabVal += ",admin";
    }

    PortletURL URL = renderResponse.createActionURL();
    URL.setParameter("click","tabClick");
%>

<liferay-ui:tabs names="<%=tabNames%>" tabsValues="<%=tabVal%>" param="tab" url="<%= portletURL %>" />

<c:import url="<%= tabsURL %>"></c:import>

控制器 :-

import com.liferay.util.bridges.mvc.MVCPortlet;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;

/**
 * Portlet implementation class TabDemoPortlet
 */
public class TabDemoPortlet extends MVCPortlet {

    public void sunday(ActionRequest req,ActionResponse res) {
        System.out.println("Hello Sunday!!!");
    }

    public void monday(ActionRequest req,ActionResponse res) {
        System.out.println("Hello Monday!!!");
    }

    public void tuesday(ActionRequest req,ActionResponse res) {
        System.out.println("Hello Tuesday!!!");
    }
}

欢迎所有建议。提前致谢!!!

4

1 回答 1

6

您必须创建多个 actionURL 并在 liferay-ui:tabs 中使用它们。像这样的东西

<portlet:actionURL name="sunday" var ="sundayURL"/>
<portlet:actionURL name="monday" var ="mondayURL"/>
<portlet:actionURL name="tuesday" var ="tuesdayURL"/>

<liferay-ui:tabs names="<%=tabNames%>" 
   url0="<%=sundayURL/>"
   url1="<%=mondayURL/>"
   url2="<%=tuesdayURL/>"/>
于 2012-06-19T06:10:29.247 回答