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...@web.de> on 2008/03/30 14:19:10 UTC

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?

_______________________________________________________________________
Jetzt neu! Schützen Sie Ihren PC mit McAfee und WEB.DE. 30 Tage
kostenlos testen. http://www.pc-sicherheit.web.de/startseite/?mc=022220


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re:

Posted by César Lesc <ce...@gmail.com>.
I'm not an expert but i guess the BeanEditForm component may give you
some hints about this.

regards,

César.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re:

Posted by Josh Canfield <jo...@thedailytube.com>.
What you are trying to do goes against "Principle 1 -- Static
Structure, Dynamic Behavior", which you can read about on
http://tapestry.apache.org/tapestry5/ towards the bottom of the page.

This question has been asked before and if you search the list (try
nabble.com) you'll find more discussion.

If you know what your configurable components will be in advance you
can create one component that contains all of your sub-components and
selectively renders them based on a parameter passed.

Josh

On Sun, Mar 30, 2008 at 5:19 AM, Max Scheffler <ma...@web.de> wrote:
> 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?
>
> _______________________________________________________________________
> Jetzt neu! Schützen Sie Ihren PC mit McAfee und WEB.DE. 30 Tage
> kostenlos testen. http://www.pc-sicherheit.web.de/startseite/?mc=022220
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org