You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Michal Gruca <mi...@gmail.com> on 2010/10/05 15:09:09 UTC

[T5.2] Constructor issue

Hi all.
While preparing small showcase app, odd problem came out. When I created
domain object with two constructors (first was default NOOP, second one had
two parameters string and enum, it was meant for manual initialization only)
and tried to use it with beaneditform I received exception that tapestry
cannot handle my object creation. After removing parametrized constructor,
error disappeared. It's bit odd IMHO. Tapestry should be capable to
instantiate objects that have more than one constructor. Also @SessionState
behaved weirdly. I was annotating java.util.Date. Error came up if I haven't
instantiate object manually. Date has default constructor so Tapestry should
be fine with constructing new Date on it's own.
Maybe there are some reasons for that kind of behavior, but as I see it
those are bugs. Should I create jira ticket for that?

Tested on tapestry 5.2.1-snapshot. Link to application sources:
https://bitbucket.org/mgruca/tjug_tapestry_30.09.10/downloads  (last
revision or two were stripped out from additional constructors. Content may
be in Polish, but code should be all in En)
-- 
View this message in context: http://tapestry-users.832.n2.nabble.com/T5-2-Constructor-issue-tp5603058p5603058.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

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


RE: [T5.2] Constructor issue

Posted by Jim O'Callaghan <jc...@yahoo.co.uk>.
I thought you should annotate the constructor you want the BEF to use with:

@Inject

... to let Tap know which constructor to use.

Regards,
Jim.

-----Original Message-----
From: Michal Gruca [mailto:michalgruca@gmail.com] 
Sent: 05 October 2010 14:09
To: users@tapestry.apache.org
Subject: [T5.2] Constructor issue


Hi all.
While preparing small showcase app, odd problem came out. When I created
domain object with two constructors (first was default NOOP, second one had
two parameters string and enum, it was meant for manual initialization only)
and tried to use it with beaneditform I received exception that tapestry
cannot handle my object creation. After removing parametrized constructor,
error disappeared. It's bit odd IMHO. Tapestry should be capable to
instantiate objects that have more than one constructor. Also @SessionState
behaved weirdly. I was annotating java.util.Date. Error came up if I haven't
instantiate object manually. Date has default constructor so Tapestry should
be fine with constructing new Date on it's own.
Maybe there are some reasons for that kind of behavior, but as I see it
those are bugs. Should I create jira ticket for that?

Tested on tapestry 5.2.1-snapshot. Link to application sources:
https://bitbucket.org/mgruca/tjug_tapestry_30.09.10/downloads  (last
revision or two were stripped out from additional constructors. Content may
be in Polish, but code should be all in En)
-- 
View this message in context:
http://tapestry-users.832.n2.nabble.com/T5-2-Constructor-issue-tp5603058p560
3058.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

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



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


Re: [T5.2] Constructor issue

Posted by Michal Gruca <mi...@gmail.com>.

Howard Lewis Ship wrote:
> 
> Remember that you can place @Inject on the constructor that should be
> used if there's any ambiguity.
> 

That is what I was looking for. Thanks :)
and +1 for adding that to FAQ :)
-- 
View this message in context: http://tapestry-users.832.n2.nabble.com/T5-2-Constructor-issue-tp5603058p5605989.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

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


Re: [T5.2] Constructor issue

Posted by Jochen Berger <fo...@googlemail.com>.
Hi,

Am Dienstag, den 05.10.2010, 09:22 -0700 schrieb Howard Lewis Ship:
> Remember that you can place @Inject on the constructor that should be
> used if there's any ambiguity.

I think, this would make a great FAQ entry. I can only speak for myself,
but I wasn't aware that this was already possible. I even thought about
proposing an annotation for that purpose while reading this thread.

Regards,
Jochen

> On Tue, Oct 5, 2010 at 9:22 AM, Howard Lewis Ship <hl...@gmail.com> wrote:
> > Your are correct and this has been the behavior since at least 5.1.
> >
> > On Tue, Oct 5, 2010 at 9:21 AM, Josh Canfield <jo...@gmail.com> wrote:
> >>>
> >>> BeanEditor (used internally for BeanEditForm) uses the no-args constructor
> >>> if it exists. I apologize for not making this distinction clear.
> >>>
> >>
> >> I'm looking at the 5.2 source and BeanEditor uses the BeanModel to get
> >> the instance, calls "newInstance()" which also uses the
> >> ObjectLocator.autobuild
> >>
> >> On Tue, Oct 5, 2010 at 8:32 AM, Thiago H. de Paula Figueiredo
> >> <th...@gmail.com> wrote:
> >>> On Tue, 05 Oct 2010 12:17:46 -0300, Michal Gruca <mi...@gmail.com>
> >>> wrote:
> >>>
> >>>> I must disagree.
> >>>> But first to clarify. I described two cases.
> >>>> 1. BeanEditForm that cannot instantiate my object
> >>>
> >>> BeanEditor (used internally for BeanEditForm) uses the no-args constructor
> >>> if it exists. I apologize for not making this distinction clear.
> >>>
> >>>> 2. Same issue for SSO creating java.util.Date
> >>>
> >>> ApplicationStateManager(Impl) uses ObjectLocator.autobuild() to construct
> >>> instances.
> >>>
> >>>> Ad 2.
> >>>> Quote from linked documentation:
> >>>> "The first time you access an SSO, it is created automatically. Typically,
> >>>> the SSO will have a public no-args constructor ... but you may inject
> >>>> dependencies into the SSO via its constructor, as you can with a Tapestry
> >>>> IoC service implementation."
> >>>> In this case I wanted to use Date. Maybe not some real case scenario, so
> >>>> let's think about shoping basket for example. It may have default no args
> >>>> for T5 and second one if I want to instantiate it with some products. If
> >>>> T5 always takes constructor with most arguments it will fail on that
> >>>> scenario
> >>>> also, meaning that I will have to check boolean variable companion exist
> >>>> on every page on which I wan't to use my object.
> >>>
> >>> In this case, use @SessionState(create = false) so the field is null when
> >>> it's not in the session. and you don't need to declare a boolean variable.
> >>>
> >>> --
> >>> 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-unsubscribe@tapestry.apache.org
> >>> For additional commands, e-mail: users-help@tapestry.apache.org
> >>>
> >>>
> >>
> >>
> >>
> >> --
> >> --
> >> http://www.bodylabgym.com - a private, by appointment only, one-on-one
> >> health and fitness facility.
> >> --
> >> http://www.ectransition.com - Quality Electronic Cigarettes at a
> >> reasonable price!
> >> --
> >> 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
> >>
> >>
> >
> >
> >
> > --
> > 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
> >
> 
> 
> 



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


Re: [T5.2] Constructor issue

Posted by Howard Lewis Ship <hl...@gmail.com>.
Remember that you can place @Inject on the constructor that should be
used if there's any ambiguity.

On Tue, Oct 5, 2010 at 9:22 AM, Howard Lewis Ship <hl...@gmail.com> wrote:
> Your are correct and this has been the behavior since at least 5.1.
>
> On Tue, Oct 5, 2010 at 9:21 AM, Josh Canfield <jo...@gmail.com> wrote:
>>>
>>> BeanEditor (used internally for BeanEditForm) uses the no-args constructor
>>> if it exists. I apologize for not making this distinction clear.
>>>
>>
>> I'm looking at the 5.2 source and BeanEditor uses the BeanModel to get
>> the instance, calls "newInstance()" which also uses the
>> ObjectLocator.autobuild
>>
>> On Tue, Oct 5, 2010 at 8:32 AM, Thiago H. de Paula Figueiredo
>> <th...@gmail.com> wrote:
>>> On Tue, 05 Oct 2010 12:17:46 -0300, Michal Gruca <mi...@gmail.com>
>>> wrote:
>>>
>>>> I must disagree.
>>>> But first to clarify. I described two cases.
>>>> 1. BeanEditForm that cannot instantiate my object
>>>
>>> BeanEditor (used internally for BeanEditForm) uses the no-args constructor
>>> if it exists. I apologize for not making this distinction clear.
>>>
>>>> 2. Same issue for SSO creating java.util.Date
>>>
>>> ApplicationStateManager(Impl) uses ObjectLocator.autobuild() to construct
>>> instances.
>>>
>>>> Ad 2.
>>>> Quote from linked documentation:
>>>> "The first time you access an SSO, it is created automatically. Typically,
>>>> the SSO will have a public no-args constructor ... but you may inject
>>>> dependencies into the SSO via its constructor, as you can with a Tapestry
>>>> IoC service implementation."
>>>> In this case I wanted to use Date. Maybe not some real case scenario, so
>>>> let's think about shoping basket for example. It may have default no args
>>>> for T5 and second one if I want to instantiate it with some products. If
>>>> T5 always takes constructor with most arguments it will fail on that
>>>> scenario
>>>> also, meaning that I will have to check boolean variable companion exist
>>>> on every page on which I wan't to use my object.
>>>
>>> In this case, use @SessionState(create = false) so the field is null when
>>> it's not in the session. and you don't need to declare a boolean variable.
>>>
>>> --
>>> 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-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>>
>>
>> --
>> --
>> http://www.bodylabgym.com - a private, by appointment only, one-on-one
>> health and fitness facility.
>> --
>> http://www.ectransition.com - Quality Electronic Cigarettes at a
>> reasonable price!
>> --
>> 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
>>
>>
>
>
>
> --
> 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
>



-- 
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

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


Re: [T5.2] Constructor issue

Posted by Howard Lewis Ship <hl...@gmail.com>.
Your are correct and this has been the behavior since at least 5.1.

On Tue, Oct 5, 2010 at 9:21 AM, Josh Canfield <jo...@gmail.com> wrote:
>>
>> BeanEditor (used internally for BeanEditForm) uses the no-args constructor
>> if it exists. I apologize for not making this distinction clear.
>>
>
> I'm looking at the 5.2 source and BeanEditor uses the BeanModel to get
> the instance, calls "newInstance()" which also uses the
> ObjectLocator.autobuild
>
> On Tue, Oct 5, 2010 at 8:32 AM, Thiago H. de Paula Figueiredo
> <th...@gmail.com> wrote:
>> On Tue, 05 Oct 2010 12:17:46 -0300, Michal Gruca <mi...@gmail.com>
>> wrote:
>>
>>> I must disagree.
>>> But first to clarify. I described two cases.
>>> 1. BeanEditForm that cannot instantiate my object
>>
>> BeanEditor (used internally for BeanEditForm) uses the no-args constructor
>> if it exists. I apologize for not making this distinction clear.
>>
>>> 2. Same issue for SSO creating java.util.Date
>>
>> ApplicationStateManager(Impl) uses ObjectLocator.autobuild() to construct
>> instances.
>>
>>> Ad 2.
>>> Quote from linked documentation:
>>> "The first time you access an SSO, it is created automatically. Typically,
>>> the SSO will have a public no-args constructor ... but you may inject
>>> dependencies into the SSO via its constructor, as you can with a Tapestry
>>> IoC service implementation."
>>> In this case I wanted to use Date. Maybe not some real case scenario, so
>>> let's think about shoping basket for example. It may have default no args
>>> for T5 and second one if I want to instantiate it with some products. If
>>> T5 always takes constructor with most arguments it will fail on that
>>> scenario
>>> also, meaning that I will have to check boolean variable companion exist
>>> on every page on which I wan't to use my object.
>>
>> In this case, use @SessionState(create = false) so the field is null when
>> it's not in the session. and you don't need to declare a boolean variable.
>>
>> --
>> 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-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
>
> --
> --
> http://www.bodylabgym.com - a private, by appointment only, one-on-one
> health and fitness facility.
> --
> http://www.ectransition.com - Quality Electronic Cigarettes at a
> reasonable price!
> --
> 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
>
>



-- 
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

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


Re: [T5.2] Constructor issue

Posted by Josh Canfield <jo...@gmail.com>.
>
> BeanEditor (used internally for BeanEditForm) uses the no-args constructor
> if it exists. I apologize for not making this distinction clear.
>

I'm looking at the 5.2 source and BeanEditor uses the BeanModel to get
the instance, calls "newInstance()" which also uses the
ObjectLocator.autobuild

On Tue, Oct 5, 2010 at 8:32 AM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> On Tue, 05 Oct 2010 12:17:46 -0300, Michal Gruca <mi...@gmail.com>
> wrote:
>
>> I must disagree.
>> But first to clarify. I described two cases.
>> 1. BeanEditForm that cannot instantiate my object
>
> BeanEditor (used internally for BeanEditForm) uses the no-args constructor
> if it exists. I apologize for not making this distinction clear.
>
>> 2. Same issue for SSO creating java.util.Date
>
> ApplicationStateManager(Impl) uses ObjectLocator.autobuild() to construct
> instances.
>
>> Ad 2.
>> Quote from linked documentation:
>> "The first time you access an SSO, it is created automatically. Typically,
>> the SSO will have a public no-args constructor ... but you may inject
>> dependencies into the SSO via its constructor, as you can with a Tapestry
>> IoC service implementation."
>> In this case I wanted to use Date. Maybe not some real case scenario, so
>> let's think about shoping basket for example. It may have default no args
>> for T5 and second one if I want to instantiate it with some products. If
>> T5 always takes constructor with most arguments it will fail on that
>> scenario
>> also, meaning that I will have to check boolean variable companion exist
>> on every page on which I wan't to use my object.
>
> In this case, use @SessionState(create = false) so the field is null when
> it's not in the session. and you don't need to declare a boolean variable.
>
> --
> 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-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
--
http://www.bodylabgym.com - a private, by appointment only, one-on-one
health and fitness facility.
--
http://www.ectransition.com - Quality Electronic Cigarettes at a
reasonable price!
--
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


Re: [T5.2] Constructor issue

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 05 Oct 2010 12:17:46 -0300, Michal Gruca <mi...@gmail.com>  
wrote:

> I must disagree.
> But first to clarify. I described two cases.
> 1. BeanEditForm that cannot instantiate my object

BeanEditor (used internally for BeanEditForm) uses the no-args constructor  
if it exists. I apologize for not making this distinction clear.

> 2. Same issue for SSO creating java.util.Date

ApplicationStateManager(Impl) uses ObjectLocator.autobuild() to construct  
instances.

> Ad 2.
> Quote from linked documentation:
> "The first time you access an SSO, it is created automatically.  
> Typically, the SSO will have a public no-args constructor ... but you  
> may inject
> dependencies into the SSO via its constructor, as you can with a Tapestry
> IoC service implementation."
> In this case I wanted to use Date. Maybe not some real case scenario, so
> let's think about shoping basket for example. It may have default no args
> for T5 and second one if I want to instantiate it with some products. If  
> T5 always takes constructor with most arguments it will fail on that  
> scenario
> also, meaning that I will have to check boolean variable companion exist  
> on every page on which I wan't to use my object.

In this case, use @SessionState(create = false) so the field is null when  
it's not in the session. and you don't need to declare a boolean variable.

-- 
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-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5.2] Constructor issue

Posted by Josh Canfield <jo...@gmail.com>.
> "Often, the BeanEditForm can create the object as needed (assuming a public,
> no arguments constructor). "
I believe the java docs are out of date. The change happened in a
dependent class and the docs don't reflect the change. As Thiago said,
the current strategy is to try to make the most complete object is
built based on the available constructors. This lets you build beans
that have access to services via constructor injection (like a
service).

I think failing to pick the correct constructor is a defect that
Tapestry *should* solve.  Principle 2 is Adaptive API, which should
"adapt to your code". One option is to try them until you get one that
works... this could lead to frustration during development if it's not
obvious which constructor is getting called...

Date has multiple constructors, so this is essentially the same problem.

Josh

On Tue, Oct 5, 2010 at 8:17 AM, Michal Gruca <mi...@gmail.com> wrote:
>
> I must disagree.
> But first to clarify. I described two cases.
> 1. BeanEditForm that cannot instantiate my object
> 2. Same issue for SSO creating java.util.Date
>
> AD 1.
> Quote from BeanEditForm doc:
> "Often, the BeanEditForm can create the object as needed (assuming a public,
> no arguments constructor). "
> So i provided such constructor in my entity (public no agrs) + I added
> another one that taken String and custom enum. What I assumed was that T5
> will just use the one that it can use and leave other one alone. Due to that
> behavior no object handled to BeanEditForm should have more constructors
> than default one, or should be always created manually, and that is bit more
> than user need to do.
>
> Ad 2.
> Quote from linked documentation:
> "The first time you access an SSO, it is created automatically. Typically,
> the SSO will have a public no-args constructor ... but you may inject
> dependencies into the SSO via its constructor, as you can with a Tapestry
> IoC service implementation."
> In this case I wanted to use Date. Maybe not some real case scenario, so
> let's think about shoping basket for example. It may have default no args
> for T5 and second one if I want to instantiate it with some products. If T5
> always takes constructor with most arguments it will fail on that scenario
> also, meaning that I will have to check boolean variable companion exist on
> every page on which I wan't to use my object.
> IMHO the best would be try to use no-args constructor or use one with most
> args and if You fail try another one and another till You succeed (meaning
> reach default no-args or error when there is no default no-args
> constructor).
>
> Regards
> Michał
> --
> View this message in context: http://tapestry-users.832.n2.nabble.com/T5-2-Constructor-issue-tp5603058p5603560.html
> Sent from the Tapestry Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
--
http://www.bodylabgym.com - a private, by appointment only, one-on-one
health and fitness facility.
--
http://www.ectransition.com - Quality Electronic Cigarettes at a
reasonable price!
--
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


Re: [T5.2] Constructor issue

Posted by Michal Gruca <mi...@gmail.com>.
I must disagree. 
But first to clarify. I described two cases.
1. BeanEditForm that cannot instantiate my object
2. Same issue for SSO creating java.util.Date

AD 1.
Quote from BeanEditForm doc:
"Often, the BeanEditForm can create the object as needed (assuming a public,
no arguments constructor). "
So i provided such constructor in my entity (public no agrs) + I added
another one that taken String and custom enum. What I assumed was that T5
will just use the one that it can use and leave other one alone. Due to that
behavior no object handled to BeanEditForm should have more constructors
than default one, or should be always created manually, and that is bit more
than user need to do.

Ad 2.
Quote from linked documentation:
"The first time you access an SSO, it is created automatically. Typically,
the SSO will have a public no-args constructor ... but you may inject
dependencies into the SSO via its constructor, as you can with a Tapestry
IoC service implementation."
In this case I wanted to use Date. Maybe not some real case scenario, so
let's think about shoping basket for example. It may have default no args
for T5 and second one if I want to instantiate it with some products. If T5
always takes constructor with most arguments it will fail on that scenario
also, meaning that I will have to check boolean variable companion exist on
every page on which I wan't to use my object.
IMHO the best would be try to use no-args constructor or use one with most
args and if You fail try another one and another till You succeed (meaning
reach default no-args or error when there is no default no-args
constructor).

Regards
Michał
-- 
View this message in context: http://tapestry-users.832.n2.nabble.com/T5-2-Constructor-issue-tp5603058p5603560.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

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


Re: T5.1 - authenticating page access & contributing a sevice

Posted by Richard Hill <ri...@su3analytics.com>.
Hi Thiago,

That's tremendous, thanks for the help.

R.


-----Original Message-----
From: Thiago H. de Paula Figueiredo <th...@gmail.com>
Reply-to: "Tapestry users" <us...@tapestry.apache.org>
To: Tapestry users <us...@tapestry.apache.org>
Subject: Re: T5.1 - authenticating page access & contributing a sevice
Date: Tue, 05 Oct 2010 12:28:41 -0300

On Tue, 05 Oct 2010 12:01:57 -0300, Richard Hill <ri...@su3analytics.com>  
wrote:

> Hi All,

Hi!

> Now my question is two-fold:
>
> 1) How do I define and contribute a service in tapestry?

Using Tapestry IoC:  
http://tapestry.apache.org/tapestry5.1/tapestry-ioc/service.html.

> 2) How does this guy know that the user _is_ authenticated? Should my
> service cache logged-in users itself, or can it access the session?

Both options sound the same to me. In your RequestFilter (or any other  
class that isn't a page, component or mixin), use the  
ApplicationStateManager service to get or set the value of a given class  
persisted using @SessionState.




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


Re: T5.1 - authenticating page access & contributing a sevice

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 05 Oct 2010 12:01:57 -0300, Richard Hill <ri...@su3analytics.com>  
wrote:

> Hi All,

Hi!

> Now my question is two-fold:
>
> 1) How do I define and contribute a service in tapestry?

Using Tapestry IoC:  
http://tapestry.apache.org/tapestry5.1/tapestry-ioc/service.html.

> 2) How does this guy know that the user _is_ authenticated? Should my
> service cache logged-in users itself, or can it access the session?

Both options sound the same to me. In your RequestFilter (or any other  
class that isn't a page, component or mixin), use the  
ApplicationStateManager service to get or set the value of a given class  
persisted using @SessionState.

-- 
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-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


T5.1 - authenticating page access & contributing a sevice

Posted by Richard Hill <ri...@su3analytics.com>.
Hi All,

I know there has been some discussion on best approaches in tapestry for
authenticating access to web pages, so apologies if i have missed the
answer to this:

Initially I was tempted by the simplest approach - that is just store
some "UserState" in the session via @SessionState and check this in
onActivate().

However I feel using a "@RequiresLogin" annotation approach is a little
more robust. I've been following Howard's tutorial here:

http://tapestryjava.blogspot.com/2009/12/securing-tapestry-pages-with.html

Now my question is two-fold:

1) How do I define and contribute a service in tapestry?
2) How does this guy know that the user _is_ authenticated? Should my
service cache logged-in users itself, or can it access the session?

Thanks for help,

Richard.





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


Re: [T5.2] Constructor issue

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 05 Oct 2010 10:09:09 -0300, Michal Gruca <mi...@gmail.com>  
wrote:

> Hi all.

Hi!

> After removing parametrized constructor,
> error disappeared. It's bit odd IMHO.

That's documented behavior:  
http://tapestry.apache.org/tapestry5.1/guide/appstate.html. This page is  
for 5.1, but it should be the same for 5.2. Summary: Tapestry uses the  
same logic for choosing a constructor used by Tapestry IoC. That page  
shows you how to control the way you classes are instantiated.

> Tapestry should be capable to
> instantiate objects that have more than one constructor.

The problem here is: which constructor should be used? Tapestry IoC  
chooses the one with the most parameters.

-- 
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-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org