Wednesday, June 20, 2012

Re: JAVA Generics with ValueProxy

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 <mwakatobe@gmail.com>
Thanks Alexandre , but that did not work as well


On Tuesday, 19 June 2012 11:56:18 UTC-4, Alexandre Ardhuin wrote:
The value attribute in @ProxyForName should be "com.vo.GenericTreeNode" instead of "com.vo.GenericTreeNode<Account>"

Alexandre


2012/6/19 tzhotmail <mwakatobe@gmail.com>
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.

--
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-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.


--
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/-/6hyZUvd02_EJ.

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.

--
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-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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate