You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Max Scheffler <ma...@freiheit.com> on 2008/03/31 18:21:21 UTC
Retrieving an instance of a component in code [WAS Re: [T5] A small
CMS in Tapestry]
Max Scheffler schrieb:
> Hi,
>
> I want to create a small CMS. The main purpose is to make a limited
> number of pages configurable.
> Configurable means that I use a template with placeholders in which
> components out of a set can be filled in.
>
> For example the template:
>
> SimpleSkeleton.tml
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html>
> <head>
> <title>Title<title>
> </head>
> <body>
>
> <t:delegate t:to="component11" />
>
> <br />
>
> <t:delegate t:to="component12" />
>
> </body>
> </html>
>
> One of the components could be as follows:
>
> SimpleLinkedImage.tml:
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <div xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
>
> <a href="#" t:type="pagelink" t:page="page" t:context="context">
> <img src="${imageUrl}" alt="${imageName}" name="${imageName}" />
> </a>
>
> </div>
>
> SimpleLinkedImage.java:
>
> public class SimpleLinkedImage {
>
> private String _page;
> private List<String> _context;
> private String _imageUrl;
> private String _imageName;
>
> // setter and getter
> }
>
> Because it's not possible to predict which component would be needed and
> how often, I want to create it programmatically by using this code.
>
> SimpleSkeleton.java
>
> public class SimpleSkeleton {
>
> public Object getComponent11 () {
>
> linkedImage = new SimpleLinkedImage();
>
> linkedImage.setImageUrl(
> "http://tapestry.apache.org/tapestry5/images/tapestry_banner.gif" );
> linkedImage.setImageName( "Tapestry Banner" );
> linkedImage.setPage( "start" );
> linkedImage.setContext( null );
>
> return linkedImage;
> }
>
> public Object getComponent12 () {
>
> linkedImage = new SimpleLinkedImage();
>
> linkedImage.setImageUrl(
> "http://tapestry.apache.org/tapestry5/images/tapestry_banner.gif" );
> linkedImage.setImageName( "Tapestry Banner_2" );
> linkedImage.setPage( "start" );
> linkedImage.setContext( null );
>
> return linkedImage;
> }
>
> }
>
> But as you can imagine it dosen't work. Is there another approach to
> solve this problem?
>
> Greetings
> Max
--
Max Scheffler
Dipl.-Inf.
freiheit.com technologies gmbh
Straßenbahnring 22 / 20251 Hamburg, Germany
fon +49 (0)40 / 890584-0
fax +49 (0)40 / 890584-20
HRB Hamburg 70814
585C 6EC1 6C6A CE17 FF25 36B0 27EA BC20 4610 5BB0
Geschäftsführer: Claudia Dietze, Stefan Richter, Jörg Kirchhof
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org