You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by jill han <jh...@bynum.com> on 2009/01/05 22:38:02 UTC

how to reference a file in javascript

We have turbine/torque/velocity app. I submitted the question to
velocity user forum and was told I may get help here .
I tried to embed AnyChart to the velocity template. Here is the snippet
of .vm code:

<script type="text/javascript" language="javascript"> //<![CDATA[
	var chart1 = new
AnyChart("$content.getURI("swf/AnyChart.swf")");
	chart1.width="550px";
	chart1.height="400px";
	
chart1.setXMLFile("$content.getURI('servlet/nequals1/template/portal,dat
a,data.xml')");
	// or chart1.setXMLFile("./data.xml"); not working either
	chart1.write();
//]]>
</script>

However, somehow, the data.xml can't be processed properly and resulted
in IO error.

But, in the following simple anychart.jsp, the javascript has no problem
processing data.xml.  
http://prod.nequalsone.com/AnyChartExternalData/anychart.jsp 
 
<html>
  <head>
      <title>AnyChart external data sample</title>
  </head>
  <body>

<script type="text/javascript" language="javascript"
src="AnyChart.js"></script>
<script type="text/javascript" language="javascript">
//<![CDATA[
	var chart1 = new AnyChart("AnyChart.swf");
	chart1.width='750px';
	chart1.height='400px';
	chart1.setXMLFile('./data.xml');
	chart1.write(); 
//]]>
</script>
  </body>
</html>

Any helps and suggestions will be appreciated as always.

Jill

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
For additional commands, e-mail: user-help@turbine.apache.org


AW: how to reference a file in javascript

Posted by Juergen Hoffmann <ho...@apache.org>.
Hi Jill,

the "," syntax is from what I understand only valid in the
$data.setTemplate(...) Method. Not inside $content.setURI(...)

could you please just try to use the "/"

Kind Regards

Juergen

> -----Ursprüngliche Nachricht-----
> Von: jill han [mailto:jhan@bynum.com]
> Gesendet: Montag, 5. Januar 2009 22:38
> An: Turbine Users List
> Betreff: how to reference a file in javascript
> 
> We have turbine/torque/velocity app. I submitted the question to
> velocity user forum and was told I may get help here .
> I tried to embed AnyChart to the velocity template. Here is the snippet
> of .vm code:
> 
> <script type="text/javascript" language="javascript"> //<![CDATA[
> 	var chart1 = new
> AnyChart("$content.getURI("swf/AnyChart.swf")");
> 	chart1.width="550px";
> 	chart1.height="400px";
> 
> chart1.setXMLFile("$content.getURI('servlet/nequals1/template/portal,da
> t
> a,data.xml')");
> 	// or chart1.setXMLFile("./data.xml"); not working either
> 	chart1.write();
> //]]>
> </script>
> 
> However, somehow, the data.xml can't be processed properly and resulted
> in IO error.
> 
> But, in the following simple anychart.jsp, the javascript has no
> problem
> processing data.xml.
> http://prod.nequalsone.com/AnyChartExternalData/anychart.jsp
> 
> <html>
>   <head>
>       <title>AnyChart external data sample</title>
>   </head>
>   <body>
> 
> <script type="text/javascript" language="javascript"
> src="AnyChart.js"></script>
> <script type="text/javascript" language="javascript">
> //<![CDATA[
> 	var chart1 = new AnyChart("AnyChart.swf");
> 	chart1.width='750px';
> 	chart1.height='400px';
> 	chart1.setXMLFile('./data.xml');
> 	chart1.write();
> //]]>
> </script>
>   </body>
> </html>
> 
> Any helps and suggestions will be appreciated as always.
> 
> Jill
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
> For additional commands, e-mail: user-help@turbine.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
For additional commands, e-mail: user-help@turbine.apache.org


RE: how to reference a file in javascript

Posted by Sheldon Ross <ro...@hotmail.com>.
I'm assuming you have something like 
$page.addScript($content.getRelativeURI("scripts/chart.js"))
at the top to include your chart js.

It looks to me like your address string is incorrect in the getURI string for data.xml

> Subject: how to reference a file in javascript
> Date: Mon, 5 Jan 2009 15:38:02 -0600
> From: jhan@bynum.com
> To: user@turbine.apache.org
> 
> We have turbine/torque/velocity app. I submitted the question to
> velocity user forum and was told I may get help here .
> I tried to embed AnyChart to the velocity template. Here is the snippet
> of .vm code:
> 
> <script type="text/javascript" language="javascript"> //<![CDATA[
> 	var chart1 = new
> AnyChart("$content.getURI("swf/AnyChart.swf")");
> 	chart1.width="550px";
> 	chart1.height="400px";
> 	
> chart1.setXMLFile("$content.getURI('servlet/nequals1/template/portal,dat
> a,data.xml')");
> 	// or chart1.setXMLFile("./data.xml"); not working either
> 	chart1.write();
> //]]>
> </script>
> 
> However, somehow, the data.xml can't be processed properly and resulted
> in IO error.
> 
> But, in the following simple anychart.jsp, the javascript has no problem
> processing data.xml.  
> http://prod.nequalsone.com/AnyChartExternalData/anychart.jsp 
>  
> <html>
>   <head>
>       <title>AnyChart external data sample</title>
>   </head>
>   <body>
> 
> <script type="text/javascript" language="javascript"
> src="AnyChart.js"></script>
> <script type="text/javascript" language="javascript">
> //<![CDATA[
> 	var chart1 = new AnyChart("AnyChart.swf");
> 	chart1.width='750px';
> 	chart1.height='400px';
> 	chart1.setXMLFile('./data.xml');
> 	chart1.write(); 
> //]]>
> </script>
>   </body>
> </html>
> 
> Any helps and suggestions will be appreciated as always.
> 
> Jill
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
> For additional commands, e-mail: user-help@turbine.apache.org
> 

_________________________________________________________________
Life on your PC is safer, easier, and more enjoyable with Windows Vista®. 
http://clk.atdmt.com/MRT/go/127032870/direct/01/