Monday, May 28, 2012

RequestFactory 2.4: save entities with multiple sub entities, can only get the first one at server side.

I'm using GWT requestFactory to save an entity, the code is rather simple: i want to create a Blog entity with several Tags, here is my code:

client side:

         BlogRequest blogRequest = factory.blogRequest();
        BlogProxy  instance  = blogRequest.create(  BlogProxy .class );

        instance.setName( "blog name");
        instance.setNote( "mynote2" );
        instance.setTags( base.createTagProxies( blogRequest, tag ) );

        blogRequest.save( instance ).fire(...);


    public Set<TagProxy> createTagProxies( BlogRequest request, String... tagNames )
    {
        Set<TagProxy> tagproxies = new HashSet<TagProxy>();
        for( String tagName : tagNames )
        {
            TagProxy proxy = request.create( TagProxy.class );
            proxy.setName( tagName );
            tagproxies.add( proxy );
        }
        return  tagproxies  ;
    }

for example i create a blog with "Tag1" and "Tag2" in a Set, however after the request send to server side, at Blog#setTags(Set<Tag> tags) method there is only one tag in the parameter set, which is "Tag1", "Tag2" is just missing.

Could anybody help with this issue? Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/c98J9a_tfyAJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment