Uploaded image for project: 'Tiles'
  1. Tiles
  2. TILES-494

Add support for a default value to attribute's cascade

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Won't Fix
    • 2.2.2
    • None
    • tiles-core
    • None

    Description

      Make it possible to specify a default value for attribute@cascade.

      I'm writing definitions for a legacy project and we don't have the luxury of a flat template that directly inserts each defined attribute.
      To have to specify cascade="true" on every put-attribute seems excessive verbosity.

      One solution would be to add a boolean attribute cascadeAttributes to Definition.

      For example:

      <definition name="myapp.homepage" template="/layouts/classic.jsp" cascade-attributes="true">
      <put-attribute name="header" value="/tiles/banner.jsp" />
      <put-attribute name="menu" value="/tiles/common_menu.jsp" />
      <put-attribute name="body" value="/tiles/home_body.jsp" />
      <put-attribute name="footer" value="/tiles/credits.jsp" />
      </definition>

      instead of today's

      <definition name="myapp.homepage" template="/layouts/classic.jsp">
      <put-attribute name="header" value="/tiles/banner.jsp" cascade="true" />
      <put-attribute name="menu" value="/tiles/common_menu.jsp" cascade="true" />
      <put-attribute name="body" value="/tiles/home_body.jsp" cascade="true" />
      <put-attribute name="footer" value="/tiles/credits.jsp" cascade="true" />
      </definition>

      Implementation:

      + add to FillDefinitionRule.begin()
      definition.setCascadeAttributes("true".equals(attributes.getValue("cascade-attributes")));

      + change in PutAttributeRule.begin()
      definition.putAttribute(attributes.getValue("name"), attribute,
      "true".equals(attributes.getValue("cascade")) || definition.getCascadeAttributes());

      + add to Definition the getter and setter methods: getCascadeAttributes and setCascadeAttributes

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mck Michael Semb Wever
              Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: