You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by membersound <me...@web.de> on 2012/10/28 14:06:23 UTC
Inject managed beans?
What is the T5 equivalent to the following JSF?
@RequestScoped @Named
class Person {}
class SigninPage {
@Inject
Person person;
}
If I try this in tapestry, I'm getting:
org.apache.tapestry5.runtime.ComponentEventException
Error obtaining injected value for field person: No service implements the
interface Person.
What do I have to change to use this kind of injection in T5?
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Inject-managed-beans-tp5717346.html
Sent from the Tapestry - User 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: Inject managed beans?
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Sun, 28 Oct 2012 11:06:23 -0200, membersound <me...@web.de> wrote:
> What is the T5 equivalent to the following JSF?
The closes thing to a JSF managed bean is page classes, but with the
requirement that every page class has exactly one template and vice-versa.
Don't try to learn Tapestry using JSF concepts: they're too different. For
example, the request scope in Tapestry doesn't exist because there's no
need for it: with a 1:1 relationship between page classes and templates
(also between components and templates), in a template, you always know
where the data comes from (the corresponding class).
--
Thiago H. de Paula Figueiredo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Inject managed beans?
Posted by membersound <me...@web.de>.
OK thanks I see.
Yes it was not a good example, probably I should rather be injecting a
service here.
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Inject-managed-beans-tp5717346p5717369.html
Sent from the Tapestry - User 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: Inject managed beans?
Posted by derkoe <ta...@gmail.com>.
membersound wrote
> What is the T5 equivalent to the following JSF?
>
> class Person {}
>
> class SigninPage {
> @Inject
> Person person;
> }
>
> If I try this in tapestry, I'm getting:
> org.apache.tapestry5.runtime.ComponentEventException
> Error obtaining injected value for field person: No service implements the
> interface Person.
>
> What do I have to change to use this kind of injection in T5?
You need to define Person as a service in your module:
public static void bind(ServiceBinder binder) {
binder.bind(Person.class);
}
But why do you want to define a value object (Person seems to be one) as a
service?
I think the better way is to just define it as a member of your page:
class SigninPage {
@Property
private Person person;
}
You find more about services and injection in the docs:
http://tapestry.apache.org/ioc-cookbook-basic-services-and-injection.html
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Inject-managed-beans-tp5717346p5717368.html
Sent from the Tapestry - User 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