Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Thiago Esteves
liferay doesn't call my processAction method
August 6, 2009 12:11 PM
Answer

Thiago Esteves

Rank: Junior Member

Posts: 31

Join Date: June 24, 2009

Recent Posts

helooo,

I have a struts action that has the two methods reder and processAction.. But only my render method has been called by liferay, why?

is that correct?

1public void processAction(
2            ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
3            ActionRequest actionRequest, ActionResponse actionResponse)
4        throws Exception {
5
6.....
7
8}


my portlet.xml :

 1
 2<?xml version="1.0"?>
 3
 4<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0" 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">
 5    <portlet>
 6        <portlet-name>combo1</portlet-name>
 7        <display-name>Combo 1</display-name>
 8        <!-- <portlet-class>br.com.gravames.liferay.portlet.Combo1Portlet</portlet-class> -->
 9        <portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class>
10        <init-param>
11            <name>view-action</name>
12            <value>/combo1/view2</value>
13        </init-param>
14        <expiration-cache>0</expiration-cache>
15        <supports>
16            <mime-type>text/html</mime-type>
17        </supports>
18        <portlet-info>
19            <title>Combo 1</title>
20            <short-title>Combo 1</short-title>
21            <keywords>combo1,gravames</keywords>
22        </portlet-info>
23        <security-role-ref>
24            <role-name>administrator</role-name>
25        </security-role-ref>
26    </portlet>
27    <custom-window-state>
28        <window-state>exclusive</window-state>
29    </custom-window-state>
30    <custom-window-state>
31        <window-state>pop_up</window-state>
32    </custom-window-state>
33</portlet-app>


my struts-config.xml :

 1
 2<?xml version="1.0"?>
 3<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
 4
 5<struts-config>
 6
 7    <form-beans>
 8   
 9    <form-bean name="combo1Form" type="br.com.gravames.liferay.portlet.Combo1Form"/>
10   
11    </form-beans>
12
13    <action-mappings>
14       
15        <action path="/combo1/view" forward="portlet.combo1.view" />   
16       
17        <action
18            path="/combo1/view2"
19            type="br.com.gravames.liferay.portlet.Combo1Action"
20            name="combo1Form"
21            scope="request">
22            <forward name="portlet.combo1.view" path="portlet.combo1.view" />
23       
24        </action>
25       
26    </action-mappings>
27   
28    <plug-in className="org.apache.struts.tiles.TilesPlugin">
29        <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml"/>
30        <set-property property="moduleAware" value="true"/>
31        <set-property property="definitions-parser-validate" value="true"/>
32    </plug-in>
33   
34
35</struts-config>


liferay-portlet.xml :

 1
 2<?xml version="1.0" encoding="ISO-8859-1"?>
 3<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 5.2.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_5_2_0.dtd">
 4
 5<liferay-portlet-app>
 6    <portlet>
 7        <portlet-name>combo1</portlet-name>
 8        <!-- <icon>/images/world.png</icon>  -->
 9        <struts-path>combo1</struts-path>
10        <use-default-template>true</use-default-template>
11        <restore-current-view>true</restore-current-view>
12        <instanceable>true</instanceable>
13        <private-request-attributes>false</private-request-attributes>
14    </portlet>
15    <role-mapper>
16        <role-name>administrator</role-name>
17        <role-link>Administrator</role-link>
18    </role-mapper>
19    <role-mapper>
20        <role-name>guest</role-name>
21        <role-link>Guest</role-link>
22    </role-mapper>
23    <role-mapper>
24        <role-name>power-user</role-name>
25        <role-link>Power User</role-link>
26    </role-mapper>
27    <role-mapper>
28        <role-name>user</role-name>
29        <role-link>User</role-link>
30    </role-mapper>
31</liferay-portlet-app>
Arvind Mishra
RE: liferay doesn't call my processAction method
August 6, 2009 12:30 PM
Answer

Arvind Mishra

Rank: Regular Member

Posts: 221

Join Date: February 13, 2008

Recent Posts

When portlet loads , render method is called .
Process action will be called once you execute an action .
Thiago Esteves
RE: liferay doesn't call my processAction method
August 6, 2009 12:37 PM
Answer

Thiago Esteves

Rank: Junior Member

Posts: 31

Join Date: June 24, 2009

Recent Posts

Hello,

Thanks for the reply..


I call the action in this form, take a look:

<form action="<portlet:actionURL>
<portlet:param name="struts_action"
value="/combo1/view2" />
</portlet:actionURL>"
method="post"
name="<portlet:namespace />fm" enctype="multipart/form-data">
<div style="color: #12558E">Arquivo:
<input name="<portlet:namespace />arquivo" size="35" type="file"
value="">
<input type="hidden" name="<portlet:namespace />metodo" value="upload">
<input onClick="submitForm(document.<portlet:namespace />fm);"
style="margin-top: 5px;" type="button" value="upload">
<br/>
</div>
<br/>
</form>
Arvind Mishra
RE: liferay doesn't call my processAction method
August 6, 2009 1:01 PM
Answer

Arvind Mishra

Rank: Regular Member

Posts: 221

Join Date: February 13, 2008

Recent Posts

What is exactly happening , does the control ever goes to Action Method ?

If you have processAction and Render both the methods in action class control will always go to render method after it executes the action .
Thiago Esteves
RE: liferay doesn't call my processAction method
August 6, 2009 1:07 PM
Answer

Thiago Esteves

Rank: Junior Member

Posts: 31

Join Date: June 24, 2009

Recent Posts

when I submit this form, only the method render is called.

thanks
Gnaniyar Zubair
RE: liferay doesn't call my processAction method
August 6, 2009 11:07 PM
Answer

Gnaniyar Zubair

Rank: Liferay Master

Posts: 602

Join Date: December 19, 2007

Recent Posts

Hi ,

If No parameter in your process action, it will go to render action only . so you have to set an action in your process file.

In your form action, you have given the struts path correctly. But you have to set the parameter like this :
<portlet:param name="CMD" value="add" />
, and get this attribute in ur process action and write ur action coding.

I think your process action is just redirecting to render method without any action.

- Gnaniyar Zubair
Thiago Esteves
RE: liferay doesn't call my processAction method
August 10, 2009 7:52 AM
Answer

Thiago Esteves

Rank: Junior Member

Posts: 31

Join Date: June 24, 2009

Recent Posts

I think I'm "action" (of the html form) isn't set correctly. It is not calling the render too, I've tried to do a simpe System.out.println an get nothing. Take a look:

<form action="<portlet:actionURL>
<portlet:param name="struts_action"
value="/combo1/view2" />
</portlet:actionURL>"
method="post"
name="<portlet:namespace />fm" enctype="multipart/form-data">

thank you