-
1. Re: UI Repeat
sjmenden Aug 23, 2008 10:43 PM (in response to bashan)Not with ui:repeat but yes with c:forEach, see https://facelets.dev.java.net/nonav/docs/dev/docbook.html#taglib-available-jstl so you can do:
<c:forEach begin="0" end="4" varStatus="idx"> #{idx} </c:forEach>
-
2. Re: UI Repeat
bashan Aug 24, 2008 1:37 AM (in response to bashan)Weird, for some reason the c:forEach doesn't work for me. I added the namespace, run a simple loop, wrote some text in the loop and all I see is a single time the text it printed. I assume that facelets simply ignore this tag...
But anyway, I am trying to use t:dataList (like ui:repeat) for now. I am generating a list on the server side. The list is being generated from a facelets component. I pass to the
component a signle parameter:<n:ratingShow rating="#{video.rating}" />
It seems like this parameter is not accessible on the server.
This is my component:<span xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:t="http://myfaces.apache.org/tomahawk" xmlns:c="http://java.sun.com/jsp/jstl/core"> <t:dataList value="#{ratingList}" var="r" rowIndexVar="rowIndex"> <h:graphicImage url="img/rating/small_#{r}.jpg" /> </t:dataList> </span>
This is the server side code:
@Name("ratingList") public class RatingAction { @Unwrap public List<String> getRatingList() { double rating = (Double)FacesUtil.getElValue("#{rating}"); List<String> list = new ArrayList<String>(); for (int i = 0; i < 5; i++) { if (rating >= i + 1) { list.add("full"); } else if (rating >= i + 0.5) { list.add("half"); } else { list.add("empty"); } } return list; } }
The
rating
is null. although when printing it from the component xml code, it returns a valid value.The code I am using to evaluate the expression:
public static Object evalEl(String expression) { String framedExpr = "#{" + expression + "}"; Object value = Expressions.instance().createValueExpression(framedExpr).getValue(); return value; }
-
3. Re: UI Repeat
bashan Aug 24, 2008 1:41 AM (in response to bashan)Sorry, I forgot to ask the final question... ;-)
Is there a reason therating
is not being evaluated in the Java code? Should there be some other code to evaluate facelets parameter (if it does it will be a bit not comfortable...).One more thing the interests me:
When calling theratingList
twice, it actually executes thegetRatingList
method twice. Is there a way to cause Seam tocache
the result for the request and execute thegetRatingList
only once (I though that this is one of the benfits of using @Unwrap)?Thanks,
Guy. -
4. Re: UI Repeat
ctomc Aug 24, 2008 11:27 AM (in response to bashan)Hello,
you can also try a4j:repeat it has index and everything you need...
the difference between c:forEach and ui:repeat is that c:forEach is content handler and ui:repeat is component..
cheers,
tomaz -
5. Re: UI Repeat
bashan Aug 25, 2008 12:12 AM (in response to bashan)Thanks,
Is there any component allowing conditional flow rather than usingrendered
property?
Does anyone know how to evaluate facelet component parameter in java code? -
6. Re: UI Repeat
tony.herstell1 Aug 25, 2008 12:43 AM (in response to bashan)<s:fragment> for conditional stuff in your xhtml pages.
-
7. Re: UI Repeat
tony.herstell1 Aug 25, 2008 12:51 AM (in response to bashan)Example
<s:fragment rendered="#{!(identity.loggedIn and s:hasRole('ADMINISTRATOR'))}"> <div class="centre text_important"> <h:outputText value="#{messages.status_arena_status}" /> <s:fragment rendered="#{!(identity.loggedIn and s:hasRole('ADMINISTRATOR'))}"> <span class="italic small_text"> (<h:graphicImage alt="#{messages.status_open}" url="#{basePath}/images/tick.gif" height="10"/><h:outputText value="#{messages.status_open}" /> <h:graphicImage alt="#{messages.status_closed}" url="#{basePath}/images/cross.gif" height="10"/><h:outputText value="#{messages.status_closed}" />) </span> </s:fragment> </div> </s:fragment>
-
8. Re: UI Repeat
bashan Aug 25, 2008 10:29 AM (in response to bashan)Nice thing, though I don't see here any special properties that I cannot do using simple h:panelGroup.
-
9. Re: UI Repeat
bashan Sep 16, 2008 11:42 PM (in response to bashan)Sorry, couldn't find any
index
property in a4j:repeat... -
10. Re: UI Repeat
brachie Sep 17, 2008 12:00 AM (in response to bashan)Hi,
what is the difference between <s:fragment> and <s:div> or <s:span> (except for the block and inline type)?
Alexander -
11. Re: UI Repeat
dro_k Sep 24, 2008 9:07 AM (in response to bashan)<s:div> conditionally renders its contents wrapped in HTML <div>
<s:span> conditionally renders its contents wrapped in HTML <span>
<s:fragment> conditionally renders its contents without wrapping them in any HTML element
cheers,
Drew