ktsha

Problem with parameter passing of a javascript function in XML

Recommended Posts

Dear All,

 

 

 

I got a doubt,Please clear it.

 

 

 

This is the current Code

 

 

 

 

 

 

 

below code is in XML

 

LinkStr = "' link='javaScript:updateChart( "" + FuncName + "","" + (String) map.get("status_name") + "",""



+ DrillDownKPI + "")' />";



 

 

 

 

 

and this is the updateChart javascript function (XMLchart.js)

 

function updateChart(Mngmnt,stutus,kpi,serviceID)

 

 

 

{

 

 

 

var strURL = "ChartServlet?GM=" + Mngmnt + "&status=" +stutus + "&kpi=" +kpi;

 

 

 

strURL = escape(strURL);

 

 

 

var chart_CityDetails = new FusionCharts('FusionCharts/StackedBar3D.swf?ChartNoDataText=Click right chart to view Services Details', 'ServDetails', '550', '450', '0', '1');

 

 

 

chart_CityDetails.setDataURL(strURL);

 

 

 

chart_CityDetails.render(Mngmnt+kpi+"ServDetailsDiv");

 

 

 

}

 

 

 

 

 

 

 

I want to pass a new parameter 'condQuery ' query with the link in XML

 

 

 

i tried this

 

 

 

LinkStr = "' link='javaScript:updateFusionChart( "" + condQuery + "","" + FuncName + "","" + (String) map.get("status_name") + "",""



+ DrillDownKPI + "")' />";



 

 

 

 

 

 

 

and updated javascript function as

 

 

 

 

 

 

 

function updateChart (condQuery,Mngmnt,stutus,kpi,serviceID){

 

 

 

 

 

 

 

var strURL = "ChartServlet?GM=" + Mngmnt + "&status=" +stutus + "&kpi=" +kpi+ "&condQuery=" +condQuery;

 

 

 

strURL = escape(strURL);

 

 

 

var chart_CityDetails = new FusionCharts('FusionCharts/StackedBar3D.swf?ChartNoDataText=Click right chart to view Services Details',

 

 

 

'ServDetails', '550', '450', '0', '1');

 

 

 

chart_CityDetails.setDataURL(strURL);

 

 

 

chart_CityDetails.render(Mngmnt+kpi+"ServDetailsDiv");

 

 

 

}

 

 

 

 

 

But after execution it was showing as Invalid XML Data. Is there any problem with the parameter passing ??

 

 

 

Any help will be appreciated...

Edited by Guest

Share this post


Link to post
Share on other sites

The problem is Solved. It was because of HTML Encoding problem .

 

 

 

Use the below method

 

 

 

public static String HTMLEntityEncode( String s )

 

{

 

StringBuffer buf = new StringBuffer();

 

int len = (s == null ? -1 : s.length());

 

 

 

for ( int i = 0; i < len; i++ )

 

{

 

char c = s.charAt( i );

 

if ( c>='a' && c<='z' || c>='A' && c<='Z' || c>='0' && c<='9' )

 

{

 

buf.append( c );

 

}

 

else

 

{

 

buf.append( "" + (int)c + ";" );

 

}

 

}

 

return buf.toString();

 

}

 

 

 

 

or

 

 

 

URLEcnoder class.There we have an encode method which will do the same

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