You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Luther Baker <lu...@gmail.com> on 2009/03/04 03:10:46 UTC

An edit block issue ...

I've implement GenericSelectBlock and have a corresponding edit block
defined.

I've implemented a method to get the model for the t:Select component in the
*.tml block:

    public AbstractSelectModel getModel()
    {
        List list =
this.persistenceService.findAll(InitiativeConstants.DOMAIN_CLASS);
        Collections.sort(list);

        this.values = new InjectedGenericSelectModel<Initiative>(list,
Initiative.class, "name", "id", this.propertyAccess,);
        return this.values;
    }


What I don't understand is how that succeeds and this one fails:


    public AbstractSelectModel getModel()
    {
        List list =
this.persistenceService.findAll(InitiativeConstants.DOMAIN_CLASS);
        Collections.sort(list);

        labeler = new InitiativeLabeler();
        this.values = new GenericSelectModel<Initiative>(list,
Initiative.class, "name", "id", this.propertyAccess);
        return this.values;
    }


The only thing I did was create the labeler. I don't use it for anything. If
I go one step farther - I get the same problem.

        labeler = new InitiativeLabeler();
        this.values = new InjectedGenericSelectModel<Initiative>(list,
Initiative.class, "name", "id", this.propertyAccess, labeler);
        return this.values;

or

        InitiativeLabeler labeler = new InitiativeLabeler();
        this.values = new InjectedGenericSelectModel<Initiative>(list,
Initiative.class, "name", "id", this.propertyAccess, labeler);
        return this.values;


No matter what I try, the error on the page reads:


Render queue error in BeforeRenderTemplate[initiative/BlockEdit:sid]:
Failure reading parameter 'model' of component initiative/BlockEdit:sid:
Component class
com.fuzzybearings.notebook.web.pages.initiative.InitiativeLabeler may not be
instantiated directly. You should use an @InjectPage or @InjectComponent
annotation instead.


Now, InitiativeLabeler is not a component nor does it implement or extend
anything other than an interface I made up to simply write a special type of
label into the select.options piece of GenericSelectModel. I would like to
inject different labelers into the GenericSelectModel when I create it.

Is there a trick here? The original GenericSelectModel works just fine - but
the Instantiating the Labeler seems to break something.

Thoughts?

-Luther

Re: An edit block issue ...

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Tue, 03 Mar 2009 23:28:50 -0300, Luther Baker <lu...@gmail.com>  
escreveu:

> Clarification for me - I know that Tapestry creates "pools" of my pages.
> Conceptually, I've often wondered how it does that - ie: does it nullify  
> all the fields between requests?

It depends on the field. I don't know what happens when the field is  
controlled by Tapestry (@Inject, @InjectComponent, @Component, etc).  
AFAIK, for ordinary fields, Tapestry sets each field with its initial  
value when a page is returned to the pool, unless it is annotated with  
@Retain. In this case, the fields is left as is.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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


Re: An edit block issue ...

Posted by Luther Baker <lu...@gmail.com>.
Ah ... that works (as expected).

Clarification for me - I know that Tapestry creates "pools" of my pages.
Conceptually, I've often wondered how it does that - ie: does it nullify all
the fields between requests?

Given this example, is it safe to say that it nullifies or invalidates any
field in the components, pages, or mixins package? ...

And more to my question - leaves any other declared and instantiated fields
alone?

For instance, if I instantiate and assign some utility class to a page.field
- is it predictably going to persist and even retain values that I might set
in it across requests?

Thanks Thiago,

-Luther





On Tue, Mar 3, 2009 at 8:15 PM, Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> Em Tue, 03 Mar 2009 23:10:46 -0300, Luther Baker <lu...@gmail.com>
> escreveu:
>
>  Render queue error in BeforeRenderTemplate[initiative/BlockEdit:sid]:
>> Failure reading parameter 'model' of component initiative/BlockEdit:sid:
>> Component class
>> com.fuzzybearings.notebook.web.pages.initiative.InitiativeLabeler may not be
>> instantiated directly. You should use an @InjectPage or @InjectComponent
>> annotation instead.
>>
>
> Tapestry loads page, component and mixin classes using a special
> classloader that changes them on the fly. That's why you must never, never,
> ever put a class or interface that is not a component in the components,
> pages, or mixins package. That's also why you cannot instantiate a
> component, page or mixin in your package: you must let Tapestry to do that.
>
> The solution is to move the InitiativeLabeler to another package outside
> com.fuzzybearings.notebook.web.pages.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java consultant, developer, and instructor
> http://www.arsmachina.com.br/thiago
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: An edit block issue ...

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Tue, 03 Mar 2009 23:10:46 -0300, Luther Baker <lu...@gmail.com>  
escreveu:

> Render queue error in BeforeRenderTemplate[initiative/BlockEdit:sid]:
> Failure reading parameter 'model' of component initiative/BlockEdit:sid:
> Component class  
> com.fuzzybearings.notebook.web.pages.initiative.InitiativeLabeler may  
> not be instantiated directly. You should use an @InjectPage or  
> @InjectComponent
> annotation instead.

Tapestry loads page, component and mixin classes using a special  
classloader that changes them on the fly. That's why you must never,  
never, ever put a class or interface that is not a component in the  
components, pages, or mixins package. That's also why you cannot  
instantiate a component, page or mixin in your package: you must let  
Tapestry to do that.

The solution is to move the InitiativeLabeler to another package outside  
com.fuzzybearings.notebook.web.pages.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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