aspose file tools*
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
Author

JSF EL Date Functions

Cory Cowgill
Greenhorn

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: 16246
    
  21

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
Greenhorn

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 agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF EL Date Functions