Sign in to follow this  
deepti

Spring Mvc - Update Fusioncharts From Ajax Response.

Recommended Posts

Hi,

 

I am trying to integrate spring mvc with ajax.I want to get the chart xml and swf from ajax response and set it to the chart and display the chart.The call back function is getting called and I can see the xml in the firebug response object . Even though I have provided the swf and xml the chart is not getting loaded initially also.I am not sure if the FusionChartsRenderer.jsp is getting included in the page because I am not able to see as if it is included when I see the firebug response when the page is initially loaded.And in the updateChart function getChartFromId("FactorySum") is returning null.I have the fusionchart.js file in classpatha nd it is getting loaded also. Pls help.

Following is my jsp code :

 

 

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>

<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

<%@ page session="false"%>

 

<tags:template>

<jsp:attribute name="breadcrumb">Plant View</jsp:attribute>

<jsp:body>

 

<table border="0" cellpadding="0" cellspacing="0" width="100%"

id="qdtable">

<c:forEach items="${qd_List}" var="qdItem">

<tr id="qdtabletr">

<td width="220" style="text-align: center; vertical-align: middle"

id="qdtabletd1">

${qdItem.source}</td>

<td

style="vertical-align: middle; horizontal-align: right; width: 350px;"

id="qdtabletd2">${qdItem.metric}</td>

<td id="qdtabletd3">

<form:select id="${qdItem.id}" path="qd_List"

items="${qdItem.timePeriodList}" /></td>

<td><a href="#" id="executeChart">Execute</a></td>

</tr>

</c:forEach>

</table>

 

<div id="chartIdDiv"></div>

<div id="chartRegion">

<jsp:include page="FusionChartsRenderer.jsp" flush="true">

<jsp:param name="chartSWF"

value="/fusioncharts/Line.swf" />

<jsp:param name="strURL" value="" />

<jsp:param name="strXML" value="/fusioncharts/Data.xml" />

<jsp:param name="chartId" value="FactorySum" />

<jsp:param name="chartWidthStr" value="600" />

<jsp:param name="chartHeightStr" value="300" />

<jsp:param name="debugModeStr" value="true" />

<jsp:param name="registerWithJSStr" value="true" />

</jsp:include>

<BR>

<BR>

<a href='./html/NoChart.html' target="_blank">Unable to see the chart above?</a>

 

</div>

 

</jsp:body>

</tags:template>

<script type="text/javascript">

jq(document).ready(function() {

jq('#qdtable tbody tr td #executeChart').click(function () {

jq(this).closest('tr').find("select").each(function() {

getQualityMetricChart(this.id,this.value);

});

});

});

function getQualityMetricChart(id,tmPeriod) {

jq.getJSON("pview/getChart", {id:id,timePeriod:tmPeriod}, function(success) {

alert("callback");

jq('#chartIdDiv').html("<span id='chartFS'>" + success.swfPath + "</span>");

updateChart(success.chartXml,success.swfPath)

});

 

function updateChart(xml,swf){

alert('up');

var chartObj = getChartFromId("FactorySum");

chartObj.setSWFPath(swf);

chartObj.setDataXML(xml);

}

 

}

</script>

Edited by deepti

Share this post


Link to post
Share on other sites

Hi,

 

I am trying to integrate spring mvc with ajax.I want to get the chart xml and swf from ajax response and set it to the chart and display the chart.The call back function is getting called and I can see the xml in the firebug response object . Even though I have provided the swf and xml the chart is not getting loaded initially also.I am not sure if the FusionChartsRenderer.jsp is getting included in the page because I am not able to see as if it is included when I see the firebug response when the page is initially loaded.And in the updateChart function getChartFromId("FactorySum") is returning null.I have the fusionchart.js file in classpatha nd it is getting loaded also. Pls help.

Following is my jsp code :

 

 

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>

<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

<%@ page session="false"%>

 

<tags:template>

<jsp:attribute name="breadcrumb">Plant View</jsp:attribute>

<jsp:body>

 

<table border="0" cellpadding="0" cellspacing="0" width="100%"

id="qdtable">

<c:forEach items="${qd_List}" var="qdItem">

<tr id="qdtabletr">

<td width="220" style="text-align: center; vertical-align: middle"

id="qdtabletd1">

${qdItem.source}</td>

<td

style="vertical-align: middle; horizontal-align: right; width: 350px;"

id="qdtabletd2">${qdItem.metric}</td>

<td id="qdtabletd3">

<form:select id="${qdItem.id}" path="qd_List"

items="${qdItem.timePeriodList}" /></td>

<td><a href="#" id="executeChart">Execute</a></td>

</tr>

</c:forEach>

</table>

 

<div id="chartIdDiv"></div>

<div id="chartRegion">

<jsp:include page="FusionChartsRenderer.jsp" flush="true">

<jsp:param name="chartSWF"

value="/fusioncharts/Line.swf" />

<jsp:param name="strURL" value="" />

<jsp:param name="strXML" value="/fusioncharts/Data.xml" />

<jsp:param name="chartId" value="FactorySum" />

<jsp:param name="chartWidthStr" value="600" />

<jsp:param name="chartHeightStr" value="300" />

<jsp:param name="debugModeStr" value="true" />

<jsp:param name="registerWithJSStr" value="true" />

</jsp:include>

<BR>

<BR>

<a href='./html/NoChart.html' target="_blank">Unable to see the chart above?</a>

 

</div>

 

</jsp:body>

</tags:template>

<script type="text/javascript">

jq(document).ready(function() {

jq('#qdtable tbody tr td #executeChart').click(function () {

jq(this).closest('tr').find("select").each(function() {

getQualityMetricChart(this.id,this.value);

});

});

});

function getQualityMetricChart(id,tmPeriod) {

jq.getJSON("pview/getChart", {id:id,timePeriod:tmPeriod}, function(success) {

alert("callback");

jq('#chartIdDiv').html("<span id='chartFS'>" + success.swfPath + "</span>");

updateChart(success.chartXml,success.swfPath)

});

 

function updateChart(xml,swf){

alert('up');

var chartObj = getChartFromId("FactorySum");

chartObj.setSWFPath(swf);

chartObj.setDataXML(xml);

}

 

}

</script>

 

Hi,

Can Anyone please help me with this?

 

Deepti.

Edited by deepti

Share this post


Link to post
Share on other sites

Hi,

Can Anyone please help me with this?

 

Deepti.

 

When I try to include the Fusionchartsrendere.jsp page I am getting the following exception :

 

14:07:23,877 FATAL [JspFactoryImpl] Exception initializing page context

java.lang.IllegalStateException: Cannot create a session after the response has been committed

at org.apache.catalina.connector.Request.doGetSession(Request.java:2301)

at org.apache.catalina.connector.Request.getSession(Request.java:2075)

at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)

at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)

at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:545)

at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)

at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:545)

at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:494)

at org.apache.jasper.runtime.PageContextImpl._initialize(PageContextImpl.java:144)

at org.apache.jasper.runtime.PageContextImpl.initialize(PageContextImpl.java:122)

at org.apache.jasper.runtime.JspFactoryImpl.internalGetPageContext(JspFactoryImpl.java:106)

at org.apache.jasper.runtime.JspFactoryImpl.getPageContext(JspFactoryImpl.java:62)

at org.apache.jsp.WEB_002dINF.views.FusionChartsRenderer_jsp._jspService(FusionChartsRenderer_jsp.java:59)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)

at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:557)

at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:481)

at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)

at org.apache.jsp.WEB_002dINF.views.plantview_jsp$plantview_jspHelper.invoke0(plantview_jsp.java:243)

at org.apache.jsp.WEB_002dINF.views.plantview_jsp$plantview_jspHelper.invoke(plantview_jsp.java:266)

at org.apache.jsp.tag.web.template_tag.doTag(template_tag.java:132)

at org.apache.jsp.WEB_002dINF.views.plantview_jsp._jspx_meth_tags_005ftemplate_005f0(plantview_jsp.java:122)

at org.apache.jsp.WEB_002dINF.views.plantview_jsp._jspService(plantview_jsp.java:68)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)

at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)

at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)

at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)

at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)

at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)

at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1031)

at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:815)

at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:717)

at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)

at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

 

I think that is the reason for the whole problem.Can anyone plese help.

 

Thanks,

Deepti.

Share this post


Link to post
Share on other sites

When I try to include the Fusionchartsrendere.jsp page I am getting the following exception :

 

14:07:23,877 FATAL [JspFactoryImpl] Exception initializing page context

java.lang.IllegalStateException: Cannot create a session after the response has been committed

at org.apache.catalina.connector.Request.doGetSession(Request.java:2301)

at org.apache.catalina.connector.Request.getSession(Request.java:2075)

at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:833)

at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)

at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:545)

at javax.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:216)

at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:545)

at org.apache.catalina.core.ApplicationHttpRequest.getSession(ApplicationHttpRequest.java:494)

at org.apache.jasper.runtime.PageContextImpl._initialize(PageContextImpl.java:144)

at org.apache.jasper.runtime.PageContextImpl.initialize(PageContextImpl.java:122)

at org.apache.jasper.runtime.JspFactoryImpl.internalGetPageContext(JspFactoryImpl.java:106)

at org.apache.jasper.runtime.JspFactoryImpl.getPageContext(JspFactoryImpl.java:62)

at org.apache.jsp.WEB_002dINF.views.FusionChartsRenderer_jsp._jspService(FusionChartsRenderer_jsp.java:59)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)

at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:557)

at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:481)

at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:968)

at org.apache.jsp.WEB_002dINF.views.plantview_jsp$plantview_jspHelper.invoke0(plantview_jsp.java:243)

at org.apache.jsp.WEB_002dINF.views.plantview_jsp$plantview_jspHelper.invoke(plantview_jsp.java:266)

at org.apache.jsp.tag.web.template_tag.doTag(template_tag.java:132)

at org.apache.jsp.WEB_002dINF.views.plantview_jsp._jspx_meth_tags_005ftemplate_005f0(plantview_jsp.java:122)

at org.apache.jsp.WEB_002dINF.views.plantview_jsp._jspService(plantview_jsp.java:68)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:336)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)

at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)

at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)

at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)

at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)

at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)

at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1031)

at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:815)

at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:717)

at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)

at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

 

I think that is the reason for the whole problem.Can anyone plese help.

 

Thanks,

Deepti.

 

 

Hi,

 

I am able to inlcude a simple jsp page.But when I include FusionChartsRenderer.jsp I am getting the above exception and hence not able to get the Fusioncharts working with spring mvc. I hope some one will be able to help.

 

Thanks,

Deepti.

Share this post


Link to post
Share on other sites
Guest Bindhu

Hi,

 

I am afraid, we do not have any implementation of FusionCharts with Spring MVC, as of now.

 

Hope this helps!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this