" type="hidden"-6ren">
gpt4 book ai didi

java - Liferay portlet 配置

转载 作者:行者123 更新时间:2023-12-01 12:46:15 25 4
gpt4 key购买 nike

我正在尝试个性化 Liferay portlet 的配置。

configuration.jsp 是:

<%@include file="/init.jsp" %>

<liferay-portlet:actionURL portletConfiguration="true" var="configurationURL" />

<%
boolean showLocationAddress_cfg = GetterUtil.getBoolean(portletPreferences.getValue("showLocationAddress", StringPool.TRUE));
%>

<aui:form action="<%= configurationURL %>" method="post" name="fm">
<aui:input name="<%= Constants.CMD %>" type="hidden" value="<%= Constants.UPDATE %>" />

<aui:input name="preferences--showLocationAddress--" type="checkbox" value="<%= showLocationAddress_cfg %>" />
<aui:input key="mailAddress" type="text" name="preferences--mailAddress--"/>
<aui:button-row>
<aui:button name="save-Boutton" type="submit" value="Save"/>
</aui:button-row>
</aui:form>

ConfigurationActionImpl.java 是:

package com.nosester.portlet.eventlisting.action;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletConfig;
import javax.portlet.PortletPreferences;

import com.liferay.portal.kernel.portlet.DefaultConfigurationAction;
import com.liferay.portal.kernel.servlet.SessionErrors;
import com.liferay.portal.kernel.servlet.SessionMessages;
import com.liferay.portal.kernel.util.Constants;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portlet.PortletPreferencesFactoryUtil;

public class ConfigurationActionImpl extends DefaultConfigurationAction {

@Override
public void processAction(
PortletConfig portletConfig, ActionRequest actionRequest,
ActionResponse actionResponse) throws Exception {

super.processAction(portletConfig, actionRequest, actionResponse);

PortletPreferences prefs = actionRequest.getPreferences();


String mailAddress=prefs.getValue("mailAddress", "default");


System.out.println("address mail= "+mailAddress);
}

但在所有情况下显示的邮件地址都是:默认。

有人可以帮助我更正此代码,以便它可以显示用户在文本字段中输入的内容吗?

最佳答案

我相信,当您调用 DefaultConfigurationActionprocessAction 方法时,actionRequest 并未使用 portletPreferences 值进行更新。您可以使用下面的代码来正确获取它。

 String portletResource = ParamUtil.getString(
actionRequest, "portletResource");

PortletPreferences portletPreferences =
PortletPreferencesFactoryUtil.getPortletSetup(
actionRequest, portletResource);

portletPreferences .getValue("mailAddress", "default");

关于java - Liferay portlet 配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24676507/

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