My JSF Books/Videos My JSF Tutorials OmniFaces/JSF PPTs
JSF 2.3 Tutorial
JSF Caching Tutorial
JSF Navigation Tutorial
JSF Scopes Tutorial
JSF Page Author Beginner's Guide
OmniFaces 2.3 Tutorial Examples
OmniFaces 2.2 Tutorial Examples
JSF Events Tutorial
OmniFaces Callbacks Usages
JSF State Tutorial
JSF and Design Patterns
JSF 2.3 New Features (2.3-m04)
Introduction to OmniFaces
25+ Reasons to use OmniFaces in JSF
OmniFaces Validators
OmniFaces Converters
JSF Design Patterns
Mastering OmniFaces
Reusable and less-verbose JSF code

My JSF Resources ...

Java EE Guardian
Member of JCG Program
Member MVB DZone
Blog curated on ZEEF
OmniFaces is an utility library for JSF, including PrimeFaces, RichFaces, ICEfaces ...

.

.

.

.

.

.

.

.


[OmniFaces Utilities] - Find the right JSF OmniFaces 2 utilities methods/functions

Search on blog

Petition by Java EE Guardians

Twitter

sâmbătă, 28 noiembrie 2015

[OmniFaces utilities 2.0] A mapping of days names (full/short names) by day numbers for the current locale


[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):

Functions (get day name (full/short name) by day number)

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

JSF BOOKS COLLECTION

Postări populare

OmniFaces/JSF Fans

Visitors Starting 4 September 2015

Locations of Site Visitors