aspose file tools*
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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Conditions to test null in JSF" Watch "Conditions to test null in JSF" New topic
Author

Conditions to test null in JSF

Ricardo Leao
Greenhorn

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:choose>
<c:when test="${document.qtde == null}">
<hutputText style="text-align:center;" value="yes" />
</c:when>
<ctherwise>
<hutputText style="text-align:center;" value="no" />
</ctherwise>
</c:choose>

Thanks.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

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
Greenhorn

Joined: May 17, 2012
Posts: 2
Thanks Tim!!!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Conditions to test null in JSF