Placing xxx.ui.xml files in different packages than counterpart Java files

2,462 views
Skip to first unread message

Yaakov

unread,
May 11, 2010, 11:53:21 AM5/11/10
to Google Web Toolkit
Hi,

Does anyone know if there is a way to place the ui.xml files in a
separate from its Java counterpart file package?

What I have to have is essentially the following package structure:
view - All Java uibinder classes
view.uibinder - All .ui.xml files
view.uibinder.resources - All .css files.

I found the @UiTemplate annotation that allowed me to successfully
move the ui.xml files into the view.uibinder package and just refer to
those in the Java file with @UiTemplate("uibinder/someView.ui.xml").

Unfortunately, all the references to the resources, although showing
no errors in Eclipse, start breaking on GWT compile. So, for example,
if I have the following in my ui.xml:
<ui:style field='myStyle' src='resources/style.css' />

When compiled, the error says that it can't find the style when lookin
in view/resources/styles.css. Note the lack of "uibinder" directory in
the error message!

Upon further testing, it seems clear that when the ui.xml files gets
ingested into its Java counter part, it copies that 'src' path
verbatum, without adjusting it first. I know this because if I put "../
resources/style.css", the error message will come with that it can't
find the path and show that it's looking in "view/../resources/
style.css"

Is there some annotation or some flag I am supposed to provide to get
this to work or is the location of the .ui.xml file forever stuck with
the location of its counterpart Java file?

Thanks,
Yaakov.

--
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-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Sripathi Krishnan

unread,
May 11, 2010, 2:39:35 PM5/11/10
to google-we...@googlegroups.com
If you just want to keep your java, css and ui.xml code in different folders, there's an easier technique. Create two folders parallel to src - "uibinder" and "css". Or whatever you want to name it. Then add these folders to the sourcepath in eclipse. These three folders should have the same package hierarchy, so GWT will be able to find ui.xml and css files without any problem. 

In our project, the above convention helps us to separate ui code from java code. Keeps the ui folks from stepping over developers toes.

--Sri

Yaakov Chaikin

unread,
May 11, 2010, 2:51:47 PM5/11/10
to google-we...@googlegroups.com
Hi Sri,

This wouldn't really work for me as we are using maven and maven has
specific standard directory structure. I guess, I could modify the
pom.xml to see those additional directories as source directories as
well, but all that work in maven that would kinda defeat the purpose
for me, i.e., it would now move the "mess" to maven and having to deal
with maven over this is not worth it for us at this point.

I just want to know if it's possible to do this with pure GWT solution or not.

Anyone know?

Thanks,
Yaakov.

Zak

unread,
May 11, 2010, 7:37:50 PM5/11/10
to Google Web Toolkit
Perhaps you can use the @UiTemplate annotation?

Check out the very bottom of http://code.google.com/webtoolkit/doc/latest/DevGuideUiBinder.html

I can't find any documentation about the specifics of this, but it
looks promising.

On May 11, 2:51 pm, Yaakov Chaikin <yaakov.chai...@gmail.com> wrote:
> Hi Sri,
>
> This wouldn't really work for me as we are using maven and maven has
> specific standard directory structure. I guess, I could modify the
> pom.xml to see those additional directories as source directories as
> well, but all that work in maven that would kinda defeat the purpose
> for me, i.e., it would now move the "mess" to maven and having to deal
> with maven over this is not worth it for us at this point.
>
> I just want to know if it's possible to do this with pure GWT solution or not.
>
> Anyone know?
>
> Thanks,
> Yaakov.
>
> On Tue, May 11, 2010 at 2:39 PM, Sripathi Krishnan
>
>
>
> <sripathi.krish...@gmail.com> wrote:
> > If you just want to keep your java, css and ui.xml code in different
> > folders, there's an easier technique. Create two folders parallel to src -
> > "uibinder" and "css". Or whatever you want to name it. Then add these
> > folders to the sourcepath in eclipse. These three folders should have the
> > same package hierarchy, so GWT will be able to find ui.xml and css files
> > without any problem.
> > In our project, the above convention helps us to separate ui code from java
> > code. Keeps the ui folks from stepping over developers toes.
> > --Sri
>
> For more options, visit this group athttp://groups.google.com/group/google-web-toolkit?hl=en.

Yaakov Chaikin

unread,
May 11, 2010, 8:09:29 PM5/11/10
to google-we...@googlegroups.com
Zak,

If you read my post a bit further, most of the post discusses my
experience with using @UiTemplate.

Yaakov.
Reply all
Reply to author
Forward
0 new messages