If you annotate your constructor parameter annotation with @annotation.target.field your parameter annotation will be assigned to the field as well. The same principle can be applied to getters and setters by using appropriate annotations in annotation.target. In order to avoid having to double annotate each parameter you can also use type definitions to keep the syntax concise, e.g.
type Index = org.hibernate.annotations.Index @field
case class(@Index id: Int)
Thus case classes should not be a handicap regarding this concern.
PS: Thanks to all of you for your great work on this project. I'm currently writing my Scala web 2.0 apps with Vaadin, but having the opportunity to write GWT components or whole GWT projects in Scala would be great.
Cheers,
Stefan
I have ported a portion of the CellWidget demo over to scala. It uses UiBinder, and as far as I could tell everything would work if it could find the appropriate setter.Here is an example error message: "The field CwCellList.pagerPanel is not visible"It uses annotations in many convenient ways. The @UiField annotation links a particular widget on the UI to a specific member variable of the class.GWT was actually finding these annotations on fields. I thought that I heard that jribble does not support annotations. I could not find any mention of the annotations in the jribbletxt. So, what is the story with annotations?
I've decompiled an annotated field and only the field retains the annotation (the methods contain none). Case classes are a corner case where the field is not annotated but the constructor parameter is; luckily though case classes don't make any sense in a UiBinder setter-injection context (yet worth mentioning).So, if we could use un-annotated setters in GWT then I think that it would be a great solution. If the implementation requires annotations on the setter then we'll have to change the current contract between annotations on fields and their helper methods (read: this is probably a bad idea).
That sounds like a good strategy to me. It is hopefully a simple
update to UIBinder, and it will allow Scala code, written in normal
Scala style, to reliably work. -Lex
Yes that was what I was hoping to be able to do. I'd definitely want it contained inside of UiBinder to start with. I hadn't had a chance to chase down a solution as my quick-and-dirty search of "is not visible" came up empty.If someone else isn't already planning on jumping on this I could make it a priority; UiBinder is a must-have for me.
On Wed, Feb 8, 2012 at 2:21 AM, Nate Bauernfeind
<nate.bau...@gmail.com> wrote:
> "ant test" fails on the current master of scalagwt-gwt. It first fails on
> the style check and then if commented out of the build.xml file it fails
> compiling tests. First compilation failure is a discrepancy between
> MockCompilationUnit and CompilationUnit which seems to have resulted from
> Lex Spoon's latest pull request; though I don't know if they were passing
> before that pull request anyways.
We need to get this stuff working.
The style check passed for me before I put out the pull request, so
there must be some kind of merge issue. It should be something simple,
whatever the problem is.
Regarding MockCompilationUnit, I didn't try running "ant test". Crud.
This particular problem should be very easy to fix. It's just a mock,
and the missing method should return 0 or null or the like.
>
> I've implemented (or hacked together really... since, again, I'm not
> familiar with the code base) setter support for UiBinder. I tossed together
> two simple tests, but I don't really know if the tests themselves pass. I've
> built and used the gwt jars successfully in altered versions of the current
> scalagwt-sample.
>
> Pull Request is here:
> https://github.com/scalagwt/scalagwt-gwt/pull/29
Organizationally, let's put this on a branch, or possibly as an issue
filed directly with the GWT project.
I expect the GWT team will really like this patch, but I don't want to
muddy the waters around the core Jribble patch. A lot is riding on
whether the core patch goes in or not.
Lex
Great news about the UiBinder progress! A couple of little notes:
We need to get this stuff working.
On Wed, Feb 8, 2012 at 2:21 AM, Nate Bauernfeind
<nate.bau...@gmail.com> wrote:
> "ant test" fails on the current master of scalagwt-gwt. It first fails on
> the style check and then if commented out of the build.xml file it fails
> compiling tests. First compilation failure is a discrepancy between
> MockCompilationUnit and CompilationUnit which seems to have resulted from
> Lex Spoon's latest pull request; though I don't know if they were passing
> before that pull request anyways.
The style check passed for me before I put out the pull request, so
there must be some kind of merge issue. It should be something simple,
whatever the problem is.
Regarding MockCompilationUnit, I didn't try running "ant test". Crud.
This particular problem should be very easy to fix. It's just a mock,
and the missing method should return 0 or null or the like.
Organizationally, let's put this on a branch, or possibly as an issue
>
> I've implemented (or hacked together really... since, again, I'm not
> familiar with the code base) setter support for UiBinder. I tossed together
> two simple tests, but I don't really know if the tests themselves pass. I've
> built and used the gwt jars successfully in altered versions of the current
> scalagwt-sample.
>
> Pull Request is here:
> https://github.com/scalagwt/scalagwt-gwt/pull/29
filed directly with the GWT project.
I expect the GWT team will really like this patch, but I don't want to
muddy the waters around the core Jribble patch. A lot is riding on
whether the core patch goes in or not.
It looks quite good to me. Like you say, it is possible to quibble
around about what counts as a setter method. In practice, though, any
definition will suffice so long as it supports the usual Java idiom as
well as the usual Scala idiom.
The test cases are particularly good. One is for a Java bean kind of
setter, the other for a Scala setter.
Lex
Also, I meant to say, it looks great for submission to the GWT project
directly. I am sure "ant test" will pass for you if you do a fresh
checkout. One of the Scala+GWT edits must have made them regress.
-Lex
Organizationally, let's put this on a branch, or possibly as an issuefiled directly with the GWT project.
I expect the GWT team will really like this patch, but I don't want to
muddy the waters around the core Jribble patch. A lot is riding on
whether the core patch goes in or not.
Sounds great to me. -Lex