Tapestry 5
  1. Tapestry 5
  2. TAP5-571

Misplaced <t:parameter> results in an inscrutable exception

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 5.1.0.0
    • Fix Version/s: 5.1.0.4
    • Component/s: tapestry-core
    • Labels:
      None

      Description

      If <t:parameter> is used not inside a component, a inscrutable exception occurs. The message of the exception doesn't tell at all what the reason was.
      PageLoaderProcessor should catch the IllegalStateException inside the method parameter(ParameterToken) and throw TapestryException containing the location of the current token. This will provide a reasonable exception report.

      java.lang.IllegalStateException: Stack is empty.
      at org.apache.tapestry5.ioc.util.Stack.checkIfEmpty(Stack.java:119)
      at org.apache.tapestry5.ioc.util.Stack.peek(Stack.java:131)
      at org.apache.tapestry5.internal.services.PageLoaderProcessor.parameter(PageLoaderProcessor.java:594)
      at org.apache.tapestry5.internal.services.PageLoaderProcessor.loadTemplateForComponent(PageLoaderProcessor.java:519)
      at org.apache.tapestry5.internal.services.PageLoaderProcessor.workComponentQueue(PageLoaderProcessor.java:834)
      at org.apache.tapestry5.internal.services.PageLoaderProcessor.loadPage(PageLoaderProcessor.java:392)
      at org.apache.tapestry5.internal.services.PageLoaderImpl.loadPage(PageLoaderImpl.java:59)
      at $PageLoader_11ff4e54e7f.loadPage($PageLoader_11ff4e54e7f.java)
      at org.apache.tapestry5.internal.services.PagePoolCache.checkout(PagePoolCache.java:210)
      at org.apache.tapestry5.internal.services.PagePoolImpl.checkout(PagePoolImpl.java:99)

      To reproduce the problem create the following page:

      <html xml:space="default" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
      <body>
      <t:unless test="some condition">
      Foo
      </t:unless>
      <t:parameter name="else">
      Bar
      </t:parameter>
      </body>
      </html>

        Activity

        Hide
        Howard M. Lewis Ship added a comment -

        Shouldn't be necessary to catch and exception; it's just a matter of checking to see if the stack is empty inside the parameter() method.

        Show
        Howard M. Lewis Ship added a comment - Shouldn't be necessary to catch and exception; it's just a matter of checking to see if the stack is empty inside the parameter() method.
        Hide
        Howard M. Lewis Ship added a comment -

        This situation can be tracked inside the template parser, and that's the way the fix was implemented.

        Show
        Howard M. Lewis Ship added a comment - This situation can be tracked inside the template parser, and that's the way the fix was implemented.
        Hide
        DH added a comment -

        The fix is not so perfect.

        <html xml:space="default" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" t:type="Layout" xmlns="tapestry:parameter">
        <p:body>
        simple test
        </p:/body>
        </html>

        is ok.

        But

        <html xml:space="default" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" t:type="Layout" xmlns="tapestry:parameter">
        <div>
        <p:body>
        simple test
        </p:/body>
        </div>
        </html>

        will lead to "Block parameters are only allowed directly within component elements.". Because p:body is embeded in general 'div' label.

        To keep the html previewability, I think it is important to make this case legal.

        Show
        DH added a comment - The fix is not so perfect. <html xml:space="default" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" t:type="Layout" xmlns ="tapestry:parameter"> <p:body> simple test </p:/body> </html> is ok. But <html xml:space="default" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd" t:type="Layout" xmlns ="tapestry:parameter"> <div> <p:body> simple test </p:/body> </div> </html> will lead to "Block parameters are only allowed directly within component elements.". Because p:body is embeded in general 'div' label. To keep the html previewability, I think it is important to make this case legal.
        Hide
        Stefan Esterer added a comment -

        I got bitten by this problem too. Is there any reason not allowing the second code example above?

        Show
        Stefan Esterer added a comment - I got bitten by this problem too. Is there any reason not allowing the second code example above?

          People

          • Assignee:
            Howard M. Lewis Ship
            Reporter:
            Igor Drobiazko
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development