wood burning stoves*
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 Murach's Java Servlets and JSP this week in the Servlets 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: 15952
    
  19

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
 
Similar Threads
Struts display:column when/otherwise
Check NULL in JSTL
JSTL how to use ELSE in JSP
how to avoid show buttons
Mixing JSP and Scriptlets throws compilation errors