[JSTL] empty strings inside table cells *with borders*

K

Karsten Wutzke

Hi all!

I am generating HTML with a lot of table content, that is in the <td>
tags. With my table cells, I always get empty cells with *no borders*
when <c:eek:ut> ing the empty string (in Java: String str = "";)

Is there any way get <td> cells *with borders* when <c:eek:ut> ing the
empty string?

Karsten
 
V

VisionSet

Karsten Wutzke said:
Hi all!

I am generating HTML with a lot of table content, that is in the <td>
tags. With my table cells, I always get empty cells with *no borders*
when <c:eek:ut> ing the empty string (in Java: String str = "";)

Is there any way get <td> cells *with borders* when <c:eek:ut> ing the
empty string?

I think this is a browser issue, IE right?
<td></td> produces borderless cells in IE
fix is
<td>&nbsp;</td>
not sure when or if this has been fixed.

Try netscape to confirm.
 
K

Karsten Wutzke

VisionSet said:
I think this is a browser issue,

Could be. I have almost no HTML/browser experience.
IE right?

Nope. Netscape 7.1.
<td></td> produces borderless cells in IE
fix is
<td>&nbsp;</td>
not sure when or if this has been fixed.

Try netscape to confirm.

Hmmm. This insert a socalled non-breaking space to every cell...

I mostly pass String objects to JSTL. How can I query on a String object
from JSTL, whether it's the empty "" string? Like this, only &nsbp; will
be output if the string is empty ("").

The bad thing is, to use it for every cell, the text will shift to the
right one space, which looks uglier than before.

Any recommendations here?

Karsten
 
C

Christophe Vanfleteren

Karsten said:
I mostly pass String objects to JSTL. How can I query on a String object
from JSTL, whether it's the empty "" string? Like this, only &nsbp; will
be output if the string is empty ("").

The bad thing is, to use it for every cell, the text will shift to the
right one space, which looks uglier than before.

Any recommendations here?

Karsten

Just write a <c:if> tag that checks wether the String was emtpy/null and
writes a &nbsp; if that was the case.

I t might also be possible to force borders on your tablecells using css, so
you might want to check that in some html/css newsgroup.
 
K

Karsten Wutzke

Christophe said:
Just write a <c:if> tag that checks wether the String was emtpy/null and
writes a &nbsp; if that was the case.

I t might also be possible to force borders on your tablecells using css, so
you might want to check that in some html/css newsgroup.

How exactly does a JSTL if look like, that can check for the empty string???

Thanks,
Karsten
 
K

Karsten Wutzke

VisionSet said:
string???


<c:if test="${myString == empty}" >
<c:eek:ut ....... />
</c:if>

Not quite... you probably meant something like:

<c:choose>
<c:when test="${empty cell.contents}">
&nbsp;
</c:when>
<c:eek:therwise>
<c:eek:ut value="${cell.contents}"/>
</c:eek:therwise>
</c:choose>

Karsten
 
B

Bruce Lewis

Karsten Wutzke said:
Not quite... you probably meant something like:

<c:choose>
<c:when test="${empty cell.contents}">
&nbsp;
</c:when>
<c:eek:therwise>
<c:eek:ut value="${cell.contents}"/>
</c:eek:therwise>
</c:choose>

Is this seriously what you do in JSTL? In BRL I do

[(or (brl-nonblank? my-string) "&nbsp;")]
 
C

Christophe Vanfleteren

Bruce said:
Karsten Wutzke said:
Not quite... you probably meant something like:

<c:choose>
<c:when test="${empty cell.contents}">
&nbsp;
</c:when>
<c:eek:therwise>
<c:eek:ut value="${cell.contents}"/>
</c:eek:therwise>
</c:choose>

Is this seriously what you do in JSTL? In BRL I do

[(or (brl-nonblank? my-string) "&nbsp;")]

It could be written a tad shorter.

<c:eek:ut value="${cell.contents}"/>
<c:if test="${empty cell.contents}">
&nbsp;
</c:if>

In JSP 2 you can just write:

${cell.contents}
<c:if test="${empty cell.contents}">
&nbsp;
</c:if>

You could also make a custom tag like this:

<t:addSpaceIfEmpty value="${cell.contents}"/>
 
S

Scott Yanoff

Karsten said:
Is there any way get <td> cells *with borders* when <c:eek:ut> ing the
empty string?

If the non-breaking space in those table cells makes your tables look
ugly, what about:

<c:eek:ut value="${data}" default="&nbsp;" />

Doesn't the default signify what to put in case there is no value?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top