File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes bean:write Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "bean:write" Watch "bean:write" New topic
Author

bean:write

Eric Sexton
Ranch Hand

Joined: Sep 12, 2003
Posts: 133
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?
Bernardus Irmanto
Greenhorn

Joined: Oct 03, 2003
Posts: 23
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

Joined: Sep 12, 2003
Posts: 133
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

Joined: Oct 03, 2003
Posts: 23
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
Eric Fletcher
Ranch Hand

Joined: Oct 26, 2000
Posts: 188
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>


My theory of evolution is that Darwin was adopted. - Steven Wright
Eric Sexton
Ranch Hand

Joined: Sep 12, 2003
Posts: 133
Thanks beN.
[ October 24, 2003: Message edited by: Eric Sexton ]
 
Consider Paul's rocket mass heater.
 
subject: bean:write