• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Conditions to test null in JSF

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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}">
<h:outputText style="text-align:center;" value="yes" />
</c:when>
<c:otherwise>
<h:outputText style="text-align:center;" value="no" />
</c:otherwise>
</c:choose>

Thanks.
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Tim!!!
 
roses are red, violets are blue. Some poems rhyme and some are a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic