Foros de discusión
Link view.jsp to processAction
lucky singh, modificado hace 11 años.
Link view.jsp to processAction
Junior Member Mensajes: 25 Fecha de incorporación: 30/07/12 Mensajes recientes
I am new to liferay. I have view.jsp,on form submit it should link to action class.
I have done following so far:
Have created “New Liferay Plug-in Project” with “Custom portlet class”and define portlet class as-CommentPortlet.
My view.jsp
My portlet.xml:
My portlet class-with processAction
I see "CommentPortlet is temporarily unavailable". Please suggest how to use processAction.
I have done following so far:
Have created “New Liferay Plug-in Project” with “Custom portlet class”and define portlet class as-CommentPortlet.
My view.jsp
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
<%@ page import="javax.portlet.PortletPreferences" %>
<%@page import="javax.portlet.PortletURL"%>
<%@page import="javax.portlet.ActionRequest"%>
<portlet:defineobjects />
<%
PortletPreferences prefs = renderRequest.getPreferences();
String greeting = (String)prefs.getValue(
"greeting", "This is a discussion forum:");
%>
<%
PortletURL viewCommentURL = renderResponse.createActionURL();
viewCommentURL.setParameter(
ActionRequest.ACTION_NAME, "processAction");
%>
<portlet:renderurl var="viewCommentURL">
<portlet:param name="jspPage" value="/html/commentportlet/view.jsp" />
</portlet:renderurl>
<form name="<portlet:namespace/>fm" method="POST" action="<%=
viewCommentURL.toString() %>">
<fieldset>
<legend><%= greeting %></legend>
Name:<input type="text" name="<portlet:namespace/>username"><br>
Add comment:<input type="text" name="<portlet:namespace/>usercommenr">
<br><input type="submit" value="Add" size="10" ">
</fieldset>
</form>
My portlet.xml:
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0">
<portlet>
<portlet-name>commentportlet</portlet-name>
<display-name>CommentPortlet</display-name>
<portlet-class>com.test.comment.CommentPortlet</portlet-class>
<init-param>
<name>view-template</name>
<value>/html/commentportlet/view.jsp</value>
</init-param>
<init-param>
<name>edit-template</name>
<value>/html/commentportlet/edit.jsp</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
<portlet-mode>edit</portlet-mode>
</supports>
<resource-bundle>content/Language</resource-bundle>
<portlet-info>
<title>CommentPortlet</title>
<short-title>CommentPortlet</short-title>
<keywords></keywords>
</portlet-info>
<security-role-ref>
<role-name>administrator</role-name>
</security-role-ref>
<security-role-ref>
<role-name>guest</role-name>
</security-role-ref>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
</portlet>
</portlet-app>
My portlet class-with processAction
package com.test.comment;
import java.io.IOException;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
//import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.util.bridges.mvc.MVCPortlet;
/**
* Portlet implementation class CommentPortlet
*/
public class CommentPortlet extends MVCPortlet {
public void processAction(
ActionRequest actionRequest, ActionResponse actionResponse)
throws IOException, PortletException {
//String name = ParamUtil.getString(actionRequest, "username");
//String comment = ParamUtil.getString(actionRequest, "usercommenr");
//System.out.println("Your inputs ==> " + name + ", " + comment);
System.out.println("Inside Processaction...");
}
}
I see "CommentPortlet is temporarily unavailable". Please suggest how to use processAction.
Oliver Bayer, modificado hace 11 años.
RE: Link view.jsp to processAction
Liferay Master Mensajes: 894 Fecha de incorporación: 18/02/09 Mensajes recientes
Hi,
if you're getting such error messages you should look at the console logs of your server to get more info why this error occurred.
HTH Oli
if you're getting such error messages you should look at the console logs of your server to get more info why this error occurred.
HTH Oli
John Andrews, modificado hace 11 años.
RE: Link view.jsp to processAction
New Member Mensajes: 22 Fecha de incorporación: 26/07/12 Mensajes recientes
use this form submit
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme"%>
<%@ page import="javax.portlet.*"%>
<%@ page import="com.liferay.portal.service.UserLocalServiceUtil" %>
<%@ page import="com.liferay.portal.model.Organization" %>
<%@ page import="com.liferay.portal.model.User" %>
<portlet:defineObjects />
<liferay-theme:defineObjects />
This is the <b>GroupCreationPortlet</b> portlet in View mode.
<form method="POST" action="<portlet:actionURL/>">
<input type="text" name="ownertarget"/>
<input type="submit" value="edit"/>
</form>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme"%>
<%@ page import="javax.portlet.*"%>
<%@ page import="com.liferay.portal.service.UserLocalServiceUtil" %>
<%@ page import="com.liferay.portal.model.Organization" %>
<%@ page import="com.liferay.portal.model.User" %>
<portlet:defineObjects />
<liferay-theme:defineObjects />
This is the <b>GroupCreationPortlet</b> portlet in View mode.
<form method="POST" action="<portlet:actionURL/>">
<input type="text" name="ownertarget"/>
<input type="submit" value="edit"/>
</form>
Roshan Qureshi, modificado hace 11 años.
RE: Link view.jsp to processAction
Regular Member Mensajes: 159 Fecha de incorporación: 24/08/10 Mensajes recientes
Hi Lucky,
Use <portlet:actionURL> instead of <portlet:renderURL>
renderURL will call render method while actionURL will call processAction() method of the portlet.
Use <portlet:actionURL> instead of <portlet:renderURL>
renderURL will call render method while actionURL will call processAction() method of the portlet.