Facelets repeat tag Index
Czy ktoś zna sposób na uzyskanie indeksu elementu w znaczniku UI: repeat facelets?
<ui:repeat id="topTenGrd" var="dream" value="#{dreamModifyBean.topDreams}">
<h:outputText class="dream-title uppercase" value="#{dream.number}. #{dream.title}" />
</ui:repeat>
2 answers
Podaj wartość atrybutu "varStatus":
<ui:repeat id="..." var="..." value="..." varStatus="myVarStatus">
Możesz następnie uzyskać dostęp do indeksu pętli poprzez EL:
#{myVarStatus.index}
Dodatkowo dla varStatus dostępne są następujące właściwości:
- początek typu Integer
- koniec typu Integer
- indeks typu int
- krok typu Integer
- parzyste typu boolean
- odd typu boolean
- pierwszy z typu boolean
- Ostatni typu boolean
Po Więcej Szczegółów, Zobacz:
Https://javaserverfaces.java.net/docs/2.2/vdldocs/facelets/ui/repeat.html
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-01-27 22:13:56
Odpowiedź Briana jest dobra, ale myślę, że mogłaby być nieco bardziej opisowa dla informacji.
Tworzymy UI: Repeat
<ui:repeat id="repeatOne" var="listofValues" varStatus="myVarStatus"> </ui:repeat>
Using Ui Repeat we can access the values from the variable we associated with the list 'listofValues'.
Używając varStatus możemy utworzyć kolejną zmienną, która przechowuje informacje innego typu. Na przykład używając #{myVarStatus.index}
w naszej liście do utworzenia tabeli możemy użyć tych informacji do naszego indeksu na naszej lista.
1.
2.
3.
Oczywiście jeśli określisz swoją tablicę, aby zaczynała się od 0, to tak samo będzie z Twoją listą, chyba że dodasz 1 do każdej. {myVarStatus.indeks + 1}
Są one również bardzo przydatne w tablicach 2D, które muszą używać 2 UI:Repeat
, które są zagnieżdżone.
Nieruchomość _ _ _ _ _ _ _ _ _ _ _ _ Opis
current getCurrent() The item (from the collection) for the current round of iteration
index getIndex() The zero-based index for the current round of iteration
count getCount() The one-based count for the current round of iteration
first isFirst() Flag indicating whether the current round is the first pass through the iteration
last isLast() Flag indicating whether the current round is the last pass through the iteration
begin getBegin() The value of the begin attribute
end getEnd() The value of the end attribute
step getStep() The value of the step attribute
Dodatkowa dokumentacja z linkami:
- atrybuty interfejsu użytkownika: Repeat można znaleźć tutaj .
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-11-14 15:28:59