Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Kiran Jai
Liferay 6 : Not allowed in event phase when using Jquery AJAX with Liferay
April 17, 2012 5:08 AM
Answer

Kiran Jai

Rank: Junior Member

Posts: 38

Join Date: April 9, 2012

Recent Posts

I am using Liferay 6 and Jquery with AJAX Support

Enter Your Name:

This is my function called on click of that button

function my_button_handler()
{
jQuery.ajax({
type: "POST",
url: "helloForm",
success: function(msg){
alert( "Data Saved: " + msg );
}});

}

This is my Struts2 Action class

public String execute() throws Exception {
HttpServletResponse response = ServletActionContext.getResponse();
writer.print("Hi");
return ActionSupport.SUCCESS;
}

This is my action mapped inside struts.xml file

<action name="helloForm" class="com.robisoft.portlet.struts.action.Struts2Action">
<result name="input">/WEB-INF/view/index.jsp</result>
<result name="success">/WEB-INF/view/result.jsp</result>
</action>

Where the result.jsp is a empty blank page only

When i executed this , by clicking on that button , it started giving me this Exception under server console

11:58:46,368 ERROR [render_portlet_jsp:154] java.lang.IllegalStateException: Not allowed in event phase
at org.apache.struts2.portlet.servlet.PortletServletResponse.getWriter(PortletServletResponse.java:169)
at com.robisoft.portlet.struts.action.Struts2Action.execute(Struts2Action.java:56)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:452)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:291)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:254)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)
at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)

Please tell me what might be the issue ??
Jignesh Vachhani
RE: Liferay 6 : Not allowed in event phase when using Jquery AJAX with Life
April 17, 2012 5:41 AM
Answer

Jignesh Vachhani

Rank: Liferay Master

Posts: 795

Join Date: March 10, 2008

Recent Posts

Hi Kiran,

You can see this post Here for more details about ajax call.
Hope this will give idea about how you can use jQuery Ajax call in liferay.