Search code examples
tapestry

Displaying a list of items in a grid Tapestry-error


I want to display a list of items in a grid and i got this error:
Failure parsing template classpath:com/mycompany/licenta/pages/ShowAll.tml: The element has been deprecated in Tapestry 5.3 in favour of 'tapestry:parameter' namespace.

My .tml page is:

<html t:type="layout" title="Show All"
      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
      xmlns:p="tapestry:parameter">

   <head>
   <title>Lista Hoteluri</title>
  </head>
   <body>
    <t:grid t:source="hotelSource" rowsPerPage="5"
row="hotel">
<t:parameter name="numeHotelCell">
<t:pagelink t:page="details" t:context="hotel.id">
${hotel.numeHotel}
</t:pagelink>
</t:parameter>
</t:grid>
   

<br/>
      <a href="#" t:type="PageLink" t:page="Index">
      Back to the Start Page</a>
    </body>

</html>

I've searched on the Internet about this problem but nothing helped me.


Solution

  • As the error says, the t:parameter element has been deprecated. Technically, it was actually removed in Tapestry 5.3. In any case, all you need to do is use the newer, more concise p: syntax (the "parameter" XML namespace) instead:

    <p:numeHotelCell>
        <t:pagelink t:page="details" t:context="hotel.id">
            ${hotel.numeHotel}
        </t:pagelink>
    </p:numeHotelCell>
    

    This is mentioned briefly here: https://tapestry.apache.org/component-templates.html

    This "parameter" namespace, using the "p:" prefix here, is already defined at the top of your template. (Technically you could declare a prefix other than "p:", but that would be unconventional.)