• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

bean:write

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a jsp that has several address lines like this:

There are 3 address lines, but sometimes address lines 2 and 3 are blank. I don't want to write out blank lines if they are blank. What is the best way to go about this formatting?
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
U can use the evaluation logic tag for that case. I think logic:notEqual will do.
<logic:notEqual value="" name="GeneralInfo" property="address2">
<bean:write ...
</logic:notEqual>
rgds
beN
 
Eric Sexton
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not at work right now, so I can't test this out. But I wanted to ask, should I leave the value parameter blank? I did try the logic tag, but could not get it to work. I did not try it exactly as you specified though. Thanks for the help.
 
Bernardus Irmanto
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use the logic:notEqual(/logic:equal) tag, you must specify the value property. Yes, you can fill the value with "".
however, this tag will not work if the value of the address2 is null(it will output the following error message "Cannot compare null variable to value", just like if you compare a variable with a string value, and the var is the left operator, and it is null), so you have to make sure that your address property is not null
<logic:notEqual value="" name="GeneralInfo" property="address2">
...
</logic:notEqual>

rgds
beN
 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alternatively you can use the <logic:notEmpty> tag, which will only evaluate the nested content of the tag if the property you use is not null and not a String with a length of 0.
Here is a link to the API reference for the tag.
<logic:notEmpty>
 
Eric Sexton
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks beN.
[ October 24, 2003: Message edited by: Eric Sexton ]
 
The harder you work, the luckier you get. This tiny ad brings luck - just not good luck or bad luck.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!