Oh that sounds pretty nice. Haven't realized that its possible that
way.. hehe..and its not nasty at all :)
I'll give it a try. Thanks!

And a second question that comes to my mind:
When using RequestFactory our domain objects are only defined by
interfaces. Is there a class in the framework that posts some sort of
PropertyChangeEvent on the provided EventBus whenever a property is
changed on client-side (This event should be fired whenever a setter
method is called on client side). If not is there a way to integrate
such a feature?
I asks this because currently we have an own simple binding system
which synchronizes UI and domain objects using PropertyChangeEvents
fired by the domain object. Of cause we could use the new Editor
Framework but it would be nice to do a step by step transition.




On 6 Nov., 21:35, Thomas Broyer <[email protected]> wrote:
> On 6 nov, 19:26, Jack <[email protected]> wrote:
>
>
>
>
>
> > Hi,
>
> > we would like to integrate GWT 2.1 RequestFactory in our application.
> > Our application's backend uses JPA and has one database per customer.
> > So we have to tell our EntityManagerFactory which database it should
> > use, depending on the customer who did the server request.
> > Currently we havehttp://our-app.com/<unique-customername> as
> > application URL and we send <unique-customername> to our backend on
> > each request. That way we can construct an EntityManagerFactory with a
> > custom properties map which contains a datasource name similar to
> > "appdatasource-<unique-customername>". So every time we got a new
> > customer, we just have to add a new JDBC resource and connection pool
> > which points to the new customers database to our J2EE server.
>
> > So we tried this approach with RequestFactory and defined our service
> > interface like this:
>
> > @Service(Person.class)
> > public interface PersonRequest extends RequestContext {
>
> >   Request<List<PersonProxy>> findAllPersons(String
> > uniqueCustomerName);
>
> >   Request<List<PersonProxy>> findPersonsByAge(int min, int max, String
> > uniqueCustomerName);
>
> >   InstanceRequest<PersonProxy, Void> persist(String
> > uniqueCustomerName);
>
> >   InstanceRequest<PersonProxy, Void> remove(String
> > uniqueCustomerName);
>
> >   Request<PersonProxy> findPerson(Long id);
>
> > }
>
> > So everything is fine except the method "Request<PersonProxy>
> > findPerson(Long id)" which is required by the GWT RequestFactory
> > servlet. So we can't add a second parameter to this method. But this
> > second parameter is required for our dynamic EntityManagerFactory
> > configuration.
>
> > Are there any plans for a GWT 2.1.x release which supports such a
> > scenario?
>
> The changes to expect are listed 
> inhttp://code.google.com/p/google-web-toolkit/wiki/RequestFactory_2_1_1
>
> > It would be nice if the required findEntity method would
> > support additional custom parameters (maybe via Java5 VarArgs) or if
> > there is a way to transport additional information from client to
> > server during a RequestFactory request which can then be accessed
> > during server side method execution.
>
> > Does anybody have an idea for a nasty workaround for that problem that
> > is possible with the current GWT 2.1 implementation?
>
> One that I wouldn't call "nasty":
> 1. extend DefaultRequestTransport to send the uniqueCustomerName (say,
> within an HTTP header)
> 2. initialize() your RequestFactory with an instance of your extended
> RequestTransport
> 3. on the server-side, get the HttpServletRequest using
> RequestFactoryServlet.getThreadLocalRequest(), to extract the
> uniqueCustomerName from it and use it to create the
> EntityManagerFactory.
> That way, you don't have to send the uniqueCustomerName explicitly in
> each and every request, it'll be done automatically and transparently
> by your RequestTransport.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to