Reputation: 1434
I've been facing an issue with Omnifaces 2.1
.
I have an images type byte[]
stored in my database with a declaration java class like this:
@Lob
private byte[] image;
In my xhtml file I have a loop on a class that has an image in it:
<ui:repeat var="listT" value="#{eventBean.listEvents}">
<o:graphicImage value="#{eventBean.getImage(listT.idEvent)}" dataURI="true" />
</ui:repeat>
Now in my bean
I tried implementing the getImage()
function mentioned in the documentation of omnifaces:
@ManagedBean
@ViewScoped
public class EventBean implements Serializable {
private static final long serialVersionUID = 1L;
@EJB
private EventServiceLocal eventServiceLocal;
private Event event = new Event();
private List<Event> listEvents;
private List<Event> listEventsval;
private static Event eventSt;
private UploadedFile file;
public byte[] getImage(int eventID) {
return eventServiceLocal.listEventspicture(eventID);
}
When I execute this I gt no image and when I inspect the element, I get this as a result:
<o:graphicimage value="[B@1aeef88" datauri="true"></o:graphicimage>
Upvotes: 2
Views: 299
Reputation: 1108632
when i execute this i got no image and when inspect the element i get this as result :
<o:graphicimage value="[B@1aeef88" datauri="true"></o:graphicimage>
In other words, <o:xxx>
tags don't work at all. This is not restricted to <o:graphicImage>
alone. All other <o:xxx>
tags in the same page would also not work.
That can have 2 causes:
o
XML namespace is not declared in the XHTML page.The normal procedure to solve this is:
/WEB-INF/lib
(or let your dependency manager do it).xmlns:o="http://omnifaces.org/ui
to some parent element.To verify the working:
When exporting a WAR file from your project and inspecting it using a ZIP tool, the physical OmniFaces JAR file should be present in /WEB-INF/lib
folder and there should be a line like below in server log during deployment:
INFO [org.omnifaces.ApplicationInitializer] Using OmniFaces version 2.6.8
There should be no <o:xxx>
tags anywhere in the generated HTML output.
Upvotes: 5