facebook

Struts tiles support

  1. MyEclipse IDE
  2.  > 
  3. Feature Requests
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #220298 Reply

    carniz
    Member

    I’d like to see support for (Struts-) tiles. Right now (with 3.8.2), the JSP editor reports validation errors when editing a jsp file that is a tile if you eg use a tag from a taglib that is declared in the parent tile or eg if the tile file starts with a regular HTML table tag that is not emboddied within a html/body tag (hope this makes sense..).

    My request is that ME keeps track of the tile structure (maybe by parsing the JSP files for tiles tags and/or the tiles definition file) so that when editing a file that is included in a parent file, it “knows” what taglibs that are available from the parent tile, and evaluates the HTML structure of the child tile in the context of the parent tile.

    Even better: the content of the included tile could be displayed (and collapsed at will!) in the parent tile!

    For example, look at this a.jsp (from http://www.javaworld.com/javaworld/jw-01-2002/jw-0104-tilestrut.html):

    
    <%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %>
    
    <html>
    <body>
    
    <%-- include header --%>
    <tiles:insert page="/header.jsp" flush="true"/>
    
    <%-- include body --%>
    <tiles:insert page="aBody.jsp" flush="true"/>
    
    <%-- include footer --%>
    <tiles:insert page="/footer.jsp" flush="true"/>
    
    </body>
    </html>

    – here, beneath each “tiles:insert” tag, there could be a collapsable
    section containing the included code.
    – the included blocks could have a different background color to indicate that they are included, and at the top of each included block there could be a clickable arrow on the left side that is used to collapse the block.

    What’s more: you could add a “Tiles explorer” view in ME that displays a tree with templates and definitions, where double-clicking on eg the “cDef” definition (or right-clicking on it and choosing “Open”) would open /layout.jsp with the content of /header.jsp, /footer.jsp and /cBody.jsp included in /layout.jsp! (check the tileDefinitions.xml below).

    Here’s a sample tileDefinitions.xml (also from http://www.javaworld.com/javaworld/jw-01-2002/jw-0104-tilestrut.html):

    
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <component-definitions>
        <definition name="aDef" path="/layout.jsp">
            <put name="header" value="/header.jsp"/>
            <put name="footer" value="/footer.jsp"/>
            <put name="body" value="/aBody.jsp"/>
        </definition>
        <definition name="bDef" path="/layout.jsp">
            <put name="header" value="/header.jsp"/>
            <put name="footer" value="/footer.jsp"/>
            <put name="body" value="/bBody.jsp"/>
        </definition>
        <definition name="cDef" path="/layout.jsp">
            <put name="header" value="/header.jsp"/>
            <put name="footer" value="/footer.jsp"/>
            <put name="body" value="/cBody.jsp"/>
        </definition>
    </component-definitions>
    

    For managing templates, there could be a “Templates” node in the Tiles explorer where you could add/edit/remove templates by right-clicking on Templates and choosing “Add template..”, and these templates could be choosable when creating new definitions. Templates could also be added to the Tiles explorer by right-clicking anywhere in an open JSP editor and choosing “Use as template”.

    ASCII version of the Tiles explorer:

    Templates <– right-click here to add a new template
    +–layout.jsp
    Managed definitions <– right-click here to add a definition
    +–aDef [layout.jsp]
    +–bDef [layout.jsp]
    +–cDef [layout.jsp]
    Unmanaged definitions
    +–a.jsp [layout.jsp]
    +–b.jsp [layout.jsp]

    – [layout.jsp] after each definition indicates the template used
    – The “Unmanaged definitions” node contains all pages that inherit from a known template without being defined in tileDefinitions.xml (see Solution 5 of http://www.javaworld.com/javaworld/jw-01-2002/jw-0104-tilestrut.html)

    Hope this makes sense. This would absolutely rock, and I haven’t seen any other IDE has this feature (don’t know about JDeveloper or JBuilder though)

    – Mikael

    #220328 Reply

    Riyad Kalla
    Member

    Great suggestion and detail, I will file it.

    #220330 Reply

    Robert Varga
    Participant

    Is it valid to declare a taglib inside a tile when it has also been declared in its parent, or does it lead to compile errors?

    If it is allowed, and it does not throw compile errors, then not declaring it inside the tile is a Bad Thing(TM) (bad coding practice) because you are not obligated to use that tile in that particular parent that contains the taglib definition, but you can refer on it from any other parents as well or without any parents at all, in which case you will definitely get compile errors.

    Just my 2 cents.

    Regards,

    Robert Varga

    #220333 Reply

    pmd
    Member

    I second this request.

    This would be extremely useful when developing with Struts 🙂

    #220338 Reply

    carniz
    Member

    You *can* declare a taglib inside a tile when it has also been declared in the parent, but this is not the main issue. Starting the tile whith eg a (html) select tag without embedding it inside a body tag still leads to validation errors. And a tiles explorer + code folding of included tiles would still be great! 🙂

    – Mikael

    #220364 Reply

    Robert Varga
    Participant

    @carniz wrote:

    You *can* declare a taglib inside a tile when it has also been declared in the parent, but this is not the main issue. Starting the tile whith eg a (html) select tag without embedding it inside a body tag still leads to validation errors. And a tiles explorer + code folding of included tiles would still be great! 🙂

    – Mikael

    Since it is valid, then in essence you are advocating a feature which makes it easier to use a bad coding practice (not declaring the taglib of a custom tag used in a tile inside the tile using the custom tag) by getting rid of errors (complaining about the taglib not being declared) which errors could be avoided by using an appropriate coding practice (declaring the taglib in the inner tile).

    These errors are absolutely valid and should NOT be disposed of because if you happened to use that tile standalone or from a parent which does not declare the taglib, then you would get a compile error, exactly the particular one you were trying get rid of.

    As I see it, it is not as if it were impossible to do the right thing, as it were if you would not be allowed to declare the taglib twice. It is just a question of lazyness.

    I don’t have a problem (for now) with the other requested features, but this compile error should remain reported, regardless of how the tile is actually used in the project.

    Just my 2 cents…

    Regards,

    Robert Varga

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Struts tiles support

You must be logged in to post in the forum log in