You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Brown, Berlin [GCG-PFS]" <Be...@Primerica.com> on 2010/08/13 23:13:46 UTC

General question - business logic with Wicket, where to put it?

What is the best practice for where to put business logic in Wicket.
 
At first, I had put logic in the page constructor, but now I have
learned a little bit about the Lifecycle of a page, the serialization of
the page.  So putting any kind of logic there didn't seem like a good
idea.
 
I placed logic in the action buttons onSubmit methods and form onSubmit
methods.
 
Placing any logic here in the onSubmits methods are OK, but sometimes it
is difficult to find all the dependent objects.
 
I gues I am used to a Struts MVC approach, where you have one Page
action and then communicate with all of your dependent objects (say a
form bean with all of the data);
 
With Wicket, I see these issues:
 
1. When will the page constructor get invoked (should any kind of
business logic be placed here?)
2. Where and when will the onSubmit/onUpdate action methods get invoked
(should any business logic be placed here and are all the dependent
objects available)
 
Berlin Brown

Re: General question - business logic with Wicket, where to put it?

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
You can put your business logic "elsewhere".

Say:

1. Project Wicket GUI
2. Project Business Logic

Minimum business logic into wicket gui or gui constructors.

**
Martin

2010/8/14 Brown, Berlin [GCG-PFS] <Be...@primerica.com>:
> What is the best practice for where to put business logic in Wicket.
>
> At first, I had put logic in the page constructor, but now I have
> learned a little bit about the Lifecycle of a page, the serialization of
> the page.  So putting any kind of logic there didn't seem like a good
> idea.
>
> I placed logic in the action buttons onSubmit methods and form onSubmit
> methods.
>
> Placing any logic here in the onSubmits methods are OK, but sometimes it
> is difficult to find all the dependent objects.
>
> I gues I am used to a Struts MVC approach, where you have one Page
> action and then communicate with all of your dependent objects (say a
> form bean with all of the data);
>
> With Wicket, I see these issues:
>
> 1. When will the page constructor get invoked (should any kind of
> business logic be placed here?)
> 2. Where and when will the onSubmit/onUpdate action methods get invoked
> (should any business logic be placed here and are all the dependent
> objects available)
>
> Berlin Brown
>

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


Re: General question - business logic with Wicket, where to put it?

Posted by Patrick Petermair <pa...@openforce.com>.
Brown, Berlin [GCG-PFS] schrieb:
> What is the best practice for where to put business logic in Wicket.

I don't know if it is the best practice, but here is how we use it:

We have several projects / modules like

myApp-dao
myApp-service
myApp-wicket-ui

Our wicket app then depends on those projects, starts one big 
application context (Spring) with all the beans and just calls the 
needed methods on them. The Login page in wicket for example has a 
service bean that is responsible for authenticating the user. All we do 
in the form's onSubmit method is to call the authentication logic 
through its own bean and never care about the actual business logic 
behind it.

In a small project you don't have to split everything into multiple 
modules / projects, but you should at least move the logic out of the 
onSubmit etc. methods and just call methods on a seperate service class.

Patrick


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