File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes Conditions to test null in JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Conditions to test null in JSF" Watch "Conditions to test null in JSF" New topic

Conditions to test null in JSF

Ricardo Leao

Joined: May 17, 2012
Posts: 2
I´d like to test a condition, but the "if" doesn't work. Doesn't matter the value of qtde, always perform the "yes", even using "empty".
The value of qtde can be "null" or number (integer).

<c:when test="${document.qtde == null}">
<hutputText style="text-align:center;" value="yes" />
<hutputText style="text-align:center;" value="no" />

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16908

Welcome to the JavaRanch, Ricardo!

You can make your code samples easier to read by using the "Code" button on the message editor.

JSTL does not play well with JSF. In almost all cases, JSF has its own solution and JSTL isn't the best solution in any case, but because JSTL is designed to work with JSPs and not JSF View Templates, it can be very frustrating, regardless.

It's also very bad practice to put logic in the View Definition.

Here's a cleaner solution:

This requires adding a public "getQtdeValid()" method to the document backing bean (Model) that returns "yes" or "no".

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

Joined: May 17, 2012
Posts: 2
Thanks Tim!!!
I agree. Here's the link:
subject: Conditions to test null in JSF
It's not a secret anymore!