JAVA Generics with ValueProxy

438 views
Skip to first unread message

tzhotmail

unread,
Jun 19, 2012, 11:18:04 AM6/19/12
to Google Web Toolkit
Please help on GWT JAVA Generics with ValueProxy

I have the following Domain class
public class GenericTreeNode<T> implements java.io.Serializable{

/**
*
*/
private static final long serialVersionUID = 1L;
private T data;
private List<GenericTreeNode<T>> children;
private GenericTreeNode<T> parent;

public GenericTreeNode() {
super();
children = new ArrayList<GenericTreeNode<T>>();
}

public GenericTreeNode( T data ) {
this();
setData( data );
}

public GenericTreeNode<T> getParent() {
return this.parent;
}

public List<GenericTreeNode<T>> getChildren() {
return this.children;
}



public void removeChildAt( int index ) throws
IndexOutOfBoundsException {
children.remove( index );
}

public GenericTreeNode<T> getChildAt( int index ) throws
IndexOutOfBoundsException {
return children.get( index );
}

public T getData() {
return this.data;
}

public void setData( T data ) {
this.data = data;
}

public String toString() {
return getData().toString();
}

@Override
public boolean equals( Object obj ) {
if ( this == obj ) {
return true;
}
if ( obj == null ) {
return false;
}
if ( getClass() != obj.getClass() ) {
return false;
}
GenericTreeNode<?> other = (GenericTreeNode<?>) obj;
if ( data == null ) {
if ( other.data != null ) {
return false;
}
} else if ( !data.equals( other.data ) ) {
return false;
}
return true;
}

/
}

then I created the following Client Proxies and Request Factory.

import com.google.web.bindery.requestfactory.shared.ProxyForName;
import com.google.web.bindery.requestfactory.shared.ValueProxy;
@ProxyForName( value = "com.vo.Account" )
public interface AccountProxy extends ValueProxy {
public Integer getPfId();

public void setPfId( Integer pfId );

public Integer getPfParentId();

public void setPfParentId( Integer pfParentId );

public Integer getPfRootId();

public void setPfRootId( Integer pfRootId );

public String getName();

public void setName( String name );
}

@ProxyForName( value = "com.vo.GenericTreeNode<Account>" )
public interface AccountNodeProxy<AccountProxy> extends ValueProxy{

List<AccountNodeProxy<AccountProxy>> getChildren();

AccountProxy getData();

}


@ServiceName( value = "com.server.DesktopService", locator =
"com.server.locator.SpringServiceLocator" )
public interface DesktopRequest extends RequestContext {

abstract Request<List<AccountProxy>> getAccounts( Integer realm,
List<Integer> relations );

abstract Request<List<AccountNodeProxy<AccountProxy>>>
getAccountsNodes( Integer realm, List<Integer> relations );

abstract Request<List<AccountProxy>> getAccounts( String userId,
List<Integer> realms );

abstract Request<List<ApplicationProxy>> getApplications();

abstract Request<List<AttributeDefProxy>> getAttributeDefs( String
attributeName );

}


But I still get the message below on Compiling , where am I doing
wrong.

warning: Cannot fully validate proxy since type
com.vo.GenericTreeNode<AccountProxy> is not available

Add @SuppressWarnings("requestfactory") to dismiss.
error: The type AccountProxy cannot be used here
warning: Cannot validate this method because the domain mapping for
the return
type
(com.client.proxy.AccountNodeProxy<com.client.proxy.AccountProxy>)
could not be resolved to a domain type

Add @SuppressWarnings("requestfactory") to dismiss.
error: Could not load domain mapping for context DesktopRequest.
Check that both the shared interfaces and server domain types are on
the classpa
th.
2 errors
[INFO]
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Command execution failed.

Alexandre Ardhuin

unread,
Jun 19, 2012, 11:56:18 AM6/19/12
to google-we...@googlegroups.com
The value attribute in @ProxyForName should be "com.vo.GenericTreeNode" instead of "com.vo.GenericTreeNode<Account>"

Alexandre


2012/6/19 tzhotmail <mwak...@gmail.com>

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


tzhotmail

unread,
Jun 20, 2012, 6:01:33 PM6/20/12
to google-we...@googlegroups.com
Thanks Alexandre , but that did not work as well
2012/6/19 tzhotmail <mwak...@gmail.com>
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsub...@googlegroups.com.

Ashwin Desikan

unread,
Jun 20, 2012, 9:34:00 PM6/20/12
to google-we...@googlegroups.com
On your value proxy add the following annotation to the interface

@SuppressWarnings("requestfactory")

Sent from my iPhone
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/6hyZUvd02_EJ.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.

Alexandre Ardhuin

unread,
Jun 21, 2012, 2:59:55 AM6/21/12
to google-we...@googlegroups.com
I see an other problem with :


public interface AccountNodeProxy<AccountProxy> extends ValueProxy{
        List<AccountNodeProxy<AccountProxy>> getChildren();
        AccountProxy getData();
}

Here, AccountNodeProxy is declared like a generic type with <AccountProxy> as type parameter. It's like you wrote :

public interface AccountNodeProxy<T> extends ValueProxy{
        List<AccountNodeProxy<T>> getChildren();
        T getData();
}

I don't think it's what you want. It should be :

public interface AccountNodeProxy extends ValueProxy{
        List<AccountNodeProxy> getChildren();
        AccountProxy getData();
}

Alexandre


2012/6/21 tzhotmail <mwak...@gmail.com>

To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages