You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by nhhockeyplayer nashua <nh...@hotmail.com> on 2012/12/25 12:27:30 UTC

how does tapestry know what model for parameter during onActivate event

Hi Folks,

Here is some code...

public class List
{

    @Inject
    private PersistenceService persistenceService;

    @Inject
    private Messages messages;

    @Property(write = false)
    private Class beanType;

    @Property
    private Object bean;

    @Component
    private Grid grid;

    @OnEvent(EventConstants.ACTIVATE)
    Object onActivate(Class clazz)
...
}

My question is simple... 
1. how does tapestry know what object to transport for the formal parameter clazz ?
2. where does that actual object for the formal parameter clazz come from ?
3. is there anything I can do within this public class List to influence this formal parameter ?

Thanks
merry christmas
 		 	   		  

Re: how does tapestry know what model for parameter during onActivate event

Posted by Howard Lewis Ship <hl...@gmail.com>.
It looks at the parameter type: String, Date, Long, and uses the
ValueEncoderSource service (ultimately, backed by the TypeCoercer) to find
a coercsion from String to the parameter's type.  The URL is a string, the
values in the extra path are strings, HTTP is all about strings.

By implication, if your page activation context encodes, say, a Date and
your activate event handler declares that the parameter is, say, a Long,
then you'll get a runtime exception as the string representation of a Date
is converted to a Long and fails with NumberFormatException.

I don't believe there is a built-in coercion from String to Class; if you
are not providing one, the TypeCoercer will likely fail.

I've seen people go a little crazy trying to create TheOneTrueBaseClass
rather than accept a limited amount of boilerplate and subclassing.  And
I've seen the people who have created TheOneTrueBaseClass get frustrated,
as their base class gets cluttered and complected with special cases ad
nauseum.


On Tue, Dec 25, 2012 at 3:44 AM, nhhockeyplayer nashua <
nhhockeyplayer@hotmail.com> wrote:

>
> I had a fourth question...
>
> 4. how can a developer configure and specify a formal parameter to
> reliably come in during the onActivate event?
>
> Thanks
> merry christmas
>
>




-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

RE: how does tapestry know what model for parameter during onActivate event

Posted by nhhockeyplayer nashua <nh...@hotmail.com>.
I had a fourth question...

4. how can a developer configure and specify a formal parameter to reliably come in during the onActivate event?

Thanks
merry christmas