jeraldmuthu 0 Newbie Poster

Hi

i have generating xml file for chart(fusion chart).

that chart having swf format file for each chart.

i'm creating xml in case statement( case 1 for horizontal bar xml(file),case 2 for verical bar xml(file))


i have created that file by giving straight path it is not servlet it is java so i cant get Context path. how can i get that context path of webapplication

switch (chartType) {
		case 1:
			
			  DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
		        DocumentBuilder docBuilder = builderFactory.newDocumentBuilder();
		        Document doc = docBuilder.newDocument();
		        
			
			
			dataset = adapter.buildCategoryDataset(olapModel);
			String st = dataset.getColumnKeys().toString();
			String st1 = dataset.getRowKeys().toString();
				
			String cols1 = st.replace("[", "");
			String rows1 = st1.replace("[", "");
			String cols = cols1.replace("]", "");
			String rows = rows1.replace("]", "");
			Number values;
			String values1;
			String casevalue1="1";
		
			 String strXML;
		
			String[] tempCols=new String[250];
			String[] tempRows=new String[250];
			String[] tempValues=new String[250];
			 strXML = "<chart caption='My first chart'>";
			String delimiter = ", ";

			tempCols = cols.split(delimiter);
			
			strXML += "<categories>";
			
			for(int i=0 ; i < tempCols.length; i++) {
				strXML += "<category label = '";// now run
				strXML += tempCols[i];
				strXML += "'/>";
			}
			strXML +="</categories>";
			tempRows = rows.split(delimiter);
			
			for(int j = 0; j < tempRows.length; j++) {
				
				strXML += "<dataset seriesname='";
				strXML += tempRows[j];
				strXML += "'>";
				
				for(int l=0 ; l < tempCols.length; l++)
				{
					values = (dataset.getValue(tempRows[j], tempCols[l]));
				String values2=values.toString();
				tempValues = values2.split(delimiter);
				for(int k = 0; k < tempValues.length; k++) {
					strXML += "<set value = '";
					strXML += tempValues[k];
					strXML += "'/>";
				}
			}
				strXML += "</dataset>";
			}
			
		

			strXML += "</chart>";
			
			System.out.println(strXML);
	
				Writer output = null;
				File file = new File("C:\\Users\\ssss\\Desktop\\web3\\WebContent\\Charts\\test.xml");
				 output = new BufferedWriter(new FileWriter(file));
				 output.write(strXML);
				 output.close();


                  		case 2:
			dataset = adapter.buildCategoryDataset(olapModel);
			
			String st4 = dataset.getColumnKeys().toString();
			String st5 = dataset.getRowKeys().toString();
			String cols3 = st4.replace("[", "");
			String rows3 = st5.replace("[", "");
			String cols2 = cols3.replace("]", "");
			String rows2 = rows3.replace("]", "");
			Number values3;
			String values4;
			 String strXML1;
			 String chartId1 = "basicChart";
			 String url1 = "Charts/test.xml";
			 String width1 = "600";
			 String height1 = "300";
			 String folderPath1="Charts/FusionCharts.js";
			 String swfFilename1 = "Charts/Column3D.swf";
			 String uniqueId1 = "";
			
			String[] tempCols1=new String[250];
			String[] tempRows1=new String[250];
			String[] tempValues1=new String[250];
			 strXML = "<chart caption='My first chart'>";
			String delimiter1 = ", ";

			tempCols = cols2.split(delimiter1);
			
			strXML += "<categories>";
			for(int i=0 ; i < tempCols.length; i++) {
				strXML += "<category label = '";// now run
				strXML += tempCols[i];
				strXML += "'/>";
			}
			strXML +="</categories>";
			tempRows = rows2.split(delimiter1);
			
			for(int j = 0; j < tempRows.length; j++) {
				
				strXML += "<dataset seriesname='";
				strXML += tempRows[j];
				strXML += "'>";
				
				for(int l=0 ; l < tempCols.length; l++)
				{
				
				values = (dataset.getValue(tempRows[j], tempCols[l]));
				String values2=values.toString();
				tempValues = values2.split(delimiter1);
				for(int k = 0; k < tempValues.length; k++) {
					strXML += "<set value = '";
					strXML += tempValues[k];
					strXML += "'/>";
				}
				
			}
				strXML += "</dataset>";
			}
			
		

			strXML += "</chart>";
			
			
				System.out.println(strXML);
	
				Writer output1 = null;
				File file1 = new File("C:\\Users\\ssss\\Desktop\\web\\WebContent\\Charts\\test23.xml");
			 output = new BufferedWriter(new FileWriter(file1));
				 output.write(strXML);
				 output.close();

in xhtml the javscript used for this fusion chart only we want give xml for .swf it will create chart for that.

in that java there 4 cases in switch statement 4 case will generate 4 different type of Xml with different xml(name)

but i need to pass that xml in one javascript

How can i pass that generate xml file in case statement to java script

<tr>
			    <td align='center'>
				<div id="chart8Div">
				  Piechart.
				</div>
				<script type="text/javascript">
					var chart4 = new FusionCharts("Charts1/MultiLevelPie.swf", "ChId3", "400", "400", "0", "1");
					chart4.setXMLUrl("Charts1/test.xml");
					chart4.render("chart8Div");
				</script>
			  </td>
               </tr>

Help me to fix this Error

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.