Hi Thiago,

I can't declare it into my page as I'm using it in the Layout component and
not in a page.

Here is the Layout.java :

    @Inject
    private ComponentSource componentSource;

    @Inject
    private ComponentResources componentResources;

    /** The page title, for the <title> element and the <h1> element. */
    @Property
    @Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
    private String title;


    /** The template name, for the structure of the layout. */
    @Property
    @Parameter(required = true, defaultPrefix = BindingConstants.LITERAL)
    private String template;

    public Object getSelectedTemplate(){
        try {
            Component selectedTemplate =
componentSource.getPage("internal/templates");
            return
selectedTemplate.getComponentResources().getBlock(template+"_template");
        }
        catch (BlockNotFoundException e) {
            return useDefaultTemplate(e);
        }
        catch (IllegalArgumentException e) {
            return useDefaultTemplate(e);
        }
    }

    private Object useDefaultTemplate(Throwable e) {
        getLogger().error("Template ["+template+"] cannot be found, using
default instead",e);
        return componentResources.getBlock("default_template");
    }


Actually, I should declare the different templates (Blocks) in my
Layout.tml. I don't like it very much as the templates may be quite
numerous.... But it seems that I don't have other possibilities.

For the easier way, I knew this one : efficient but I don't know why, I feel
it quite dirty :p

Anyway, thanks for the help!

Thomas.

2010/5/11 Thiago H. de Paula Figueiredo <thiag...@gmail.com>

> On Tue, 11 May 2010 10:34:52 -0300, Thomas Cucchietti <
> thomas.cucchie...@gmail.com> wrote:
>
>  So, I have to create a page only for internal use in order to follow this
>> philosophy.
>>
>
> You don't need to create a page just for holding your component. Just
> create a Block inside your page and declare you component there. Then you
> can use the Delegate component to render the component or not.
>
>
>  How can I prevent user to access this page ?
>>
>
> Easier way: add this method to that page:
>
> Object onActivate() {
>        return Index.class;
> }
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

Reply via email to