Thursday, February 28, 2013

Re: RequestFactory issue with overloaded setters in domain type

 FYI writing my own ServiceLayerDecorator with the following worked like a charm so extra thanks for the suggestion

    private static Method getBeanMethod( BeanMethod methodType, Class<?> domainType, String property, Class<?> propertyType ) {
        for ( Method m : domainType.getMethods() ) {
            if ( methodType.matches( m ) && property.equals( methodType.inferName( m ) )
                    && m.getParameterTypes()[0].isAssignableFrom( propertyType ) ) {
                m.setAccessible( true );
                return m;
            }
        }
        return null;
    }

    @Override
    public Method getSetter( Class<?> domainType, String property ) {
        Class<?> propertyType = getTop().getGetter( domainType, property ).getReturnType();
        Method setter = getBeanMethod( BeanMethod.SET, domainType, property, propertyType );
        if ( setter == null ) {
            setter = getBeanMethod( BeanMethod.SET_BUILDER, domainType, property, propertyType );
        }
        return setter;
    }


On 28 February 2013 13:44, James Horsley <james.horsley@gmail.com> wrote:
Makes sense. Thanks!


On 28 February 2013 13:27, Thomas Broyer <t.broyer@gmail.com> wrote:


On Thursday, February 28, 2013 1:50:03 PM UTC+1, James Horsley wrote:
I'll take a stab at writing a ServiceLayerDecorator as that should get me unblocked without writing DTO's and if the correct setter is called the NPE's won't be an issue. Thanks to you both for the suggestions!

Thomas, is this issue likely to end up as PatchesWelcome or WontFix? If the former then I'll look at getting a patch together.

I you send a patch, I'll look at it; the outcome will depend on what changes the patch has to make. 

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment