|
Page Created :
WICKET :
Open Flash Chart and Wicket
Open Flash Chart and Wicket has been created by Ryan McKinley (Dec 05, 2008). Content:Here is a starter to use Open Flash Charts and Wicket: /** * @see <a href="" class="code-quote">"http://code.google.com/p/swfobject/">SWFObject</a> */ 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; final IModel<Chart> chart; public OpenFlashChart(final String id, final IModel<Chart> chart, final int width, final int height) { this( id, chart, width+"", height+"" ); } public OpenFlashChart(final String id, final IModel<Chart> chart, final String width, final String height) { super(id); this.chart = chart; final IResourceStream json = new AbstractStringResourceStream( "text/plain") { @Override public String getString() { return chart.getObject().toString(); } }; 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 = "" dataPath.toString() ); swf.setFlashvar( "data-file", data ); swf.setParam( "allowScriptAccess", "sameDomain" ); super.onBeforeRender(); } /** * Actually handle the request */ public void onResourceRequested() { jsonResource.onResourceRequested(); } } |
Powered by
Atlassian Confluence
(Version: 2.2.9 Build:#527 Sep 07, 2006)
-
Bug/feature request
Unsubscribe or edit your notifications preferences
Unsubscribe or edit your notifications preferences
