0

Am totally lost trying to understand the @Category annotation of AutoBean. Can somebody please tell me how exactly it can be used?

I went through the example in wiki as well. My doubt is like this.

Say I am having a proxy interface in the client side which extends entity proxy, and I want to insert a non setter/getter method in that interface, how can I do that?

@ProxyFor( value = CacheStrategy.class )
public interface CacheStrategyProxy extends EntityProxy
{
// setters and getters

   CacheStrategyProxy  fetchObject(int id);
}

@Category(CacheStrategyProxyCategory.class)
interface MyFactory extends AutoBeanFactory {
          AutoBean<CacheStrategyProxy> fetchObject();
}

class CacheStrategyProxyCategory {
      public static CacheStrategyProxy fetchObject (AutoBean<CacheStrategyProxy> instance, int id) {
                 // return data
    }
}

Am writing all this in my CacheStrategyProxy file. But I still get the error "Only setters and getters allowed". Pardon me if I have done something silly here. I am totally new to this world.

LPD
  • 2,833
  • 2
  • 29
  • 48
  • I don't understand the relationship between the question's title and body. Maybe this is what you're looking for: https://groups.google.com/d/topic/google-web-toolkit/IkoTd85mvas/discussion – Thomas Broyer Sep 11 '12 at 09:00
  • Am extremely sorry, as the title I had given in my question was wrong. I went through that link. @category is supported in GWT 2.5 right? I tried to understand how to use it by going through the explanation in http://code.google.com/p/google-web-toolkit/wiki/AutoBean#Categories , but didn't help. Can you please give an example? Thanks for your response. – LPD Sep 11 '12 at 09:25
  • Er, well, there *is* an example in the wiki page, where `PersonCategory` _implements_ the `marry` method of the `Person` bean. – Thomas Broyer Sep 11 '12 at 09:54
  • Hi Thomas, thank you very much for your help. I went through the example and have put up my confusion. AM not able to clearly understand how and where interface "MyFactory" is used and CacheStrategyProxyCategory class is used. – LPD Sep 11 '12 at 10:20
  • My confusion is where exactly I can use MyFactory in the above example – LPD Sep 11 '12 at 11:09
  • It's either AutoBean, or RequestFactory (EntityProxy), not both. – Thomas Broyer Sep 11 '12 at 11:45
  • I am very sorry to say, my effort to add a util method in the proxy interface is not happening. In the example given in the wiki page, I am not able to understand who will use MyFactory interface. From your previous comment, can I not use @Category concept in request factory application? – LPD Sep 12 '12 at 03:50
  • I also went through the RequestFactoryModel class, as suggested by you in [link](http://stackoverflow.com/questions/10636966/rf-jsonrpcproxy-is-neither-a-getter-nor-a-setter). Does that mean RequestFactory currently doesn't support @Category? I am using version 2.5.0.rc1 – LPD Sep 12 '12 at 05:23
  • An `AutoBeanFactory` is meant to be passed to `GWT.create()` or `AutoBeanFactorySource.create()`. – Thomas Broyer Sep 12 '12 at 09:45
  • BTW, I gave you the answer to your question in the first comment (if you followed the links). – Thomas Broyer Sep 12 '12 at 09:48

1 Answers1

0

@Category cannot be used with Request Factory (at least not currently).

Request Factory makes use of AutoBeans (and your proxies will be AutoBean instances) but the AutoBeanFactory (factories actually) is/are internal to the RequestFactory, and you cannot tweak them.

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164