Bringing a simple application over to Tapestry 4.0

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

Bringing a simple application over to Tapestry 4.0

richard.hensley
AbstractService went away. So, I had to gut and rewrite my service
        - had to remove service from .application
        - had to create a hivemodule.xml in the WEB-INF folder

IComponent.getMessage() went away. So, I had replace with
IComponent.getMessages().getMessage(). I got bit by this twice, once in code
and once in an ognl express container.getMessage(label + 'Label') which had
to be updated to container.getMessages().getMessage(label + 'Label')

I had used a different servlet name than /app, so I had to set a tapestry
application configuration.

In order to use my hivemind services, I had to convert to the 4.0 dtd
because the hivemind registry is no longer available to my pages through the
Hivemind Servlet. I happen to use service proxy serialization, so I can have
only one registry.

Because I converted to the 4.0 dtd's I got to remove a bunch of stuff from
my .page file, then I got to put some of it back because I did not have any
abstract methods for my template only references. These were things like
Foreach value targets.

The things that took me the longest time to figure out where the servlet
name thing, and how to get parameters working with my service. I'm still not
sure I've got the parameter thing right.

Next, I'm going to add friendly URL's to my app, weee!

Richard


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

Reply | Threaded
Open this post in threaded view
|

RE: Bringing a simple application over to Tapestry 4.0

richard.hensley
Ok, I was right, my parameter processing in my service is still not right,
cursed that AbstractService went away, because it handled all of this for
me.

This is how I'm constructing a link, this is basically a direct copy from
AssetService, except my parameter is an Object[] with a single serializable
object in the list.

    public ILink getLink(IRequestCycle cycle, Object parameter) {
        Map parameters = new HashMap();
        parameters.put(ServiceConstants.SERVICE, getName());
        parameters.put(ServiceConstants.PARAMETER, parameter);
        /*
         * Service is always stateless
         */
        return this.linkFactory.constructLink(cycle, parameters, false);
        }

My parameter is a serializable object, so it is running through the
squeezer.

So, my next question is how do I get it back?

Do I have to get the string of the parameter using:

cycle.getParameter(ServiceConstants.PARAMETER)
and then unsqueeze it myself?

It seems that the squeezing was handled on the way out to the browser, but
not on the way back in from the browser. This makes constructing a service
kind-of difficult to follow.

Richard

-----Original Message-----
From: Hensley, Richard [mailto:[hidden email]]
Sent: Thursday, May 12, 2005 3:58 PM
To: Tapestry development
Subject: Bringing a simple application over to Tapestry 4.0

AbstractService went away. So, I had to gut and rewrite my service
        - had to remove service from .application
        - had to create a hivemodule.xml in the WEB-INF folder

IComponent.getMessage() went away. So, I had replace with
IComponent.getMessages().getMessage(). I got bit by this twice, once in code
and once in an ognl express container.getMessage(label + 'Label') which had
to be updated to container.getMessages().getMessage(label + 'Label')

I had used a different servlet name than /app, so I had to set a tapestry
application configuration.

In order to use my hivemind services, I had to convert to the 4.0 dtd
because the hivemind registry is no longer available to my pages through the
Hivemind Servlet. I happen to use service proxy serialization, so I can have
only one registry.

Because I converted to the 4.0 dtd's I got to remove a bunch of stuff from
my .page file, then I got to put some of it back because I did not have any
abstract methods for my template only references. These were things like
Foreach value targets.

The things that took me the longest time to figure out where the servlet
name thing, and how to get parameters working with my service. I'm still not
sure I've got the parameter thing right.

Next, I'm going to add friendly URL's to my app, weee!

Richard


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


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

Reply | Threaded
Open this post in threaded view
|

RE: Bringing a simple application over to Tapestry 4.0

richard.hensley
In reply to this post by richard.hensley
Ok, I figured it out, the service has to make the choice of squeezing or
not, and then implement it. Turned out to be pretty easy once I figured it
out.

Another thing I did was avoid the standard ServiceConstants.PARAMETER so I
had full control over my names and processing.

Richard

-----Original Message-----
From: Hensley, Richard [mailto:[hidden email]]
Sent: Thursday, May 12, 2005 4:14 PM
To: Tapestry development
Subject: RE: Bringing a simple application over to Tapestry 4.0

Ok, I was right, my parameter processing in my service is still not right,
cursed that AbstractService went away, because it handled all of this for
me.

This is how I'm constructing a link, this is basically a direct copy from
AssetService, except my parameter is an Object[] with a single serializable
object in the list.

    public ILink getLink(IRequestCycle cycle, Object parameter) {
        Map parameters = new HashMap();
        parameters.put(ServiceConstants.SERVICE, getName());
        parameters.put(ServiceConstants.PARAMETER, parameter);
        /*
         * Service is always stateless
         */
        return this.linkFactory.constructLink(cycle, parameters, false);
        }

My parameter is a serializable object, so it is running through the
squeezer.

So, my next question is how do I get it back?

Do I have to get the string of the parameter using:

cycle.getParameter(ServiceConstants.PARAMETER)
and then unsqueeze it myself?

It seems that the squeezing was handled on the way out to the browser, but
not on the way back in from the browser. This makes constructing a service
kind-of difficult to follow.

Richard

-----Original Message-----
From: Hensley, Richard [mailto:[hidden email]]
Sent: Thursday, May 12, 2005 3:58 PM
To: Tapestry development
Subject: Bringing a simple application over to Tapestry 4.0

AbstractService went away. So, I had to gut and rewrite my service
        - had to remove service from .application
        - had to create a hivemodule.xml in the WEB-INF folder

IComponent.getMessage() went away. So, I had replace with
IComponent.getMessages().getMessage(). I got bit by this twice, once in code
and once in an ognl express container.getMessage(label + 'Label') which had
to be updated to container.getMessages().getMessage(label + 'Label')

I had used a different servlet name than /app, so I had to set a tapestry
application configuration.

In order to use my hivemind services, I had to convert to the 4.0 dtd
because the hivemind registry is no longer available to my pages through the
Hivemind Servlet. I happen to use service proxy serialization, so I can have
only one registry.

Because I converted to the 4.0 dtd's I got to remove a bunch of stuff from
my .page file, then I got to put some of it back because I did not have any
abstract methods for my template only references. These were things like
Foreach value targets.

The things that took me the longest time to figure out where the servlet
name thing, and how to get parameters working with my service. I'm still not
sure I've got the parameter thing right.

Next, I'm going to add friendly URL's to my app, weee!

Richard


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


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


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

Reply | Threaded
Open this post in threaded view
|

Re: Bringing a simple application over to Tapestry 4.0

Erik Hatcher
In reply to this post by richard.hensley

On May 12, 2005, at 7:13 PM, Hensley, Richard wrote:

> This is how I'm constructing a link, this is basically a direct  
> copy from
> AssetService, except my parameter is an Object[] with a single  
> serializable
> object in the list.
>
>     public ILink getLink(IRequestCycle cycle, Object parameter) {
>         Map parameters = new HashMap();
>         parameters.put(ServiceConstants.SERVICE, getName());
>         parameters.put(ServiceConstants.PARAMETER, parameter);
>         /*
>          * Service is always stateless
>          */
>         return this.linkFactory.constructLink(cycle, parameters,  
> false);
>         }
>
> My parameter is a serializable object, so it is running through the
> squeezer.
>
> So, my next question is how do I get it back?
>
> Do I have to get the string of the parameter using:
>
> cycle.getParameter(ServiceConstants.PARAMETER)
> and then unsqueeze it myself?
>
> It seems that the squeezing was handled on the way out to the  
> browser, but
> not on the way back in from the browser. This makes constructing a  
> service
> kind-of difficult to follow.

My custom ParamService is squeezing and unsqueezing the data itself.  
In the service() method I have this:

     List parameterNames = request.getParameterNames();
     HashMap map = new HashMap();
     for (int i=0; i < parameterNames.size(); i++) {
       String name = (String) parameterNames.get(i);
       map.put(name, dataSqueezer.unsqueeze(request.getParameterValue
(name)));
     }

And in getLink() I have this:

     Map map = (Map) dsp.getServiceParameters()[0];
     Set set = map.keySet();
     for (Iterator iter = set.iterator(); iter.hasNext();) {
       String name = (String) iter.next();
       try {
         parameters.put(name, dataSqueezer.squeeze(map.get(name)));
       } catch (IOException e) {
         throw new ApplicationRuntimeException(e);
       }
     }

DataSqueezer is injected via HiveMind:

   public void setDataSqueezer(DataSqueezer dataSqueezer) {
     this.dataSqueezer = dataSqueezer;
   }

and my hivemodule.xml has this:

   <service-point id="Param"  
interface="org.apache.tapestry.engine.IEngineService">
     <invoke-factory model="primitive">
       <construct class="ParamService">
         <set-object property="responseRenderer"  
value="infrastructure:responseRenderer"/>
         <set-object property="linkFactory"  
value="infrastructure:linkFactory"/>
         <set-object property="request" value="infrastructure:request"/>
         <set-object property="pageService"  
value="service:tapestry.services.Page"/>
         <set-object property="dataSqueezer"  
value="service:tapestry.data.DataSqueezer"/>
       </construct>
     </invoke-factory>
   </service-point>

I cloned what I did from the other services out there.

     Erik




>
> Richard
>
> -----Original Message-----
> From: Hensley, Richard [mailto:[hidden email]]
> Sent: Thursday, May 12, 2005 3:58 PM
> To: Tapestry development
> Subject: Bringing a simple application over to Tapestry 4.0
>
> AbstractService went away. So, I had to gut and rewrite my service
>     - had to remove service from .application
>     - had to create a hivemodule.xml in the WEB-INF folder
>
> IComponent.getMessage() went away. So, I had replace with
> IComponent.getMessages().getMessage(). I got bit by this twice,  
> once in code
> and once in an ognl express container.getMessage(label + 'Label')  
> which had
> to be updated to container.getMessages().getMessage(label + 'Label')
>
> I had used a different servlet name than /app, so I had to set a  
> tapestry
> application configuration.
>
> In order to use my hivemind services, I had to convert to the 4.0 dtd
> because the hivemind registry is no longer available to my pages  
> through the
> Hivemind Servlet. I happen to use service proxy serialization, so I  
> can have
> only one registry.
>
> Because I converted to the 4.0 dtd's I got to remove a bunch of  
> stuff from
> my .page file, then I got to put some of it back because I did not  
> have any
> abstract methods for my template only references. These were things  
> like
> Foreach value targets.
>
> The things that took me the longest time to figure out where the  
> servlet
> name thing, and how to get parameters working with my service. I'm  
> still not
> sure I've got the parameter thing right.
>
> Next, I'm going to add friendly URL's to my app, weee!
>
> Richard
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


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