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 <[EMAIL PROTECTED]> wrote:
> call urlfor(resourcereference)....
>
> -igor
>
> On Tue, Sep 30, 2008 at 6:08 PM, Ryan McKinley <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]