• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Conditions to test null in JSF

 
Ricardo Leao
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 17646
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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".
 
Ricardo Leao
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim!!!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic