This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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: 16019
    
  20

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!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Conditions to test null in JSF