Discussion:
Display images from database
hinkel
2008-08-22 17:52:44 UTC
Permalink
Hi folks,

I am new to Wicket and have a simple questions to the experts:

I have images stored in a databse and want to display them on a webpage.
I've searched each and everything on the web but did not find a working
solution. It seems that the source of the much recommend cdapp-application
is not available anymore. I am using Wicket 1.3.4 and would appriciate a
link to some working example or any other hint how it is done.

Thank you for your help.

Greetings.
--
View this message in context: http://www.nabble.com/Display-images-from-database-tp19112473p19112473.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-***@wicket.apache.org
For additional commands, e-mail: users-***@wicket.apache.org
Nino Saturnino Martinez Vazquez Wael
2008-08-22 18:55:23 UTC
Permalink
hmm, use an image resource. Below code could probably get beautified a
bit.. And you might want to use shared resources if its something common..

form.add(new NonCachingImage("currentPicture",
new AbstractReadOnlyModel() {
@Override
public Object getObject() {
// TODO Auto-generated method stub
return new
ImageResource(getPerson().getPicture(),"png");
}
}));



package zeuzgroup.application.utils;

import java.awt.image.BufferedImage;

import org.apache.wicket.markup.html.image.resource.DynamicImageResource;

public class ImageResource extends DynamicImageResource {

// has to save this. or get the image another way!
private byte[] image;

public ImageResource(byte[] image, String format) {
this.image = image;
setFormat(format);
}

public ImageResource(BufferedImage image) {
this.image = toImageData(image);
}

@Override
protected byte[] getImageData() {
if (image != null) {
return image;
} else {
return new byte[0];
}

}

/**
* 1 day!
*/
@Override
protected int getCacheDuration() {

return 3600*24;
}

}
Post by hinkel
Hi folks,
I have images stored in a databse and want to display them on a webpage.
I've searched each and everything on the web but did not find a working
solution. It seems that the source of the much recommend cdapp-application
is not available anymore. I am using Wicket 1.3.4 and would appriciate a
link to some working example or any other hint how it is done.
Thank you for your help.
Greetings.
--
-Wicket for love

Nino Martinez Wael
Java Specialist @ Jayway DK
http://www.jayway.dk
+45 2936 7684


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