Foros de discusión
Unable to call Struts2 Action using Jquery Ajax in Liferay
Ravi Kiran, modificado hace 12 años.
Unable to call Struts2 Action using Jquery Ajax in Liferay
Junior Member Mensajes: 53 Fecha de incorporación: 8/04/12 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;
}
}
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, modificado hace 12 años.
RE: Unable to call Struts2 Action using Jquery Ajax in Liferay
Regular Member Mensajes: 139 Fecha de incorporación: 13/11/10 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
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, modificado hace 11 años.
RE: Unable to call Struts2 Action using Jquery Ajax in Liferay
New Member Mensajes: 5 Fecha de incorporación: 4/05/12 Mensajes recientes
the same problem too.