You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Adam Henderson Azudio <az...@hotmail.com> on 2005/09/02 16:22:06 UTC

T4 DataSqueezer/SqueezeAdaptor, Spring & Hibernate

Hi,

I've written a SqueezeAdaptor for use with my Hibernate entities and  
it works well in T3.

My HibernateSqueezeAdaptor unsqueezes the string by decoding a entity  
type code along with the id, then it accesses my Spring appService  
bean and asks it to retrieve my entity.

I'm attempting to upgrade/convert to T4 and I'm a bit stumped as how  
to do the conversion.

How do I create and register a SqueezeAdaptor that uses a Spring  
service object, what do I put in my subclass of BaseEngine?, do I  
need to subclass BaseEngine? How do I inject my spring service into  
my adaptor? Do I need a hivemodule.xml? if so what do I put in it?

What would be the logical steps needed to implement this. Also is  
there any security issues with what I'm doing?

Many thanks

Adam.


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


PersistentPropertyDataEncoder

Posted by Borut Bolčina <bo...@najdi.si>.
Hi,

anyone willing to share code, hivemind entries on this subject?

Cheers,
Borut

On 24.4.2006 5:47, James Carman wrote:
> You can write your own PersistentPropertyDataEncoder and which uses the
> squeezers instead.  You'd have to override the implementation of the
> tapestry.persist.PersistentPropertyDataEncoder service using your custom
> class instead.  The ClientPropertyPersistenceStrategy class uses a
> PersistentPropertyDataEncoder to write out the property values.  I don't
> have time tonight to write it, but it doesn't appear to be that difficult.
>
>
> -----Original Message-----
> From: Jun Tsai [mailto:jun.tsai@gmail.com] 
> Sent: Sunday, April 23, 2006 11:34 PM
> To: Tapestry users
> Subject: Re: T4 DataSqueezer/SqueezeAdaptor, Spring & Hibernate
>
> 2006/4/24, James Carman <ja...@carmanconsulting.com>:
>   
>> There are multiple ways to use it.  You can have a DirectLink which uses
>> parameters to call a listener method (the parameters will be
>> squeezed).  You
>> can have a Hidden component in a form that has its value set to some
>> squeezable object.
>>
>>     
>
>
> I want to use it in <property ....>
>
> How to implement it?
>
> Thanks
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>   

-- 
bLOG <http://www.delo.si/blog/borutb/>
--
Naključna *izjava tedna* iz tednika Mladina:

RE: T4 DataSqueezer/SqueezeAdaptor, Spring & Hibernate

Posted by James Carman <ja...@carmanconsulting.com>.
You can write your own PersistentPropertyDataEncoder and which uses the
squeezers instead.  You'd have to override the implementation of the
tapestry.persist.PersistentPropertyDataEncoder service using your custom
class instead.  The ClientPropertyPersistenceStrategy class uses a
PersistentPropertyDataEncoder to write out the property values.  I don't
have time tonight to write it, but it doesn't appear to be that difficult.


-----Original Message-----
From: Jun Tsai [mailto:jun.tsai@gmail.com] 
Sent: Sunday, April 23, 2006 11:34 PM
To: Tapestry users
Subject: Re: T4 DataSqueezer/SqueezeAdaptor, Spring & Hibernate

2006/4/24, James Carman <ja...@carmanconsulting.com>:
>
> There are multiple ways to use it.  You can have a DirectLink which uses
> parameters to call a listener method (the parameters will be
> squeezed).  You
> can have a Hidden component in a form that has its value set to some
> squeezable object.
>


I want to use it in <property ....>

How to implement it?

Thanks



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: T4 DataSqueezer/SqueezeAdaptor, Spring & Hibernate

Posted by Jun Tsai <ju...@gmail.com>.
2006/4/24, James Carman <ja...@carmanconsulting.com>:
>
> There are multiple ways to use it.  You can have a DirectLink which uses
> parameters to call a listener method (the parameters will be
> squeezed).  You
> can have a Hidden component in a form that has its value set to some
> squeezable object.
>


I want to use it in <property ....>

How to implement it?

Thanks

RE: T4 DataSqueezer/SqueezeAdaptor, Spring & Hibernate

Posted by James Carman <ja...@carmanconsulting.com>.
There are multiple ways to use it.  You can have a DirectLink which uses
parameters to call a listener method (the parameters will be squeezed).  You
can have a Hidden component in a form that has its value set to some
squeezable object.

-----Original Message-----
From: Jun Tsai [mailto:jun.tsai@gmail.com] 
Sent: Sunday, April 23, 2006 11:03 PM
To: Tapestry users
Subject: Re: T4 DataSqueezer/SqueezeAdaptor, Spring & Hibernate

2006/4/24, James Carman <ja...@carmanconsulting.com>:
>
> The client persistence strategy doesn't use the "squeezers."



How to use it ?thanks.

Jun Tsai



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: T4 DataSqueezer/SqueezeAdaptor, Spring & Hibernate

Posted by Jun Tsai <ju...@gmail.com>.
2006/4/24, James Carman <ja...@carmanconsulting.com>:
>
> The client persistence strategy doesn't use the "squeezers."



How to use it ?thanks.

Jun Tsai

RE: T4 DataSqueezer/SqueezeAdaptor, Spring & Hibernate

Posted by James Carman <ja...@carmanconsulting.com>.
The client persistence strategy doesn't use the "squeezers." 

-----Original Message-----
From: Jun Tsai [mailto:jun.tsai@gmail.com] 
Sent: Sunday, April 23, 2006 10:56 PM
To: Tapestry users
Subject: Re: T4 DataSqueezer/SqueezeAdaptor, Spring & Hibernate

How to use MySqueezeAdaptor ?

<property name="xx" persist="client"/> ?


Jun Tsai

2005/9/8, Adam Henderson Azudio <az...@hotmail.com>:
>
> Adam,
>
> OK got it to work, the following is what I did along with a little
> bit of code.
>
> In hivemodule.xml:
>
>      <service-point id="MySqueezeAdaptor"
> interface="com.azudio.project1.MySqueezeAdaptor">
>          <invoke-factory>
>              <construct class="com.azudio.project1.MySqueezeAdaptor"/>
>              <set-object property="myService"
> value="spring:myService" />
>          </invoke-factory>
>      </service-point>
>
>      <contribution configuration-id="tapestry.data.SqueezeAdaptors">
>          <adaptor object="service:MySqueezeAdaptor" />
>      </contribution>
>
> The Adaptor class:
> *Note: This is not a complete implementation, ie: the adaptor isn't
> really useful but just demonstrates how to get a SqueezeAdaptor set
> up and registered, although it works, it squeezes a SomeBase instance
> and reconstitutes it later.
>
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> import org.apache.tapestry.services.DataSqueezer;
> import org.apache.tapestry.util.io.SqueezeAdaptor;
>
> public class MySqueezeAdaptor implements SqueezeAdaptor {
>
>      private static final Log log = LogFactory.getLog
> (MySqueezeAdaptor.class);
>
>      private MySpringBean _myService;
>
>      public MySpringBean getMyService(){
>          return _myService;
>      }
>      public void setMyService(MySpringBean myService){
>          _myService = myService;
>      }
>
>
>      private static final String PREFIX = "H";
>
>      public String getPrefix() {
>          return PREFIX;
>      }
>
>      public Class getDataClass() {
>          log.debug("Getting DataClass");
>          return  SomeBase.class;
>      }
>
>      public String squeeze(DataSqueezer datasqueezer, Object entity) {
>          log.debug("Squeezing Object");
>
>          // Will return something like: "H:XXX:1234"
>          return getPrefix() + ":" + "XXX:" + ((SomeBase)entity).getId();
>      }
>
>      public Object unsqueeze(DataSqueezer dataSqueezer, String
> stringRepresentation) {
>          log.debug("Unsqueezing Object");
>
>          String parts[] = stringRepresentation.split(":");
>
>          Long id = Long.parseLong(parts[2]);
>
>          log.debug("Id: " + id);
>
>          return getMyService().getSomeBase(id);
>      }
>
> }
>
> I'm assuming that the Spring context is all set up etc.
>
> Hope that helps.
>
> Adam.
>
> On 3 Sep 2005, at 01:14, Adam Greene wrote:
>
> > Ok, first thing right off.  You do not need to subclass
> > BaseEngine.  The steps are :
> >
> > 1. Your class implements org.apache.tapestry.services.DataSqueezer.
> > 2.  Setup your class as a service in hivemodule.xml:
> > 3.  Then contribute to the tapestry.data.SqueezeAdaptors
> > configuration point, put something like this in your hivemodule.xml:
> >
> > <contribution configuration-id="tapestry.data.SqueezeAdaptors">
> >    <adaptor object="service:YourAdaptor"/>
> > </contribution>
> >
> > if you look at tapestry-4.0.jar!/META-INF/tapestry-data.xml, you
> > will see how this all works.  The examples there are based on
> > "instance:" but you can use "service:"
> >
> > ----- Original Message ----- From: "Adam Henderson Azudio"
> > <az...@hotmail.com>
> > To: "Tapestry users" <ta...@jakarta.apache.org>
> > Sent: Friday, September 02, 2005 11:22 AM
> > Subject: T4 DataSqueezer/SqueezeAdaptor, Spring & Hibernate
> >
> >
> >
> >> Hi,
> >>
> >> I've written a SqueezeAdaptor for use with my Hibernate entities
> >> and  it works well in T3.
> >>
> >> My HibernateSqueezeAdaptor unsqueezes the string by decoding a
> >> entity type code along with the id, then it accesses my Spring
> >> appService  bean and asks it to retrieve my entity.
> >>
> >> I'm attempting to upgrade/convert to T4 and I'm a bit stumped as
> >> how  to do the conversion.
> >>
> >> How do I create and register a SqueezeAdaptor that uses a Spring
> >> service object, what do I put in my subclass of BaseEngine?, do I
> >> need to subclass BaseEngine? How do I inject my spring service
> >> into  my adaptor? Do I need a hivemodule.xml? if so what do I put
> >> in it?
> >>
> >> What would be the logical steps needed to implement this. Also is
> >> there any security issues with what I'm doing?
> >>
> >> Many thanks
> >>
> >> Adam.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: tapestry-user-
> >> help@jakarta.apache.org
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


--
Welcome to China Java Users Group(CNJUG).
http://cnjug.dev.java.net



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: T4 DataSqueezer/SqueezeAdaptor, Spring & Hibernate

Posted by Jun Tsai <ju...@gmail.com>.
How to use MySqueezeAdaptor ?

<property name="xx" persist="client"/> ?


Jun Tsai

2005/9/8, Adam Henderson Azudio <az...@hotmail.com>:
>
> Adam,
>
> OK got it to work, the following is what I did along with a little
> bit of code.
>
> In hivemodule.xml:
>
>      <service-point id="MySqueezeAdaptor"
> interface="com.azudio.project1.MySqueezeAdaptor">
>          <invoke-factory>
>              <construct class="com.azudio.project1.MySqueezeAdaptor"/>
>              <set-object property="myService"
> value="spring:myService" />
>          </invoke-factory>
>      </service-point>
>
>      <contribution configuration-id="tapestry.data.SqueezeAdaptors">
>          <adaptor object="service:MySqueezeAdaptor" />
>      </contribution>
>
> The Adaptor class:
> *Note: This is not a complete implementation, ie: the adaptor isn't
> really useful but just demonstrates how to get a SqueezeAdaptor set
> up and registered, although it works, it squeezes a SomeBase instance
> and reconstitutes it later.
>
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> import org.apache.tapestry.services.DataSqueezer;
> import org.apache.tapestry.util.io.SqueezeAdaptor;
>
> public class MySqueezeAdaptor implements SqueezeAdaptor {
>
>      private static final Log log = LogFactory.getLog
> (MySqueezeAdaptor.class);
>
>      private MySpringBean _myService;
>
>      public MySpringBean getMyService(){
>          return _myService;
>      }
>      public void setMyService(MySpringBean myService){
>          _myService = myService;
>      }
>
>
>      private static final String PREFIX = "H";
>
>      public String getPrefix() {
>          return PREFIX;
>      }
>
>      public Class getDataClass() {
>          log.debug("Getting DataClass");
>          return  SomeBase.class;
>      }
>
>      public String squeeze(DataSqueezer datasqueezer, Object entity) {
>          log.debug("Squeezing Object");
>
>          // Will return something like: "H:XXX:1234"
>          return getPrefix() + ":" + "XXX:" + ((SomeBase)entity).getId();
>      }
>
>      public Object unsqueeze(DataSqueezer dataSqueezer, String
> stringRepresentation) {
>          log.debug("Unsqueezing Object");
>
>          String parts[] = stringRepresentation.split(":");
>
>          Long id = Long.parseLong(parts[2]);
>
>          log.debug("Id: " + id);
>
>          return getMyService().getSomeBase(id);
>      }
>
> }
>
> I'm assuming that the Spring context is all set up etc.
>
> Hope that helps.
>
> Adam.
>
> On 3 Sep 2005, at 01:14, Adam Greene wrote:
>
> > Ok, first thing right off.  You do not need to subclass
> > BaseEngine.  The steps are :
> >
> > 1. Your class implements org.apache.tapestry.services.DataSqueezer.
> > 2.  Setup your class as a service in hivemodule.xml:
> > 3.  Then contribute to the tapestry.data.SqueezeAdaptors
> > configuration point, put something like this in your hivemodule.xml:
> >
> > <contribution configuration-id="tapestry.data.SqueezeAdaptors">
> >    <adaptor object="service:YourAdaptor"/>
> > </contribution>
> >
> > if you look at tapestry-4.0.jar!/META-INF/tapestry-data.xml, you
> > will see how this all works.  The examples there are based on
> > "instance:" but you can use "service:"
> >
> > ----- Original Message ----- From: "Adam Henderson Azudio"
> > <az...@hotmail.com>
> > To: "Tapestry users" <ta...@jakarta.apache.org>
> > Sent: Friday, September 02, 2005 11:22 AM
> > Subject: T4 DataSqueezer/SqueezeAdaptor, Spring & Hibernate
> >
> >
> >
> >> Hi,
> >>
> >> I've written a SqueezeAdaptor for use with my Hibernate entities
> >> and  it works well in T3.
> >>
> >> My HibernateSqueezeAdaptor unsqueezes the string by decoding a
> >> entity type code along with the id, then it accesses my Spring
> >> appService  bean and asks it to retrieve my entity.
> >>
> >> I'm attempting to upgrade/convert to T4 and I'm a bit stumped as
> >> how  to do the conversion.
> >>
> >> How do I create and register a SqueezeAdaptor that uses a Spring
> >> service object, what do I put in my subclass of BaseEngine?, do I
> >> need to subclass BaseEngine? How do I inject my spring service
> >> into  my adaptor? Do I need a hivemodule.xml? if so what do I put
> >> in it?
> >>
> >> What would be the logical steps needed to implement this. Also is
> >> there any security issues with what I'm doing?
> >>
> >> Many thanks
> >>
> >> Adam.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: tapestry-user-
> >> help@jakarta.apache.org
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>


--
Welcome to China Java Users Group(CNJUG).
http://cnjug.dev.java.net

Re: T4 DataSqueezer/SqueezeAdaptor, Spring & Hibernate

Posted by Adam Henderson Azudio <az...@hotmail.com>.
Adam,

OK got it to work, the following is what I did along with a little  
bit of code.

In hivemodule.xml:

     <service-point id="MySqueezeAdaptor"  
interface="com.azudio.project1.MySqueezeAdaptor">
         <invoke-factory>
             <construct class="com.azudio.project1.MySqueezeAdaptor"/>
             <set-object property="myService"  
value="spring:myService" />
         </invoke-factory>
     </service-point>

     <contribution configuration-id="tapestry.data.SqueezeAdaptors">
         <adaptor object="service:MySqueezeAdaptor" />
     </contribution>

The Adaptor class:
*Note: This is not a complete implementation, ie: the adaptor isn't  
really useful but just demonstrates how to get a SqueezeAdaptor set  
up and registered, although it works, it squeezes a SomeBase instance  
and reconstitutes it later.

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tapestry.services.DataSqueezer;
import org.apache.tapestry.util.io.SqueezeAdaptor;

public class MySqueezeAdaptor implements SqueezeAdaptor {

     private static final Log log = LogFactory.getLog 
(MySqueezeAdaptor.class);

     private MySpringBean _myService;

     public MySpringBean getMyService(){
         return _myService;
     }
     public void setMyService(MySpringBean myService){
         _myService = myService;
     }


     private static final String PREFIX = "H";

     public String getPrefix() {
         return PREFIX;
     }

     public Class getDataClass() {
         log.debug("Getting DataClass");
         return  SomeBase.class;
     }

     public String squeeze(DataSqueezer datasqueezer, Object entity) {
         log.debug("Squeezing Object");

         // Will return something like: "H:XXX:1234"
         return getPrefix() + ":" + "XXX:" + ((SomeBase)entity).getId();
     }

     public Object unsqueeze(DataSqueezer dataSqueezer, String  
stringRepresentation) {
         log.debug("Unsqueezing Object");

         String parts[] = stringRepresentation.split(":");

         Long id = Long.parseLong(parts[2]);

         log.debug("Id: " + id);

         return getMyService().getSomeBase(id);
     }

}

I'm assuming that the Spring context is all set up etc.

Hope that helps.

Adam.

On 3 Sep 2005, at 01:14, Adam Greene wrote:

> Ok, first thing right off.  You do not need to subclass  
> BaseEngine.  The steps are :
>
> 1. Your class implements org.apache.tapestry.services.DataSqueezer.
> 2.  Setup your class as a service in hivemodule.xml:
> 3.  Then contribute to the tapestry.data.SqueezeAdaptors  
> configuration point, put something like this in your hivemodule.xml:
>
> <contribution configuration-id="tapestry.data.SqueezeAdaptors">
>    <adaptor object="service:YourAdaptor"/>
> </contribution>
>
> if you look at tapestry-4.0.jar!/META-INF/tapestry-data.xml, you  
> will see how this all works.  The examples there are based on  
> "instance:" but you can use "service:"
>
> ----- Original Message ----- From: "Adam Henderson Azudio"  
> <az...@hotmail.com>
> To: "Tapestry users" <ta...@jakarta.apache.org>
> Sent: Friday, September 02, 2005 11:22 AM
> Subject: T4 DataSqueezer/SqueezeAdaptor, Spring & Hibernate
>
>
>
>> Hi,
>>
>> I've written a SqueezeAdaptor for use with my Hibernate entities  
>> and  it works well in T3.
>>
>> My HibernateSqueezeAdaptor unsqueezes the string by decoding a  
>> entity type code along with the id, then it accesses my Spring  
>> appService  bean and asks it to retrieve my entity.
>>
>> I'm attempting to upgrade/convert to T4 and I'm a bit stumped as  
>> how  to do the conversion.
>>
>> How do I create and register a SqueezeAdaptor that uses a Spring   
>> service object, what do I put in my subclass of BaseEngine?, do I   
>> need to subclass BaseEngine? How do I inject my spring service  
>> into  my adaptor? Do I need a hivemodule.xml? if so what do I put  
>> in it?
>>
>> What would be the logical steps needed to implement this. Also is   
>> there any security issues with what I'm doing?
>>
>> Many thanks
>>
>> Adam.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user- 
>> help@jakarta.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: T4 DataSqueezer/SqueezeAdaptor, Spring & Hibernate

Posted by Adam Greene <ag...@iq-2000.com>.
Ok, first thing right off.  You do not need to subclass BaseEngine.  The 
steps are :

1. Your class implements org.apache.tapestry.services.DataSqueezer.
2.  Setup your class as a service in hivemodule.xml:
3.  Then contribute to the tapestry.data.SqueezeAdaptors configuration 
point, put something like this in your hivemodule.xml:

<contribution configuration-id="tapestry.data.SqueezeAdaptors">
    <adaptor object="service:YourAdaptor"/>
</contribution>

if you look at tapestry-4.0.jar!/META-INF/tapestry-data.xml, you will see 
how this all works.  The examples there are based on "instance:" but you can 
use "service:"

----- Original Message ----- 
From: "Adam Henderson Azudio" <az...@hotmail.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Friday, September 02, 2005 11:22 AM
Subject: T4 DataSqueezer/SqueezeAdaptor, Spring & Hibernate


> Hi,
>
> I've written a SqueezeAdaptor for use with my Hibernate entities and  it 
> works well in T3.
>
> My HibernateSqueezeAdaptor unsqueezes the string by decoding a entity 
> type code along with the id, then it accesses my Spring appService  bean 
> and asks it to retrieve my entity.
>
> I'm attempting to upgrade/convert to T4 and I'm a bit stumped as how  to 
> do the conversion.
>
> How do I create and register a SqueezeAdaptor that uses a Spring  service 
> object, what do I put in my subclass of BaseEngine?, do I  need to 
> subclass BaseEngine? How do I inject my spring service into  my adaptor? 
> Do I need a hivemodule.xml? if so what do I put in it?
>
> What would be the logical steps needed to implement this. Also is  there 
> any security issues with what I'm doing?
>
> Many thanks
>
> Adam.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org