[OmniFaces utilities] The
getDaysOfWeek()
function returns a mapping of day of week names in ISO 8601 order (Monday first) for the current locale. For example: "Monday=1", "Tuesday=2", etc. This is useful if you want to for example populate a <f:selectItems>
which shows all days of week. The locale is obtained by Faces#getLocale()
. The mapping is per locale stored in a local cache to improve retrieving performance.[OmniFaces utilities] The
getShortDaysOfWeek()
function returns a mapping of short day of week names in ISO 8601 order (Monday first) for the current locale. For example: "Mon=1", "Tue=2", etc. This is useful if you want to for example populate a <f:selectItems>
which shows all short days of week. The locale is obtained by Faces#getLocale()
. The mapping is per locale stored in a local cache to improve retrieving performance.[OmniFaces utilities] The
getDayOfWeek()
function returns the day of week name from the mapping associated with the given day of week number in ISO 8601 order (Monday first) for the current locale. For example: "1=Monday", "2=Tuesday", etc. The locale is obtained by Faces#getLocale()
.[OmniFaces utilities] The
getShortDayOfWeek()
function returns the short day of week name from the mapping associated with the given day of week number in ISO 8601 order (Monday first) for the current locale. For example: "1=Mon", "2=Tue", etc. The locale is obtained by Faces#getLocale()
.Function(full names):
Function(short names):
In OmniFaces
Showcase you can
see how an example of how to populate a <f:selectItems/> which
shows all days of week. Below, you can see an example of displaying the days of
week numbers and names in a data table.
Full names via of:getDaysOfWeek():
<h:dataTable
value="#{of:getDaysOfWeek().entrySet()}"
var="t">
<h:column>
<f:facet
name="header">No.</f:facet>
#{t.value}
</h:column>
<h:column>
<f:facet
name="header">Name</f:facet>
#{t.key}
</h:column>
</h:dataTable>
Short names via of:getShortDaysOfWeek():
<h:dataTable
value="#{of:getShortDaysOfWeek().entrySet()}"
var="t">
<h:column>
<f:facet
name="header">No.</f:facet>
#{t.value}
</h:column>
<h:column>
<f:facet
name="header">Name</f:facet>
#{t.key}
</h:column>
</h:dataTable>
Moreover, we
can obtain a day name (short name) by its number via of:getDayOfWeek() and of:getShortDayOfWeek():
The day 4 of
the week is: #{of:getDayOfWeek(4)}
Output: Thursday
The day 4 of
the week is: #{of:getShortDayOfWeek(4)}
Output: Thu
The day
number can be provided from a managed bean also:
#{of:getDayOfWeek(fooBean.daynumer)}
#{of:getShortDayOfWeek(fooBean.daynumer)}
Niciun comentariu :
Trimiteți un comentariu