This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 160347 - JSTL tags are formatted incorrectly
Summary: JSTL tags are formatted incorrectly
Status: VERIFIED DUPLICATE of bug 162772
Alias: None
Product: javaee
Classification: Unclassified
Component: JSP (show other bugs)
Version: 6.x
Hardware: Sun All
: P3 blocker (vote)
Assignee: David Konecny
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-16 14:09 UTC by Jindrich Sedek
Modified: 2009-05-25 21:07 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jindrich Sedek 2009-03-16 14:09:38 UTC
use this code in JSP file:
------------------------------
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
    <head><title></title></head>
    <body>
        <p>
            <c:if test="true">
            <table cellpadding="5" border="1">
                <tr>
                    <td>undefinedKey</td>
                    <td>undefinedKey</td>
                </tr>
            </table>
        </c:if>
</p>
</body>
</html>
----------------------------------
invoke reformat -> no change
the content of <c:if> tag should be indented
Comment 1 David Konecny 2009-03-16 20:42:35 UTC
The cause for this issue is that table is not allowed within paragraph tag and consequently paragraph tag is closed by
table tag. If you replace table with for example <a> or anything which can be inside <p> then everything works fine.
Also try to keep table in <p> but remove JSTL and you will get 

        <p>
        <table cellpadding="5" border="1">
            <tr>
                <td>undefinedKey</td>
                <td>undefinedKey</td>
            </tr>
        </table>
</p>

where table is formatted properly but closing </p> does not have corresponding opening <p> and is therefore wrongly
indented. I wonder what would be the best solution. Perhaps, in last example </p> should be underlined with
warning/error stating it does not have matching tag. What's your opinion Jindra?
Comment 2 Jindrich Sedek 2009-03-17 09:49:16 UTC
I see. In my opinion this formatting is good, but it can be bit confusing for users. I'm not sure if the warning about
unfinished and "p" tag is enough for users to understand the reason of such formatting, but it could help at least a
bit. I've no idea how to give better information to users. Adding marek to cc, so he would have some more ideas.

another case in previous sample is the JSTL tags integration into HTML code. I talk about this sample code:
---------------
        <p>
            <c:if test="true">
            <p cellpadding="5" border="1">
            </p>
        </c:if>
        <p>
        ....
--------------
could be formatted better this way if possible:
----------------
        <p>
            <c:if test="true">
               <p cellpadding="5" border="1">
               </p>
            </c:if>
        <p>
        ....
----------------
Comment 3 David Konecny 2009-03-17 10:11:46 UTC
Re. your last example - that's the formatting which I would want to achieve. I will have a look at it tomorrow.
Comment 4 Marek Fukala 2009-03-17 12:26:38 UTC
I have filed the missing html editor warnings as issue 160454. I belive marking the closing tag as unmatched is
sufficient for the user to understand why the formatting is wrong.
Comment 5 David Konecny 2009-04-06 21:29:20 UTC
Re. "fix-in-fcs" - I do not find this issue important and in addition I do not think it has simple fix. This is so far
first formatting issue which I have no quick solution for. Combination of HTML tag with optional end and templating
language tag in which previous HTML may or may not have been closed is tricky to resolve on per-language basis. I can
imagine a solution but it would require serious amount of changes and right not it would not be worth it. This is more
or less FYI so please comment if you disagree.
Comment 6 Jindrich Sedek 2009-04-07 10:26:02 UTC
I'm trying to evaluate the problem deeper since I've faced more problems than just "crossing" of open HTML tag with
optional endtag and I thought this issue covers all of them.

I'll give one example - this is reformatted code - all HTML blocks are "complete" and there are no unclosed tag with
optional end tag, but the </c:if> end tag is not formatted correctly
---------------------
<table>
    <tr><th>HEADER</th></tr>
        <c:if test="false">
        <tr>
            <td>CODE</td>
        </tr>
    </c:if>
</table>
---------------------

From your comment of Mar 17 and no more reactions than, I expected you've just omitted this bug and I didn't expect so
serious problems while fixing it.

My expectations about JSP tags formatting is that start and end tags should be always at the same level independently of
HTML code inside since JSP tags are more important for the structure of code.

In general I'm quite satisfied with new reformatting and I prefer not to make huge changes with big danger of
regressions because of P3 as this one is. Evaluate the problem that I've mentioned above, please, and decide what we can
do for better JSP tags formatting now. Let's let the rest as P3 for next release - it would be probably good to fill
another issue for that purpose since this one is already mixed of many different things.
Comment 7 David Konecny 2009-04-07 10:42:59 UTC
Re. " I expected you've just omitted this bug and I didn't expect so serious problems while fixing it" - :-)

Reformatting example you gave the result is:

<table>
    <tr><th>HEADER</th></tr>
    <c:if test="false">
        <tr>
            <td>CODE</td>
        </tr>
    </c:if>
</table>

which is OK, no? Or how can I get it into broken state your reported.

Re. "JSP tags formatting that start and end tags should be always at the same level" - this should be doable and is on
my todo list to check how easy/difficult it would be.
Comment 8 Jindrich Sedek 2009-04-07 11:25:29 UTC
the latest sample is missing taglib declaration :-(
this one is correct:
-----------
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<table>
    <tr><th>HEADER</th></tr>
        <c:if test="false">
        <tr>
            <td>CODE</td>
        </tr>
    </c:if>
</table>
------------
Comment 9 David Konecny 2009-04-08 05:09:52 UTC
Thanks, I can reproduce it now. That's one of these trivial issues which I can easily fix and which is different from
the 'problematic' one described earlier here.
Comment 10 Quality Engineering 2009-04-14 19:14:25 UTC
Integrated into 'main-golden', will be available in build *200904141401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/f34969b401fb
User: David Konecny <dkonecny@netbeans.org>
Log: #160347 - fixing separate problem mentioned in this issue; this does not fix the issue though
Comment 11 David Konecny 2009-04-16 00:11:17 UTC
I filed original problem as new issue 162772. All other issues mentioned here were resolved.

*** This issue has been marked as a duplicate of 162772 ***
Comment 12 Jindrich Sedek 2009-04-24 16:22:22 UTC
verified.
NetBeans IDE Dev (Build web-main-469-on-090424)