graphicImage Tag does not work with jsf dataTable

UI Components for JSF
Post Reply
badping
Posts: 1
Joined: 07 Apr 2010, 16:06

07 Apr 2010, 16:20

I am using Jsf2 with PrimeFaces.

I got a h:dataTable and i want to create a dynamic image for each column. It seems p:graphicImage does not work with it, can anyone confirm.
Maybe anyone has an idea for a workaround, if this is not possible
Code looks:

Code: Select all

	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.prime.com.tr/ui"
...
		<h:dataTable value="#{bookListBean.books}" var="books">
			<h:column>
				<h:commandLink action="#{detailBean.forward}">
					<p:graphicImage value="#{books.book.dbImage}" />
				</h:commandLink>
			</h:column>
...
Info: dbImage is of type StreamedContent

Thank you.

Ps. Without h:dataTable it works fine.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

08 Apr 2010, 10:30

It will work with some effort because due to the nature of how it works once the page is rendered browser will make a new request to retrieve the image to display it. In this case books.book.dbImage will not yield to a result as books is only available when datatable is being rendered.

We have added f:param support to graphic image to make it work within repeating components like datatable. In this case try sth like;

Code: Select all

<h:column>
  <h:commandLink action="#{detailBean.forward}">
    <p:graphicImage value="#{bookListBean.dynamicBookImage}">
      <f:param name="bookId" name="#{books.book.id}" />
    </p:graphicImage>
  </h:commandLink>
</h:column>
Your getDynamicBookImage method should be like;

Code: Select all

public StreamedContent getDynamicBookImage() {
   String bookId = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get('bookId');
      //Here you have db id of book so just create a StreamedContent and return it.
}
This method will be called for each of the books in list.

Hope it helps.

victor
Posts: 5
Joined: 14 Jun 2010, 13:16

30 Jun 2010, 11:46

I've been trying to get this working and did not succeed. I think the f:param solution does not work:

The browser uses a HTTP GET for obtaining the image. The f:param is not posted to the server, and also the URL of the image does not contain the f:param value.

So the getDynamicBookImage() works when the HTML page is rendered, but does not work on the 'get image request' lateron.
I am reverting to a Servlet solution.

If it is possible to use StreamedContent inside a primefaces datatable, a working example would be nice!

User avatar
boscooo
Posts: 55
Joined: 07 Apr 2010, 15:48
Location: Brazil

01 Jul 2010, 00:27

Have u tried to use p:commandLink?

Code: Select all

  
            <p:commandLink action="#{detailBean.forward}">
                <p:graphicImage value="#{books.book.dbImage}" />
            </p:commandLink>
JBoss Seam 2.2.0 GA Web Framework
Mojarra 1.2_15-SNAPSHOT JSF Implementation
PrimeFaces 1.0.2 Final
RichFaces 3.3.3 Final
JBoss AS 4.2.2 GA

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 50 guests