File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
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: 15641
    
  15

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