How can I address a block to Tapestry layout component loaded from a library?

StackOverflow https://stackoverflow.com/questions/20337338

  •  07-08-2022
  •  | 
  •  

Question

My project is splitt in two subprojects. One is a component library and the second is the main part that implements the pages and stuff.

The layout component uses blocks and delegates to implement some dynamic. Something like that:

<!DOCTYPE html>
<!-- myLayout template -->
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
      xmlns:p="tapestry:parameter">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        <link rel="SHORTCUT ICON" href="favicon.ico"/>
        <title>${title}</title>
    </head>
    <body>
        <div class="tbar">
            <t:delegate to="toolbar"/>        
        </div>
        <t:body/>
    </body>
</html>

My Page includes the layout in a way like this:

<?xml version="1.0"?>
<!-- Index.tml -->
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
    xmlns:p="tapestry:parameter"    
    xmlns:mylib="tapestry-library:myLib"
    mylib:type="myLayout">

    <p:toolbar>
        <ul class="tbuttons">
            <li>
                <t:pagelink page="exp/index" class="tbutton">
                    <img src="${context:}/static/pic/print.png"/>
                </t:pagelink>            
            </li>
        </ul>
    </p:toolbar>
</html>

If I run my project and try to access the site I got the following error:

Failure parsing template classpath:*/Index.tml: Block parameters are only allowed directly within component elements ...

The whole construct works fine if I move the layout from the library to the main application project.

Has anyone a idea?

Was it helpful?

Solution

Have you made a contribution to ComponentClassResolver? Does it work without the namespace alias?

Either:

<html
    xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
    xmlns:p="tapestry:parameter"    
    t:type="mylib/myLayout"
>

    <p:toolbar>...</p:toolbar>
</html>

Or

<t:mylib.mylayout
    xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
    xmlns:p="tapestry:parameter"
>
    <p:toolbar>...</p:toolbar>
</t:mylib.mylayout>

Full documentation on component libraries here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top