tbt wrote:
> Hi
> I am using flash in my web application and currently using the example
> given at
> http://cwiki.apache.org/WICKET/object-container-adding-flash-to-a-wicket-application.html
> This works fine but my swf files are stored in a database and when
> displayed now is converted back into a swf file and stored in a temperory
> folder on the server. Then the image path is given to the swf file as
> provided in the example. But I would like to make this more efficient and
> like to pass the swf file stored in the db as a 'Resource'. I currently do
> this with the image files stored in the database like
> BlobImageResource blobImageResource = new BlobImageResource()
> {
>       @Override
>       protected Blob getBlob() 
>       {
>               return images.getImageFile();
>       }
> };  
> Image uploadImage = new Image("uploadImage",blobImageResource);
> to display the images in the webpage.
> How can I do something similar with the 'ShockWaveComponent' class so that
> a 'Resource' can be passed as a constructor parameter
> Thanks


I came up with the following flash component to display an swf file stored
in a database. It is attached above. 
http://www.nabble.com/file/p21408684/FlashComponent.txt FlashComponent.txt 

The example given below was used to code this flash component

The following class was coded by Robert Mattler which reads flash data
stored in a file.

public class FlashComponent extends WebMarkupContainer implements
IResourceListener {

    int width;
    int height;
    String fileName;

    public FlashComponent(String id, int width, int height, String fileName)
        this.width = width;
        this.height = height;
        this.fileName = fileName;

    public void onResourceRequested() {

        getRequestCycle().setRequestTarget(new IRequestTarget() {

            public void respond(RequestCycle requestCycle) {

                try {
                } catch (IOException e) {

            public void detach(RequestCycle requestCycle) {
                // TODO Auto-generated method stub


    protected void onComponentTagBody(MarkupStream markupStream,
ComponentTag openTag) {

        StringBuffer flashBuffer = new StringBuffer();

        // in the following, we will append all the necessary body tags of
        // markup
        flashBuffer.append("<embed src=\"");
        flashBuffer.append("\" width=\"");
        flashBuffer.append("\" height=\"");

        replaceComponentTagBody(markupStream, openTag, flashBuffer);


    protected byte[] getFlashByteArray() {

        try {
            File inputFile = new File(fileName);
            InputStream inStream = new FileInputStream(inputFile);

            if (inStream != null) {
                ByteArrayOutputStream out = new ByteArrayOutputStream();
                Streams.copy(inStream, out);
                return out.toByteArray();


            return new byte[0];
        } catch (IOException e) {
            throw new WicketRuntimeException("Error while reading flash
data", e);




additional comments and suggestions regarding these components are welcome.
It would also be great to have a built in wicket flash component like
'Image' which has many constructors so that users could pass the filename,
width, height or even a 'Resource' as a parameter.

View this message in context: 
Sent from the Wicket - User mailing list archive at Nabble.com.

To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to