Vista combinada Visión Plana Vista de árbol
Discusiones [ Anterior | Siguiente ]
toggle
Ravi Kiran
Unable to call Struts2 Action using Jquery Ajax in Liferay
19 de abril de 2012 22:55
Respuesta

Ravi Kiran

Ranking: Junior Member

Mensajes: 53

Fecha de incorporación: 7 de abril de 2012

Mensajes recientes

I was Unable to call Struts2 Action using Jquery Ajax in Liferay6.1

Please see the following files , i pasted below and let me know if this is not the way to call

Jsp page

<portlet:renderURL var="getChartData" windowState="<%= LiferayWindowState.EXCLUSIVE.toString() %>">
<portlet:param name="struts_action" value="/getChartData" />
</portlet:renderURL>



<script type="text/javascript">
$(document).ready(function(){
alert('jjjj');
$.ajax({
type : 'POST',
url : '<%=getChartData%>',
data: "countryId="+countryId,
success : function(data){
alert(data);
}
});

});
</script>
struts.xml

<action name="getChartData" class="com.actions.ImageDisplayAction" method="getChartData">
<result name="success">/WEB-INF/view/blank.jsp</result>
</action>
portlet.xml

<portlet>
<portlet-name>DisplayImages</portlet-name>
<display-name>DisplayImages</display-name>

<portlet-class>org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher</portlet-class>
Action class

public class ImageDisplayAction extends ActionSupport {

public String getChartData() {

System.out.println("Hi ");
System.out.println("Hi ");
System.out.println("Hi ");
System.out.println("Hi ");

return SUCCESS;
}

}
Riccardo Ferrari
RE: Unable to call Struts2 Action using Jquery Ajax in Liferay
21 de abril de 2012 6:35
Respuesta

Riccardo Ferrari

Ranking: Regular Member

Mensajes: 137

Fecha de incorporación: 13 de noviembre de 2010

Mensajes recientes

Hi,

I think you are NOT configuring properly your struts2 URLs. Take a look at the following example (it uses struts2 taglib to build action URLs)

http://www.mkyong.com/struts2/struts-2-action-tag-example/

In my experience "struts_action" parameter is referring to Struts 1 actions. Struts2 is using a parameter name of "struts.portlet.action"

EDIT: sorry there was a typo
Terry zhao
RE: Unable to call Struts2 Action using Jquery Ajax in Liferay
7 de junio de 2012 3:15
Respuesta

Terry zhao

Ranking: New Member

Mensajes: 5

Fecha de incorporación: 3 de mayo de 2012

Mensajes recientes

the same problem too.