This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JSF and the fly likes JSF EL Date Functions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » JSF
Bookmark "JSF EL Date Functions" Watch "JSF EL Date Functions" New topic

JSF EL Date Functions

Cory Cowgill

Joined: Mar 15, 2011
Posts: 4
Is there a way to compare two dates in JSF & EL?

For example, I have two Calendar objects and in the view layer I need to display one date or the other based on which one comes first.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17026

That's a logic function and logic should not be performed in the View. It's better to do the logic in the backing bean.

In a backing bean, it's pretty easy. Just expose a property to display the date and make its "get" method return the earlier of 2 Date objects:

Customer surveys are for companies who didn't pay proper attention to begin with.
Cory Cowgill

Joined: Mar 15, 2011
Posts: 4
Thanks for the reply Tim.

However, I would argue that this functionality should be available in View layer.

This is not complex business logic, this is logic specific to the View layer and only affects the View. It's specific to rendering elements on the page.

EL provides logic functions specifically so you can do things like this in the View layer to hide/show/perform simple logic to render/not render elements or change css style classes.

Otherwise, the inverse it true. Now I am putting View layer logic inside the Controller to control the rendering of elements.

It may be a mute point anyway since I got it to work.

Thanks for your input though.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: JSF EL Date Functions
jQuery in Action, 3rd edition