Converting a Spring MVC application to Tapestry

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Converting a Spring MVC application to Tapestry

Nathan Lai
Hi All,
 
   A few weeks ago, I made a web mapping application with the Spring MVC
using the MultiActionController that comes with the framework. The
application features the following
 
    (1) A user is able to retrieve the map image of a feature (say a
garden) easily from the database by simply specifying the unique
identifier of that feature in the URL. For instance, he can simply enter
the URL
http://xxxx/imageservice/service.do?op=getImage&id=12345&sizeoption=1 in
the browser or embed it in the HTML as a link to retreive the image of
the feature with id 1234 from the database. The parameter 'sizeoption'
is optional.

    (2)  After retrieving the image, the user can navigation around the
feature, say zoomin, zoomout and pan using just simple URLs. For
instance , he can enter
http://xxxx/imageservice/service.do?op=zoomin&zoomfactor=2 in the
browser to get a more detailed map. He has no need to carry out any
relevant coordinate calculations. Moreover, the 'zoomfactor' parameter
is optional and defaults to the value of 1 if absent.

    (3) The controller at the backend would perform validation against
query parameters. For instance, it would check if the user wants to
perform a getImage operation but forgets to supply the feature id in the
request.

    Now, I'm thinking the possibility of porting the application to
Tapestry and wanting to know how hard it is. The following are my
initial thoughts and doubts:
 
    Initial thoughts :

    I think that DirectLink is the component to use to accomplish the
task. So, there should be different DirectLink listeners, say
doGetImage, doZoomIn, doZoomOut, doPan, etc in the page to act for
different  map actions. Moreover, a visit object should also be used in
order to track the user specific information such as the viewing extent
of the map and the id of the feature in which the user is interested.All
beans performing the mapping functions should be managed by Spring.
 
    Doubts:

    (1) Actually, is it the correct and best way to use DirectLink to do
the job?

    (2) If using DirectLink,  how could I get some of the service
parameters optional?

    (3) Moreover, how could I get those service parameters validated
before the listenters are called. What I want to do is to separate the
map operation logic and the validation logic. In Spring MVC, a means is
provided to automatically bind all request parameters to a bean
so-called an command object and then to pass the command object together
with a validator to the BindUtils.bindAndValidate(command,validator)
method to perform validation such that there is no validation code in my
controller. I like this feature as binding to command objects occurs
automatically and I can even specify different command objects and
validators for different operations, say ZoomCommand for the doZoom
method and PanCommand for the doPan method. But in Tapestry, since I'm
not using a form, I can't specify in a declarative manner validators for
the parmameters in the page, so how could I get those service parameters
validated? Is it possible to define something like an interceptor so
that it is called to do the validation before the listener is invoked?

   (4) Since the original application allows user to enter user friendly
URLs (as described above) directly into the browser to get things done,
and those URLs are so different from those recognized and generated by
Tapestry, I need to make an conversion between them.  I 'm thinking of
using the URL Rewriter to get it done. Is it a good idea?

   I'm quite new to Tapestry, so sorry for any silly questions asked.
I'm using Tapestry 3.0.3.

Nathan
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Converting a Spring MVC application to Tapestry

Erik Hatcher

On May 13, 2005, at 6:33 AM, Nathan Lai wrote:

> Hi All,
>    A few weeks ago, I made a web mapping application with the  
> Spring MVC using the MultiActionController that comes with the  
> framework. The application features the following
>    (1) A user is able to retrieve the map image of a feature (say a  
> garden) easily from the database by simply specifying the unique  
> identifier of that feature in the URL. For instance, he can simply  
> enter the URL http://xxxx/imageservice/service.do?
> op=getImage&id=12345&sizeoption=1 in the browser or embed it in the  
> HTML as a link to retreive the image of the feature with id 1234  
> from the database. The parameter 'sizeoption' is optional.
>
>    (2)  After retrieving the image, the user can navigation around  
> the feature, say zoomin, zoomout and pan using just simple URLs.  
> For instance , he can enter http://xxxx/imageservice/service.do?
> op=zoomin&zoomfactor=2 in the browser to get a more detailed map.  
> He has no need to carry out any relevant coordinate calculations.  
> Moreover, the 'zoomfactor' parameter is optional and defaults to  
> the value of 1 if absent.
>
>    (3) The controller at the backend would perform validation  
> against query parameters. For instance, it would check if the user  
> wants to perform a getImage operation but forgets to supply the  
> feature id in the request.
>
>    Now, I'm thinking the possibility of porting the application to  
> Tapestry and wanting to know how hard it is. The following are my  
> initial thoughts and doubts:
>     Initial thoughts :
>
>    I think that DirectLink is the component to use to accomplish  
> the task. So, there should be different DirectLink listeners, say  
> doGetImage, doZoomIn, doZoomOut, doPan, etc in the page to act for  
> different  map actions. Moreover, a visit object should also be  
> used in order to track the user specific information such as the  
> viewing extent of the map and the id of the feature in which the  
> user is interested.All beans performing the mapping functions  
> should be managed by Spring.
>    Doubts:
>
>    (1) Actually, is it the correct and best way to use DirectLink  
> to do the job?

I recommend using ExternalLink instead.  DirectLink is not suited for  
what you're after, in my opinion.

>   (4) Since the original application allows user to enter user  
> friendly URLs (as described above) directly into the browser to get  
> things done, and those URLs are so different from those recognized  
> and generated by Tapestry, I need to make an conversion between  
> them.  I 'm thinking of using the URL Rewriter to get it done. Is  
> it a good idea?

Yes, or a custom filter to do the mapping.  I'm a big proponent of  
that technique.

>   I'm quite new to Tapestry, so sorry for any silly questions  
> asked. I'm using Tapestry 3.0.3.

Not silly at all.  Hackable - meaning user manipulatable - URL's are  
important to many including myself.  Tapestry 3.0 requires ingenuity  
on top of it to get clean URL's.  Tapestry 4.0 has some facilities to  
make it better that I have not yet explored.

     Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]