掲示板

following the developing guide but fail in "Passing Information from the Ac

11年前 に tong123123 tong123123 によって更新されました。

following the developing guide but fail in "Passing Information from the Ac

New Member 投稿: 23 参加年月日: 12/08/10 最新の投稿
I follow the developing guide
http://www.liferay.com/documentation/liferay-portal/6.0/development/-/ai/passing-information-from-the-action-phase-to-the-render-phase
and modify MyGreetingPortlet and edit.jsp,
but when I saved, the "Greeting saved successfully" does not shown as the developer guide said.
it just returned to the view.jsp

the edit.jsp is as follow:
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>

<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>

<%@ page import="com.liferay.portal.kernel.util.ParamUtil" %>
<%@ page import="com.liferay.portal.kernel.util.Validator" %>
<%@ page import="javax.portlet.PortletPreferences" %>
<portlet:defineObjects />

<%
PortletPreferences prefs = renderRequest.getPreferences();

String greeting = (String)prefs.getValue(
"greeting", "Hello! Welcome to our portal.");
%>

<liferay-ui:success key="success" message="Greeting saved successfully!" />


<portlet:actionURL var="editGreetingURL">
<portlet:param name="jspPage" value="/edit.jsp" />
</portlet:actionURL>

<aui:form action="<%= editGreetingURL %>" method="post">
<aui:input label="greeting" name="greeting" type="text" value="<%= greeting %>" />
<aui:button type="submit" />
</aui:form>

<portlet:renderURL var="viewGreetingURL">
<portlet:param name="jspPage" value="/view.jsp" />
</portlet:renderURL>

<p><a href="<%= viewGreetingURL %>">← Back</a></p>


the MyGreetingPortlet as follow:
package com.liferay.samples;

import java.io.IOException;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.PortletPreferences;

import com.liferay.portal.kernel.servlet.SessionMessages;

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

public class MyGreetingPortlet extends MVCPortlet {

@Override
public void processAction(
ActionRequest actionRequest, ActionResponse actionResponse)
throws IOException, PortletException {

PortletPreferences prefs = actionRequest.getPreferences();

String greeting = actionRequest.getParameter("greeting");

if (greeting != null) {
prefs.setValue("greeting", greeting);
prefs.store();
}

SessionMessages.add(actionRequest, "success");


super.processAction(actionRequest, actionResponse);
}
}
11年前 に Satheesh Ravi によって更新されました。

RE: following the developing guide but fail in "Passing Information from th

Junior Member 投稿: 35 参加年月日: 11/11/25 最新の投稿
It's working fine for me. One advice use MVCPortlet only if you have requirement else go for GenericPortlet which is lighter than MVC.