You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by tbt <na...@yahoo.com> on 2008/11/26 11:35:28 UTC
flash with resource
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
--
View this message in context: http://www.nabble.com/flash-with-resource-tp20698407p20698407.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: flash with resource
Posted by tbt <na...@yahoo.com>.
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
>
>
Hi
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
http://cwiki.apache.org/WICKET/how-to-display-a-flash-movie-from-a-byte-array.html
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)
{
super(id);
this.width = width;
this.height = height;
this.fileName = fileName;
}
public void onResourceRequested() {
getRequestCycle().setRequestTarget(new IRequestTarget() {
public void respond(RequestCycle requestCycle) {
try {
requestCycle.getResponse().getOutputStream().write(getFlashByteArray());
} catch (IOException e) {
e.printStackTrace();
}
}
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
flash
// markup
flashBuffer.append("");
flashBuffer.append("<embed src=\"");
flashBuffer.append(urlFor(IResourceListener.INTERFACE));
flashBuffer.append("\" width=\"");
flashBuffer.append(width);
flashBuffer.append("\" height=\"");
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.
Thanks
--
View this message in context: http://www.nabble.com/flash-with-resource-tp20698407p21408684.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