[T5] Instantiate Interfaces

2008-06-27 Thread Kheldar666

Hello,

When i use Tapestry, almost my Bean are Interfaces (ex : UserImpl implements
User ). That causes me a problem sometimes, specially when using
BeanEditForm (ex : with @Parameter private User _user ). 

When I submit the form after editing a User, I have this error :

Exception instantiating instance of org.libermundi.User (for component
'Index:beaneditform.editor'): Class org.libermundi.User does not contain a
public constructor needed to autobuild.

This is normal ! User is a interface...

So, how do I tell Tapestry how to instantiate such objects ?

I tried with Alias... doesn't work at all. The only way I could make this
work is when the User is an ApplicationStateObject because I contribute to
the ApplicationStateManager.

Any idea ? Am I wrong when trying to make everything an Interface ? 

Thanks for your answers.

Regards,

Martin
-- 
View this message in context: 
http://www.nabble.com/-T5--Instantiate-%22Interfaces%22-tp18153603p18153603.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [T5] Instantiate Interfaces

2008-06-27 Thread Sven Homburg
a possible solution is:
add to your application module class

public static void bind(ServiceBinder binder)
{
binder.bind(User.class, UserImpl.class);
}

2008/6/27 Kheldar666 [EMAIL PROTECTED]:


 Hello,

 When i use Tapestry, almost my Bean are Interfaces (ex : UserImpl
 implements
 User ). That causes me a problem sometimes, specially when using
 BeanEditForm (ex : with @Parameter private User _user ).

 When I submit the form after editing a User, I have this error :

 Exception instantiating instance of org.libermundi.User (for component
 'Index:beaneditform.editor'): Class org.libermundi.User does not contain a
 public constructor needed to autobuild.

 This is normal ! User is a interface...

 So, how do I tell Tapestry how to instantiate such objects ?

 I tried with Alias... doesn't work at all. The only way I could make this
 work is when the User is an ApplicationStateObject because I contribute to
 the ApplicationStateManager.

 Any idea ? Am I wrong when trying to make everything an Interface ?

 Thanks for your answers.

 Regards,

 Martin
 --
 View this message in context:
 http://www.nabble.com/-T5--Instantiate-%22Interfaces%22-tp18153603p18153603.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




-- 
with regards
Sven Homburg
http://tapestry5-components.googlecode.com
http://chenillekit.googlecode.com


Re: [T5] Instantiate Interfaces

2008-06-27 Thread Howard Lewis Ship
There currently isn't a *global* mechanism to map an interface to a
class so that BeanEditForm can instantiate it for you.

Instead, you can add an event handler to your page for the prepare
event.  This method is responsible for preparing the page for either
rendering a form, or submitting a form.  You can add code to
instantiate the UserImpl object there.

Sven's option looks wrong; that's how you define a service, which is
orthogonal to your problem.

On Fri, Jun 27, 2008 at 4:58 AM, Kheldar666 [EMAIL PROTECTED] wrote:

 Hello,

 When i use Tapestry, almost my Bean are Interfaces (ex : UserImpl implements
 User ). That causes me a problem sometimes, specially when using
 BeanEditForm (ex : with @Parameter private User _user ).

 When I submit the form after editing a User, I have this error :

 Exception instantiating instance of org.libermundi.User (for component
 'Index:beaneditform.editor'): Class org.libermundi.User does not contain a
 public constructor needed to autobuild.

 This is normal ! User is a interface...

 So, how do I tell Tapestry how to instantiate such objects ?

 I tried with Alias... doesn't work at all. The only way I could make this
 work is when the User is an ApplicationStateObject because I contribute to
 the ApplicationStateManager.

 Any idea ? Am I wrong when trying to make everything an Interface ?

 Thanks for your answers.

 Regards,

 Martin
 --
 View this message in context: 
 http://www.nabble.com/-T5--Instantiate-%22Interfaces%22-tp18153603p18153603.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [T5] Instantiate Interfaces

2008-06-27 Thread Kheldar666

Yes, I know how to instantiate an Object in a onSetupRender phase for
instance.

But in the case of the BeanEditForm, the problem occurs when submitting.
Maybe the BeanEditForm, on Submit, tries to create a new User before copying
all datas from the Form to the user's properties ?

So I think I don't really have a place to instantiate anything on my own (or
I humbly recognized that I really don't know how to do that... ). I tried to
use the @Persist on the property but it doesn't help :(. 

The thing is that the exact same code with a @ApplicationState instead of
the @Persist works perfectly (if User is declared in the
ApplicationStateManager), but this is not clean in terms of memory usage...

Not sure to be clear, but I hope to find a solution



Howard Lewis Ship wrote:
 
 There currently isn't a *global* mechanism to map an interface to a
 class so that BeanEditForm can instantiate it for you.
 
 Instead, you can add an event handler to your page for the prepare
 event.  This method is responsible for preparing the page for either
 rendering a form, or submitting a form.  You can add code to
 instantiate the UserImpl object there.
 
 Sven's option looks wrong; that's how you define a service, which is
 orthogonal to your problem.
 
 -- 
 Howard M. Lewis Ship
 
 Creator Apache Tapestry and Apache HiveMind
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/-T5--Instantiate-%22Interfaces%22-tp18153603p18157112.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [T5] Instantiate Interfaces

2008-06-27 Thread Howard Lewis Ship
void onPrepare() { user = new UserImpl(); }

On Fri, Jun 27, 2008 at 8:02 AM, Kheldar666 [EMAIL PROTECTED] wrote:

 Yes, I know how to instantiate an Object in a onSetupRender phase for
 instance.

 But in the case of the BeanEditForm, the problem occurs when submitting.
 Maybe the BeanEditForm, on Submit, tries to create a new User before copying
 all datas from the Form to the user's properties ?

 So I think I don't really have a place to instantiate anything on my own (or
 I humbly recognized that I really don't know how to do that... ). I tried to
 use the @Persist on the property but it doesn't help :(.

 The thing is that the exact same code with a @ApplicationState instead of
 the @Persist works perfectly (if User is declared in the
 ApplicationStateManager), but this is not clean in terms of memory usage...

 Not sure to be clear, but I hope to find a solution



 Howard Lewis Ship wrote:

 There currently isn't a *global* mechanism to map an interface to a
 class so that BeanEditForm can instantiate it for you.

 Instead, you can add an event handler to your page for the prepare
 event.  This method is responsible for preparing the page for either
 rendering a form, or submitting a form.  You can add code to
 instantiate the UserImpl object there.

 Sven's option looks wrong; that's how you define a service, which is
 orthogonal to your problem.

 --
 Howard M. Lewis Ship

 Creator Apache Tapestry and Apache HiveMind

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




 --
 View this message in context: 
 http://www.nabble.com/-T5--Instantiate-%22Interfaces%22-tp18153603p18157112.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [T5] Instantiate Interfaces

2008-06-27 Thread Martin Papy

In fact I think I am confronted with two different issues :

1 - @Persist behavior

When I use a @Persist, I am aware that the object will only be kept in
'memory' between two request on the same page / component. So in my head I
thought that it was always the same object (the same instance of the object)
used by the BeanEditForm all along the process :

 Display Page A - Submit Form in page A - Display Page A again

- Same instance of my User object because of the @Persist - ==
Wrong ! (at least inside the BeanEditForm)

2 - Mecanism of the BeanEditForm : It recreate an entire object when I
submit the form. That is why it work with the ASO. Because it is always the
same instance of the object that is updated. In fact when using the @Persist
it does not have any effects on the BeanEditForm. 

So... would not it be possible to make the @Persist work the same way that
ASO in this particular case ? It would be very usefull. Hibernate object
manipulation/update would be very easy and powerfull.

Ex : 

1 - Get my User from Hibernate
2 - Pass it to the BeanEditForm
3 - Update the date directly in the bean (because the @Persist would allow
to do so )
4 - use onSuccess to do a Merge and a Commit :)

What is your opinion about that ?

Regards,

Martin

-- 
View this message in context: 
http://www.nabble.com/-T5--Instantiate-%22Interfaces%22-tp18153603p18158657.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]