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

Discussion in 'Java' started by Karsten Wutzke, Oct 28, 2003.

  1. 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
     
    Karsten Wutzke, Oct 28, 2003
    #1
    1. Advertising

  2. Karsten Wutzke

    VisionSet Guest

    "Karsten Wutzke" <> wrote in message
    news:bnmc4e$32o$01$-online.com...
    > 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.

    --
    Mike W
     
    VisionSet, Oct 28, 2003
    #2
    1. Advertising

  3. VisionSet wrote:

    > "Karsten Wutzke" <> wrote in message
    > news:bnmc4e$32o$01$-online.com...
    >
    >>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,


    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
     
    Karsten Wutzke, Oct 28, 2003
    #3
  4. Karsten Wutzke wrote:
    >
    > 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.

    --
    Regards,
    Christophe Vanfleteren
     
    Christophe Vanfleteren, Oct 28, 2003
    #4
  5. Christophe Vanfleteren wrote:

    > Karsten Wutzke wrote:
    >
    >>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.
    >


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

    Thanks,
    Karsten
     
    Karsten Wutzke, Oct 28, 2003
    #5
  6. Karsten Wutzke

    VisionSet Guest

    "Karsten Wutzke" <> wrote in message
    news:bnmnin$3op$06$-online.com...

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

    string???
    >


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

    --
    Mike W
     
    VisionSet, Oct 28, 2003
    #6
  7. VisionSet wrote:

    > "Karsten Wutzke" <> wrote in message
    > news:bnmnin$3op$06$-online.com...
    >
    >
    >>How exactly does a JSTL if look like, that can check for the empty

    >
    > 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
     
    Karsten Wutzke, Oct 28, 2003
    #7
  8. Karsten Wutzke

    Bruce Lewis Guest

    Karsten Wutzke <> writes:

    > VisionSet wrote:
    >
    > > "Karsten Wutzke" <> wrote in message
    > > news:bnmnin$3op$06$-online.com...
    > >
    > >>How exactly does a JSTL if look like, that can check for the empty

    > > 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>


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

    [(or (brl-nonblank? my-string) "&nbsp;")]
     
    Bruce Lewis, Oct 29, 2003
    #8
  9. Bruce Lewis wrote:

    > Karsten Wutzke <> writes:
    >
    >> VisionSet wrote:
    >>
    >> > "Karsten Wutzke" <> wrote in message
    >> > news:bnmnin$3op$06$-online.com...
    >> >
    >> >>How exactly does a JSTL if look like, that can check for the empty
    >> > 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>

    >
    > 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}"/>

    --
    Regards,
    Christophe Vanfleteren
     
    Christophe Vanfleteren, Oct 29, 2003
    #9
  10. Karsten Wutzke

    Scott Yanoff Guest

    Karsten Wutzke wrote:
    > 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?


    --
    -Scott
    | http://www.yanoff.org | AOL IM: SAY KJY
     
    Scott Yanoff, Oct 31, 2003
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave Ortman

    JSP : No Borders for empty data cells

    Dave Ortman, Aug 9, 2003, in forum: Java
    Replies:
    2
    Views:
    1,391
    Scott Yanoff
    Aug 11, 2003
  2. bbxrider
    Replies:
    0
    Views:
    619
    bbxrider
    Jul 14, 2003
  3. George
    Replies:
    9
    Views:
    5,049
    George
    Oct 25, 2004
  4. Replies:
    1
    Views:
    429
    Jonathan N. Little
    Jan 12, 2007
  5. Savvoulidis Iordanis

    Empty gridview cells and checking for empty string

    Savvoulidis Iordanis, Sep 5, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    558
    Savvoulidis Iordanis
    Sep 5, 2008
Loading...

Share This Page