gpt4 book ai didi

tabs - 如何在liferay ui选项卡中单击选项卡调用 Controller 方法?

转载 作者:行者123 更新时间:2023-12-05 00:34:11 25 4
gpt4 key购买 nike

我在我的项目中使用 liferay ui 选项卡。我想在单击选项卡时调用 Controller 。我尝试使用 portlerURL 属性,但它不起作用。

这是我的代码片段:-

view.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>

Controller :-
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!!!");
}
}

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

最佳答案

您必须创建多个 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/>"/>

关于tabs - 如何在liferay ui选项卡中单击选项卡调用 Controller 方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11094992/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com