You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by anyz <an...@gmail.com> on 2009/10/29 12:21:25 UTC

Preparing Data for Tiles when used with Spring

When using with Spring 2.5, What is best way to prepare data for Tiles.

1- Prepare data in Spring controller or set the delegator property with
methodNameResolver for controller and put data fetch logic in it.

2- After some validation etc controler can throw ModeView to render tiles.
Tiles preparer class can then fetch required data for it from DB.

What can be pros and cons of two apparoaches or any other better alternate.

thanks

Re: Preparing Data for Tiles when used with Spring

Posted by anyz <an...@gmail.com>.
Right. I think i will wait a bit as we are in phase of requirement
gathering. After we have finalized i will review where to prepare data.
Anyhow guidelines you mentioned can be used as rule of thumb in mos cases.
Thanks.



On Thu, Oct 29, 2009 at 4:42 PM, Antonio Petrelli <
antonio.petrelli@gmail.com> wrote:

> 2009/10/29 anyz <an...@gmail.com>:
> > Thanks a lot. Your comments are very helpful. I believe with view data
> you
> > mean that is kind of static data not tied to business logic. For example
> > menus soemtime are dependent on Roles  and/or business rules. In that
> case
> > menus should also be loaded from controller. Is it correct?
>
> In fact I believe that menus are *always* view data. Even if they are
> dependent on business rules, they should loaded where they belong as
> they do not make sense in other parts of the page.
> Obviously IMHO. Ask your project leader (if you're not him/her :-D )
> because this is an interesting point of discussion.
>
> Antonio
>

Re: Preparing Data for Tiles when used with Spring

Posted by Rick Mangi <Ri...@nick.com>.
I think the key is to have your data access tier modular enough so that it
can be used in both the controller and the view-preparer. There are valid
use cases for both. The best solution usually depends on the way your site
is constructed. 

If it is content-centric usually your controller fetches the data and then
view preparers transform the parts of the data they are interested in to the
appropriate format for the view.

If you are using tiles to provide reusable modules for things that are
dependent on the main content of the page in which they sit to provide some
id or key that they need to look up their data, then the view preparer is a
good place to do the data access for that part of the page.

On many of our sites we hit multiple data sources to create a page. The main
data access occurs in the page controller and then view preparers are used
to transform the data as needed for the main section of the page and also to
fetch other related data for things like ad and reporting calls, associated
content and site headers/footers.
 
Rick



On 10/29/09 7:42 AM, "Antonio Petrelli" <an...@gmail.com> wrote:

> 2009/10/29 anyz <an...@gmail.com>:
>> Thanks a lot. Your comments are very helpful. I believe with view data you
>> mean that is kind of static data not tied to business logic. For example
>> menus soemtime are dependent on Roles  and/or business rules. In that case
>> menus should also be loaded from controller. Is it correct?
> 
> In fact I believe that menus are *always* view data. Even if they are
> dependent on business rules, they should loaded where they belong as
> they do not make sense in other parts of the page.
> Obviously IMHO. Ask your project leader (if you're not him/her :-D )
> because this is an interesting point of discussion.
> 
> Antonio


Re: Preparing Data for Tiles when used with Spring

Posted by Antonio Petrelli <an...@gmail.com>.
2009/10/29 anyz <an...@gmail.com>:
> Thanks a lot. Your comments are very helpful. I believe with view data you
> mean that is kind of static data not tied to business logic. For example
> menus soemtime are dependent on Roles  and/or business rules. In that case
> menus should also be loaded from controller. Is it correct?

In fact I believe that menus are *always* view data. Even if they are
dependent on business rules, they should loaded where they belong as
they do not make sense in other parts of the page.
Obviously IMHO. Ask your project leader (if you're not him/her :-D )
because this is an interesting point of discussion.

Antonio

Re: Preparing Data for Tiles when used with Spring

Posted by anyz <an...@gmail.com>.
Thanks a lot. Your comments are very helpful. I believe with view data you
mean that is kind of static data not tied to business logic. For example
menus soemtime are dependent on Roles  and/or business rules. In that case
menus should also be loaded from controller. Is it correct?




On Thu, Oct 29, 2009 at 4:28 PM, Antonio Petrelli <
antonio.petrelli@gmail.com> wrote:

> 2009/10/29 anyz <an...@gmail.com>:
>  > When using with Spring 2.5, What is best way to prepare data for Tiles.
> >
> > 1- Prepare data in Spring controller or set the delegator property with
> > methodNameResolver for controller and put data fetch logic in it.
> >
> > 2- After some validation etc controler can throw ModeView to render
> tiles.
> > Tiles preparer class can then fetch required data for it from DB.
> >
> > What can be pros and cons of two apparoaches or any other better
> alternate.
>
>
> This question can be generalized to non Spring applications too: is it
> better to load data from C part of an MVC application, or from the
> preparer?
>
> Using a preparer you have a modular dependency between data used in a
> portion of the page and the portion itself. However, using a
> controller you have a centralized point where you load all the
> necessary data to render the page correctly.
> IMHO a mixed approach is better:
>
> If it is business data, then it is better to load it from the controller.
> If it is view data (for example a menu, a list of link etc.) then
> probably it is better to load it in a preparer.
>
> Antonio
>

Re: Preparing Data for Tiles when used with Spring

Posted by Antonio Petrelli <an...@gmail.com>.
2009/10/29 anyz <an...@gmail.com>:
> When using with Spring 2.5, What is best way to prepare data for Tiles.
>
> 1- Prepare data in Spring controller or set the delegator property with
> methodNameResolver for controller and put data fetch logic in it.
>
> 2- After some validation etc controler can throw ModeView to render tiles.
> Tiles preparer class can then fetch required data for it from DB.
>
> What can be pros and cons of two apparoaches or any other better alternate.


This question can be generalized to non Spring applications too: is it
better to load data from C part of an MVC application, or from the
preparer?

Using a preparer you have a modular dependency between data used in a
portion of the page and the portion itself. However, using a
controller you have a centralized point where you load all the
necessary data to render the page correctly.
IMHO a mixed approach is better:

If it is business data, then it is better to load it from the controller.
If it is view data (for example a menu, a list of link etc.) then
probably it is better to load it in a preparer.

Antonio