Search code examples
gwtrequestfactory

Non setter/getter methods in proxy interface


Is there a way where I can put non setter/getter methods inside the proxy interface that we define?

For eg..

@ProxyFor( value = requestFactory.example.gwt.server.domain.Person.class )
public interface PersonProxy extends EntityProxy
{
    String getLastName();

    String getFirstName();

    void setLastName( String nachname );

    void setFirstName( String vorname );

    public Long getId();

    public Integer getVersion();

    void setProperty(String name, Object value);

}

The last method in the above example throws an exception "Only setters and getters allowed". Any ways to fix this? Thanks in advance.


Solution

  • No. Proxies can only have getters and setters.

    You can however add a method to a RequestContext for the same server-side call to be made:

    InstanceRequest<PersonProxy> setProperty(String name, String value);
    

    Used as:

    context.setProperty("foo", "bar").using(personProxy);
    

    Note that you cannot use Object either (and before you ask: no, you cannot have overloads so you'd have to add setPropertyString, setPropertyDate, setPropertyDouble, etc. with similarly named methods on the server-side)