PDA

View Full Version : Generated beans not working with non-public getters



sdc
19 Mar 2009, 9:17 AM
Hi,

If we have non-public getters (even protected) in a bean (implementing BeanModelTag or with a marker and the @BEAN annotation), we get a GWT error :

[ERROR] Errors in 'transient source for com.extjs.gxt.ui.client.data.BeanModel_MyBean
[ERROR] Line 15: The method getFoo() from the type MyBean is not visibleI think there is a very simple way to fix that : put the generated beans in the same package that the bean.

In BeanModelGenerator (1.2.3), replace :


private String createBean(JClassType bean, TreeLogger logger, GeneratorContext context)
throws Exception {
final String genPackageName = "com.extjs.gxt.ui.client.data";
by



private String createBean(JClassType bean, TreeLogger logger, GeneratorContext context)
throws Exception {
final String genPackageName = bean.getPackage().getName();

sdc
26 Mar 2009, 6:16 AM
Thoughts ? Am I wrong ?

sven
26 Mar 2009, 6:24 AM
I did the change for 2.0 code. It will be in SVN with my next commit.

sdc
26 Mar 2009, 6:31 AM
Thankssssssssss ! ;)

sven
26 Mar 2009, 6:32 AM
Also only public methods will be concidered.

sven
26 Mar 2009, 6:39 AM
I was to fast. This change wont make it into 2.0 ;) it is not working out of the box.

But 2.0 will only concider public getters and setters.

sdc
26 Mar 2009, 6:41 AM
Arf... too bad :(

sven
26 Mar 2009, 6:50 AM
Change to make it work was smaller than original thought. Needs some more testing but looks fine. I hope you are lucky now again ;)

fother
26 Mar 2009, 6:52 AM
why you considers this change bad? Equals sven told its more fast.. all private methods will be converted returning a bad designer pattern.. if you really need this, turn public :)

or.. so explain one reason to get private methods

micgala
26 Mar 2009, 7:55 AM
Hi forther...

I guess you misunderstood him.

What he meant by "too bad" was that it was too bad that it wasn't going to be ready for 2.0 release...

But then sven said that there is a chance that it comes on 2.0 again :)

sdc
26 Mar 2009, 10:21 AM
Change to make it work was smaller than original thought. Needs some more testing but looks fine. I hope you are lucky now again ;)

Great ! No joke this time ? ;)

sven
26 Mar 2009, 10:22 AM
yeah, i have it working. But only public and protected getters and setters will be concidered not private ones.

sdc
26 Mar 2009, 10:26 AM
??? uh ?
Actually, my request was to support protected getters/setters... If they are still not supported, what is the change ?

sven
26 Mar 2009, 10:31 AM
Oh, i changed my post :)

sdc
26 Mar 2009, 10:34 AM
Aaaaaah :)
Nice. No problem about private methods, it is even a good thing to not support them.