Dynamic p:graphicImage in carousel

UI Components for JSF
Post Reply
cartesius28
Posts: 10
Joined: 27 Nov 2009, 00:41

04 Dec 2009, 05:03

Dear Sirs,

I am so sorry to bother you again but I need to have a dynamic image list in the carousel.

JSF
<rich:dataGrid value="#{result.list}" var="r" >
...
<p:carousel value="#{r.images}" var="i" rows="1"
rendered="#{r.images.size > 0}">
<p:graphicImage value="#{i}" />
<h:outputText value="#{i.contentType}" />
</p:carousel>
</rich:dataGrid>

where result.list is

@DataModel
private List<W> list = new ArrayList<W>();
--------------------------
and W is:

@Name("w")
@AutoCreate
public class W implements Serializable {

@DataModel
private List<StreamedContent> images = new ArrayList<StreamedContent>();

public List<StreamedContent> getImages() {
return images;
}

public W() {

}

// DataEntity is a entity bean
public void setEntity(DataEntity e) {
if (e.getSons() == null)
return;
for (DataEntity x : e.getSons()) {
images.add(new DefaultStreamedContent(new ByteArrayInputStream(x.getData()), x
.getMime()));
}
}

/**
*
*/
private static final long serialVersionUID = -8106287009474660390L;

}
------------------------------------------------------------

I do not see any images despite the images list is correctly filled-up.

Please, what's wrong???

Kind regards,
Jakub

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

06 Dec 2009, 19:53

Hi,

Does <h:outputText value="#{i.contentType}" /> work? Only images fail? What does #{i} print?

asbrana
Posts: 9
Joined: 16 Dec 2009, 14:51

16 Dec 2009, 16:17

I did the same test here and the image is not being showed.

The <h:outputText value="#{i.contentType}" /> prints "image/jpeg".

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

16 Dec 2009, 17:51

Can you post what p:graphicImage components render? Dynamic images are generated later after the page is rendered, they make a new request so in this new request if the value is not there anymore, this might occur. So just post what dynamic images render and we can continue discussing. :)

asbrana
Posts: 9
Joined: 16 Dec 2009, 14:51

16 Dec 2009, 21:46

Here is what p:carousel rendered.

Code: Select all

<script type="text/javascript">YAHOO.util.Event.addListener(window, "load", function() {
	j_id14167376_36330bf7_widget = new PrimeFaces.widget.Carousel("j_id14167376_36330bf7:container", {pagerStateHolder:"j_id14167376_36330bf7:pagerstate", selectedItemStateHolder:"j_id14167376_36330bf7:selecteditem"});
	j_id14167376_36330bf7_widget.set("numVisible",1);
	j_id14167376_36330bf7_widget.set("animation", {speed:0.5});
	j_id14167376_36330bf7_widget.render();
	j_id14167376_36330bf7_widget.show();
	});
</script>
	<div id="j_id14167376_36330bf7">
		<div id="j_id14167376_36330bf7:container">
			<ol>
				<li id="j_id14167376_36330bf7:0"><img id="j_id14167376_36330bf7:0:j_id14167376_36330bdd" src="/test-app/views/test_carousel.jsf?primefacesDynamicImage=i" />image/jpeg</li>
				<li id="j_id14167376_36330bf7:1"><img id="j_id14167376_36330bf7:0:j_id14167376_36330bdd" src="/test-app/views/test_carousel.jsf?primefacesDynamicImage=i" />image/jpeg</li>
			</ol>
		</div>
		<input id="j_id14167376_36330bf7:pagerstate" name="j_id14167376_36330bf7:pagerstate" type="hidden" />
		<input id="j_id14167376_36330bf7:selecteditem" name="j_id14167376_36330bf7:selecteditem" type="hidden" />
	</div>
Hope it helps.
Thanks

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

18 Dec 2009, 12:09

Now I see, unfortunately it seems p:graphicImage does not support data iteration. So will not work in a carousel or a rich:dataGrid, we're aiming to add this support soon.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 60 guests