Latest Entries »

Monday, January 5, 2009

How to display dynamic image from blob data in icefaces ?

To display ice graphic image from the blob content, add icefaces-comps.jar and icefaces.jar.
These jar files contains improved ice graphic image component.
Click here to download the jar files.
This component supports byte[] and url to file.

Sample code of hibernate pojo and icefaces jsp file.
Hibernate POJO Code:
private byte[] content;
@Column(name = "Content")
public byte[] getContent() {
return this.content;
}
public void setContent(byte[] content) {
this.content = content;
}
JSP Page Code:
< ice:graphicImage height="50" width="50" value="#{image.content}"><\ice:graphicImage>

1 comments:

Sravan Modugula said...

Few readers asked me about the Hibernate POJO code:

If you are auto generating the Hibernate POJO code through reverse engineering your database, for a blob field in database Hibernate assigns String for it.

Example Code:

private String content;


@Column(name = "Content")
public String getContent() {
return this.content;
}

public void setContent(String content) {
this.content = content;
}

The above is the Hibernate auto generated code through reverse engineering the database field blob.

You need to change String to byte[]

Example code:

private byte[] content;

@Column(name = "Content")
public byte[] getContent() {
return this.content;
}

public void setContent(byte[] content) {
this.content = content;
}

To display the blob content using iceface graphicimage component it should be a byte[] field.

Hope this information will help you in configuring/ maintaining your Hibernate POJO code.