You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Ryan McKinley <ry...@lapnap.net> on 2008/10/01 03:08:08 UTC
linking to a text ResourceReference
Hello-
I know I have seen an example of this somewhere, so i'm feeling kinda
silly as I ask for help....
I am trying to integrate Open Flash Charts (OFC) with wicket. You
pass OFC a url containing json to draw a chart. Something like:
<script type="text/javascript">
var so = new SWFObject("/open-flash-chart.swf", "chart", "500",
"300", "9", "#FFFFFF");
so.addVariable("data-file", "${TODO -- need to have link to data}" );
so.addParam("allowScriptAccess", "sameDomain");
so.write("my_chart");
</script>
I know I can use a global mount point, but I'm looking to do something
similar to how JFreeChart works
http://cwiki.apache.org/WICKET/jfreechart-and-wicket-example.html
Where you have a Chart object in the Component scope and various
actions can manipulate it.
I can create a WebResource -- but how would I pass the URL to
javascript?
Any pointers would be great!
thanks
ryan
Re: linking to a text ResourceReference
Posted by CrocodileShoes <ma...@logica.com>.
I found the problem. It seems the url must be encoded otherwise the OFC
cannot find the data file. I don't have an account on apache yet so I can't
update the wiki.
private String getUrlForJson() {
CharSequence dataPath = RequestCycle.get().urlFor(OpenFlashChart.this,
IResourceListener.INTERFACE);
//######### ADDED THIS ###############################
try {
dataPath = URLEncoder.encode(dataPath.toString(), "UTF-8");
}
catch (UnsupportedEncodingException e) {
LOGGER.error("Error encoding dataPath for Chart Json data file. Details:
" + e);
}
//################################################
return RequestUtils.toAbsolutePath(dataPath.toString());
}
--
View this message in context: http://www.nabble.com/linking-to-a-text-ResourceReference-tp19753402p24458873.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: linking to a text ResourceReference
Posted by CrocodileShoes <ma...@logica.com>.
Hello,
I'm trying to get SWFObject and Open Flash Charts running in my web app.
I'm receiving the following error where the chart should be:
Open Flash Chart
JSON Parse Error [Syntax Error]
Error at character 0, line 1:
-2: undefined-1: undefined0: <!DOCTYP
I'm sure this is generated by the ofc.swf but i can't figure out why! I'm
ruling out each component one at a time so my question is could this be
related to SWFObject or the OpenFlashChart classes?
--
View this message in context: http://www.nabble.com/linking-to-a-text-ResourceReference-tp19753402p24431195.html
Sent from the Wicket - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: linking to a text ResourceReference
Posted by Ryan McKinley <ry...@lapnap.net>.
thanks!
I knew it was one line. You guys are great!
On Sep 30, 2008, at 10:39 PM, Igor Vaynberg wrote:
> call urlfor(resourcereference)....
>
> -igor
>
> On Tue, Sep 30, 2008 at 6:08 PM, Ryan McKinley <ry...@lapnap.net>
> wrote:
>> Hello-
>>
>> I know I have seen an example of this somewhere, so i'm feeling
>> kinda silly
>> as I ask for help....
>>
>> I am trying to integrate Open Flash Charts (OFC) with wicket. You
>> pass OFC
>> a url containing json to draw a chart. Something like:
>>
>> <script type="text/javascript">
>> var so = new SWFObject("/open-flash-chart.swf", "chart", "500",
>> "300", "9",
>> "#FFFFFF");
>> so.addVariable("data-file", "${TODO -- need to have link to data}" );
>> so.addParam("allowScriptAccess", "sameDomain");
>> so.write("my_chart");
>> </script>
>>
>> I know I can use a global mount point, but I'm looking to do
>> something
>> similar to how JFreeChart works
>> http://cwiki.apache.org/WICKET/jfreechart-and-wicket-example.html
>>
>> Where you have a Chart object in the Component scope and various
>> actions can
>> manipulate it.
>>
>> I can create a WebResource -- but how would I pass the URL to
>> javascript?
>>
>> Any pointers would be great!
>> thanks
>> ryan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: linking to a text ResourceReference
Posted by Maarten Bosteels <mb...@gmail.com>.
Hello Ryan,
Would you be so kind to add some more details about your OpenFlashChart
component ?
* Could you post the html that goes with the OpenFlashChart component ?
* Could you also provide source code of the SWFObject that are you using ?
Is it based on the http://issues.apache.org/jira/browse/WICKET-309 with
some modifications ?
* Is it using http://code.google.com/p/swfobject/ ?
Thanks in advance,
Maarten
On Thu, Oct 2, 2008 at 1:39 AM, Ryan McKinley <ry...@gmail.com> wrote:
> Thanks igor!
>
> another message of yours helped too:
>
> http://www.nabble.com/Generate-URL-for-a-Resource-depending-on-component-state-td18941798.html
>
> for the record, here is some code for the next guy searching the
> archives...
>
> public class OpenFlashChart extends Panel implements IResourceListener
> {
> static final ResourceReference SWF = new ResourceReference(
> OpenFlashChart.class, "open-flash-chart.swf" );
>
> final WebResource jsonResource;
> final SWFObject swf;
>
> public OpenFlashChart(String id, final int width, final int height)
> {
> this( id, width+"", height+"" );
> }
>
> public OpenFlashChart(String id, final String width, final String height)
> {
> super(id);
>
> final IResourceStream json = new AbstractStringResourceStream(
> "text/plain") {
> @Override
> public String getString() {
> return "YOUR STRING HERE...";
> }
> };
>
> jsonResource = new WebResource() {
> @Override
> public IResourceStream getResourceStream() {
> return json;
> }
> };
> jsonResource.setCacheable(false);
>
> String swfURL = RequestUtils.toAbsolutePath( urlFor( SWF ).toString() );
> swf = new SWFObject( "chart", swfURL, "500", "300" );
> add( swf );
> }
>
> @Override
> protected void onBeforeRender() {
> CharSequence dataPath =
> RequestCycle.get().urlFor(OpenFlashChart.this,
> IResourceListener.INTERFACE);
>
> String data = RequestUtils.toAbsolutePath( dataPath.toString() );
>
> swf.setFlashvar( "data-file", data );
> swf.setParam( "allowScriptAccess", "sameDomain" );
>
> super.onBeforeRender();
> }
>
> /**
> * Actually handle the request
> */
> @Override
> public void onResourceRequested() {
> jsonResource.onResourceRequested();
> }
> }
>
>
> On Tue, Sep 30, 2008 at 10:39 PM, Igor Vaynberg <ig...@gmail.com>
> wrote:
> > call urlfor(resourcereference)....
> >
> > -igor
> >
> > On Tue, Sep 30, 2008 at 6:08 PM, Ryan McKinley <ry...@lapnap.net> wrote:
> >> Hello-
> >>
> >> I know I have seen an example of this somewhere, so i'm feeling kinda
> silly
> >> as I ask for help....
> >>
> >> I am trying to integrate Open Flash Charts (OFC) with wicket. You pass
> OFC
> >> a url containing json to draw a chart. Something like:
> >>
> >> <script type="text/javascript">
> >> var so = new SWFObject("/open-flash-chart.swf", "chart", "500", "300",
> "9",
> >> "#FFFFFF");
> >> so.addVariable("data-file", "${TODO -- need to have link to data}" );
> >> so.addParam("allowScriptAccess", "sameDomain");
> >> so.write("my_chart");
> >> </script>
> >>
> >> I know I can use a global mount point, but I'm looking to do something
> >> similar to how JFreeChart works
> >> http://cwiki.apache.org/WICKET/jfreechart-and-wicket-example.html
> >>
> >> Where you have a Chart object in the Component scope and various actions
> can
> >> manipulate it.
> >>
> >> I can create a WebResource -- but how would I pass the URL to
> javascript?
> >>
> >> Any pointers would be great!
> >> thanks
> >> ryan
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
Re: linking to a text ResourceReference
Posted by Ryan McKinley <ry...@gmail.com>.
Thanks igor!
another message of yours helped too:
http://www.nabble.com/Generate-URL-for-a-Resource-depending-on-component-state-td18941798.html
for the record, here is some code for the next guy searching the archives...
public class OpenFlashChart extends Panel implements IResourceListener
{
static final ResourceReference SWF = new ResourceReference(
OpenFlashChart.class, "open-flash-chart.swf" );
final WebResource jsonResource;
final SWFObject swf;
public OpenFlashChart(String id, final int width, final int height)
{
this( id, width+"", height+"" );
}
public OpenFlashChart(String id, final String width, final String height)
{
super(id);
final IResourceStream json = new AbstractStringResourceStream(
"text/plain") {
@Override
public String getString() {
return "YOUR STRING HERE...";
}
};
jsonResource = new WebResource() {
@Override
public IResourceStream getResourceStream() {
return json;
}
};
jsonResource.setCacheable(false);
String swfURL = RequestUtils.toAbsolutePath( urlFor( SWF ).toString() );
swf = new SWFObject( "chart", swfURL, "500", "300" );
add( swf );
}
@Override
protected void onBeforeRender() {
CharSequence dataPath =
RequestCycle.get().urlFor(OpenFlashChart.this,
IResourceListener.INTERFACE);
String data = RequestUtils.toAbsolutePath( dataPath.toString() );
swf.setFlashvar( "data-file", data );
swf.setParam( "allowScriptAccess", "sameDomain" );
super.onBeforeRender();
}
/**
* Actually handle the request
*/
@Override
public void onResourceRequested() {
jsonResource.onResourceRequested();
}
}
On Tue, Sep 30, 2008 at 10:39 PM, Igor Vaynberg <ig...@gmail.com> wrote:
> call urlfor(resourcereference)....
>
> -igor
>
> On Tue, Sep 30, 2008 at 6:08 PM, Ryan McKinley <ry...@lapnap.net> wrote:
>> Hello-
>>
>> I know I have seen an example of this somewhere, so i'm feeling kinda silly
>> as I ask for help....
>>
>> I am trying to integrate Open Flash Charts (OFC) with wicket. You pass OFC
>> a url containing json to draw a chart. Something like:
>>
>> <script type="text/javascript">
>> var so = new SWFObject("/open-flash-chart.swf", "chart", "500", "300", "9",
>> "#FFFFFF");
>> so.addVariable("data-file", "${TODO -- need to have link to data}" );
>> so.addParam("allowScriptAccess", "sameDomain");
>> so.write("my_chart");
>> </script>
>>
>> I know I can use a global mount point, but I'm looking to do something
>> similar to how JFreeChart works
>> http://cwiki.apache.org/WICKET/jfreechart-and-wicket-example.html
>>
>> Where you have a Chart object in the Component scope and various actions can
>> manipulate it.
>>
>> I can create a WebResource -- but how would I pass the URL to javascript?
>>
>> Any pointers would be great!
>> thanks
>> ryan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: linking to a text ResourceReference
Posted by Igor Vaynberg <ig...@gmail.com>.
call urlfor(resourcereference)....
-igor
On Tue, Sep 30, 2008 at 6:08 PM, Ryan McKinley <ry...@lapnap.net> wrote:
> Hello-
>
> I know I have seen an example of this somewhere, so i'm feeling kinda silly
> as I ask for help....
>
> I am trying to integrate Open Flash Charts (OFC) with wicket. You pass OFC
> a url containing json to draw a chart. Something like:
>
> <script type="text/javascript">
> var so = new SWFObject("/open-flash-chart.swf", "chart", "500", "300", "9",
> "#FFFFFF");
> so.addVariable("data-file", "${TODO -- need to have link to data}" );
> so.addParam("allowScriptAccess", "sameDomain");
> so.write("my_chart");
> </script>
>
> I know I can use a global mount point, but I'm looking to do something
> similar to how JFreeChart works
> http://cwiki.apache.org/WICKET/jfreechart-and-wicket-example.html
>
> Where you have a Chart object in the Component scope and various actions can
> manipulate it.
>
> I can create a WebResource -- but how would I pass the URL to javascript?
>
> Any pointers would be great!
> thanks
> ryan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org