Creating a component to display a Flash movie (from a byte array) has been edited by Apaar Trivedi (Aug 03, 2007). Content:Although Wicket does not provide a Flash component right out of the box, it isn't hard at all to make one using some markup and a Resource. Given a byte array representing a Flash movie, all that is required is to be able to stream this back as a resource with the appropriate markup around it. The general idea is that you want to make some Component extending WebMarkupComponent and implementing IResourceListener so that it can be displayed as a component and return a flash movie as a resource to the resource stream. When You have such a class made, there a couple of things to do. One, you must implement onResourceRequested, this will write the flash bytes into the resource stream, and might look something like this: public void onResourceRequested() { getRequestCycle().setRequestTarget(new IRequestTarget() { public void respond(RequestCycle requestCycle) { requestCycle.getResponse()getOutputStream().write(getFlashBytes()); } }); } You may override onComponentTag to dynamically output the height and width of the Flash movie protected void onComponentTag(ComponentTag tag) { super.onComponentTag(tag); tag.put("width", WIDTH); tag.put("height", HEIGHT; } and finally to ensure that your markup is created correctly to display the Flash, you must override and implement onComponentTagBody as such: protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) { StringBuffer flashBuffer = new StringBuffer(); // in the following, we will append all the necessary body tags of flash markup flashBufferappend("<param name=\"movie\" value=\""); // urlFor will provide the link that will stream the flash byte array flashBuffer.append(urlFor(IResourceListener.INTERFACE)); flashBuffer.append("\"/>"); flashBuffer.append("<embed src="">"); flashBuffer.append(urlFor(IResourceListener.INTERFACE)); flashBuffer.append("\" width=\""); flashBuffer.append(WIDTH); flashBuffer.append("\" height=\""); flashBuffer.append(HEIGHT); flashBuffer.append("' quality=\"high\" name=\"movie\" align=\"middle\" plug inspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\">"); replaceComponentTagBody(markupStream, openTag, flashBody); } That is all that is required of the component to provide the Flash resource, and build the body markup. Finally, you want the actual markup of whoever adds this component (.html), to look like this: <object wicket:id="WICKET_ID_OF_COMPONENT" classid="" class="code-quote">"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="" class="code-quote">"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="350" height="100" id="movie" align="middle"> <!-- The markup from onComponentTagBody will go in here --> </object> And that is basically all that is required to display your flash movie that might be stored as a byte array in a database somewhere! |
Unsubscribe or edit your notifications preferences