I am working on ajax using struts 2 frame work. Application has two text boxes "name" and "age". On submitting , those two values should be updated using div tag on the same page itself.
<sx:div id="div2" executeScripts="true" theme="ajax">Value</sx:div>
<sx:submit targets="div2" value="submit">
when i use "targets" attribute in sx:submit ,getting some exception. when i remove "targets" no exception has been thrown.But application needs "targets" attribute to update the div tag.Do i need to any handle exception ? I am trying this as a sample exmple , my application needs this kind of functionality. Help me.
Source code as follows :
<%@taglib uri="/struts-tags" prefix="s" %>
<%@taglib uri="/struts-dojo-tags" prefix="sx" %>
<html>
<head><title>Ajax_Div_Tag_Example</title>
</head>
<body><h1>Ajax_Div_Tag_Example</h1><hr>
<sx:div id="div2" executeScripts="true" theme="ajax">Value</sx:div>
<s:form action="resultAction">
<s:textfield name="name" label="Name"></s:textfield>
<s:textfield name="age" label="Age"></s:textfield>
<sx:submit value="submit" targets="div2"> </sx:submit>
</s:form>
</body>
</html>
struts.xml
<action name="resultAction" class="ActionClasses.AjaxDivAction">
<result name="success">/resultPage.jsp</result>
</action>
resultPage.jsp
<%@taglib uri="/struts-tags" prefix="s" %>
<html>
<head><title>Ajax_Div_Tag_Example</title>
</head>
<body><hr>Name : <s:property value="name"/><br>
Age : <s:property value="age"/><hr>
</body>
</html>
AjaxDivAction.java
package ActionClasses;
import com.opensymphony.xwork2.ActionSupport;
public class AjaxDivAction extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = 1L;
private String name;
private String age;
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}
public String getName() {
return name;
}
Exception thrown is give below
org.apache.jasper.JasperException: An exception occurred processing JSP page /AjaxDemo.jsp at line 21
18:
19: <s:textfield name="age" label="Age"></s:textfield>
20:
21: <sx:submit value="submit" targets="div2"> </sx:submit>
22:
23: </s:form>
24:
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:519)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:410)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)
root cause
javax.servlet.ServletException: java.lang.AbstractMethodError
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:865)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:794)
org.apache.jsp.AjaxDemo_jsp._jspService(AjaxDemo_jsp.java:94)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)
root cause
java.lang.AbstractMethodError
org.apache.struts2.components.ClosingUIBean.start(ClosingUIBean.java:65)
org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:53)
org.apache.jsp.AjaxDemo_jsp._jspx_meth_sx_005fsubmit_005f0(AjaxDemo_jsp.java:242)
org.apache.jsp.AjaxDemo_jsp._jspx_meth_s_005fform_005f0(AjaxDemo_jsp.java:168)
org.apache.jsp.AjaxDemo_jsp._jspService(AjaxDemo_jsp.java:82)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:389)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.32 logs.
Thanks
Jagan