UiBinder and cell widget

89 views
Skip to first unread message

Grzegorz Kossakowski

unread,
Apr 7, 2012, 10:18:48 AM4/7/12
to scalagwt, nate.bau...@gmail.com
Hi,

Nate, you mentioned before that you ported portion of Cell widget demo. Would you be interested in porting it completely to Scala?


and want to know if I can get some help on this :)

Let me know what you think.

PS. Other willing to help with updating samples are welcome to join of course!

--
Grzegorz Kossakowski

Nate Bauernfeind

unread,
Apr 7, 2012, 2:13:06 PM4/7/12
to Grzegorz Kossakowski, scalagwt
I would be interested in continuing this.

I stopped midstream last time because the build was failing (I don't exactly remember context, but my commit message says) "build breaks due to internal scala compiler on nested enum."

It is probably not an issue anymore, hopefully =).

Grzegorz Kossakowski

unread,
Apr 7, 2012, 2:29:06 PM4/7/12
to Nate Bauernfeind, scalagwt
On 7 April 2012 20:13, Nate Bauernfeind <nate.bau...@gmail.com> wrote:
I would be interested in continuing this.

Cool! I'll work on other part then.
 
I stopped midstream last time because the build was failing (I don't exactly remember context, but my commit message says) "build breaks due to internal scala compiler on nested enum."

It is probably not an issue anymore, hopefully =).

Ouch. Enums are not the biggest strength of Scala compiler so you might run into this issue again. If so, let me know.

--
Grzegorz Kossakowski

Grzegorz Kossakowski

unread,
Apr 9, 2012, 2:57:37 PM4/9/12
to Nate Bauernfeind, scalagwt
On 7 April 2012 20:29, Grzegorz Kossakowski <grzegorz.k...@gmail.com> wrote:
On 7 April 2012 20:13, Nate Bauernfeind <nate.bau...@gmail.com> wrote:
I would be interested in continuing this.

Cool! I'll work on other part then.

It turned out that it's simply easier to port everything to Scala while updating Showcase. I'm on it right now.

--
Grzegorz Kossakowski

Nate Bauernfeind

unread,
Apr 9, 2012, 5:55:38 PM4/9/12
to Grzegorz Kossakowski, scalagwt
As long as you're excited about it ;).

This may be useful to you if/when you run into problems with UIBinder:
https://github.com/nbauernfeind/scalagwt-gwt/tree/UiBinderSupport

I have not yet had the chance to write additional tests that go along with GWT's move to use the AbstractFieldWriter. FWIW, this worked about a month ago.

Grzegorz Kossakowski

unread,
Apr 9, 2012, 6:46:48 PM4/9/12
to Nate Bauernfeind, scalagwt
On 9 April 2012 23:55, Nate Bauernfeind <nate.bau...@gmail.com> wrote:
As long as you're excited about it ;).

This may be useful to you if/when you run into problems with UIBinder:

Thanks. :-) BTW. I think I found the problem with enums, see:


Could you verify? 

ant clean && ant
cd test && ./partest --jribble

I have not yet had the chance to write additional tests that go along with GWT's move to use the AbstractFieldWriter. FWIW, this worked about a month ago.

It would be super cool to get this functionality covered by extensive tests.

--
Grzegorz Kossakowski

Nate Bauernfeind

unread,
Apr 9, 2012, 9:22:59 PM4/9/12
to Grzegorz Kossakowski, scalagwt
Nice work on adding java enum support =). Tests pass for me.

Grzegorz Kossakowski

unread,
Apr 10, 2012, 12:02:55 PM4/10/12
to Nate Bauernfeind, scalagwt
On 9 April 2012 23:55, Nate Bauernfeind <nate.bau...@gmail.com> wrote:
As long as you're excited about it ;).

This may be useful to you if/when you run into problems with UIBinder:
https://github.com/nbauernfeind/scalagwt-gwt/tree/UiBinderSupport

I have not yet had the chance to write additional tests that go along with GWT's move to use the AbstractFieldWriter. FWIW, this worked about a month ago.

I think I ran into problems with UiBinder. See this gist. Basically, generated code tries to access (private) fields instead of going through accessors:


     [java] Validating units:
     [java] Errors in 'generated://2DC862AEF141A5CF6B2762371A620676/com/google/gwt/sample/showcase/client/ShowcaseShell_ShowcaseShellUiBinderImpl.java'
     [java] Line 451: The field ShowcaseShell.mainMenu is not visible
     [java] See snapshot: /var/folders/bj/m3zw8wpx1jvcdcqlfd5hyl340000gn/T/com.google.gwt.sample.showcase.client.ShowcaseShell_ShowcaseShellUiBinderImpl6513177951694488806.java
     [java] Removing invalidated units

The code I used for running into that problem can be found here:

Can you have a look into it?

--
Grzegorz Kossakowski

Nate Bauernfeind

unread,
Apr 11, 2012, 2:39:57 AM4/11/12
to Grzegorz Kossakowski, scalagwt
That's interesting. So it sounds like scala implements package private
by making the field completely private and applying the package
private to the accessor method (you probably already knew that).

I added provided field support as well via getters. A method is
considered a getter if:
1) it is a zero arg function
2) it returns the proper type as the ui field
and 3) contains the name of the field (non-case-sensitive).

This supports the bean naming scheme (getMainMenu) and the scala one
(mainMenu). For setters I wrote to cause it to be an error if there is
more than one method that looks like a setter. Originally, I added
that in for the getters but in your sample it fails. There's the scala
getter (package private) and then the getter you expose (getMainMenu)
to the showcase class. Not sure how we should handle that (i.e. tell
me what semantics you want). For now, I'm allowing more than one and
breaking ties by choosing the one with the fewest letters in the name.

Writing full tests for these is my next top scala-gwt related priority
(and removing my changes to UiBinderWriter class which might be in the
process of being deprecated in favor of AbstractFieldWriter).

I've updated my current UiBinderSupport branch that you can merge.
https://github.com/nbauernfeind/scalagwt-gwt/commits/UiBinderSupport

BTW, it compiles but does not run. It gives this error:

Uncaught TypeError: Cannot read property 'listWrapper' of null

(anonymous function) FBFD560377482D0691310860178B6C65.cache.html:1431
gwtOnLoad FBFD560377482D0691310860178B6C65.cache.html:41654
maybeStartModule showcase.nocache.js:39
showcase.onScriptLoad showcase.nocache.js:356
(anonymous function)

Grzegorz Kossakowski

unread,
Apr 11, 2012, 8:21:24 AM4/11/12
to Nate Bauernfeind, scalagwt
On 11 April 2012 08:39, Nate Bauernfeind <nate.bau...@gmail.com> wrote:
That's interesting. So it sounds like scala implements package private
by making the field completely private and applying the package
private to the accessor method (you probably already knew that).

Yup.
 
I added provided field support as well via getters. A method is
considered a getter if:
1) it is a zero arg function
2) it returns the proper type as the ui field
and 3) contains the name of the field (non-case-sensitive).

This supports the bean naming scheme (getMainMenu) and the scala one
(mainMenu). For setters I wrote to cause it to be an error if there is
more than one method that looks like a setter. Originally, I added
that in for the getters but in your sample it fails. There's the scala
getter (package private) and then the getter you expose (getMainMenu)
to the showcase class. Not sure how we should handle that (i.e. tell
me what semantics you want). For now, I'm allowing more than one and
breaking ties by choosing the one with the fewest letters in the name.


It's just a cruft I got from automatic Java2Scala conversion IntelliJ provided. Situation where we have two different accessor was not intended so you don't need to bother supporting this case and you can safely issue an error.

 
Writing full tests for these is my next top scala-gwt related priority
(and removing my changes to UiBinderWriter class which might be in the
process of being deprecated in favor of AbstractFieldWriter).


That would be certainly cool.


I've updated my current UiBinderSupport branch that you can merge.
https://github.com/nbauernfeind/scalagwt-gwt/commits/UiBinderSupport

Thanks!
 
BTW, it compiles but does not run. It gives this error:

Uncaught TypeError: Cannot read property 'listWrapper' of null

(anonymous function)     FBFD560377482D0691310860178B6C65.cache.html:1431
gwtOnLoad                    FBFD560377482D0691310860178B6C65.cache.html:41654
maybeStartModule         showcase.nocache.js:39
showcase.onScriptLoad  showcase.nocache.js:356
(anonymous function)

It was initialization order bug in Scala code. I fixed it. The whole Showcase is ported to Scala now and mostly works:

There's problem with cell samples but I didn't have time to dig into it.

--
Grzegorz Kossakowski

Nate Bauernfeind

unread,
Apr 11, 2012, 9:15:23 AM4/11/12
to Grzegorz Kossakowski, scalagwt
On Wed, Apr 11, 2012 at 7:21 AM, Grzegorz Kossakowski
<grzegorz.k...@gmail.com> wrote:
> It's just a cruft I got from automatic Java2Scala conversion IntelliJ
> provided. Situation where we have two different accessor was not intended so
> you don't need to bother supporting this case and you can safely issue an
> error.

Is there value in being able to hide the setter to some scope and yet
create a public getter in general? I realize you'll probably want to
use a val in this particular case and construct it at the declaration
site.

Grzegorz Kossakowski

unread,
Apr 11, 2012, 9:28:25 AM4/11/12
to Nate Bauernfeind, scalagwt
I don't think there's a value in supporting such case at the moment. I much more value simple rules and simple implementation of them along with tests.

--
Grzegorz Kossakowski
Reply all
Reply to author
Forward
0 new messages