Cannot parse value: "res.xxx" as type ImageResource

243 views
Skip to first unread message

giannisdag

unread,
Jun 26, 2010, 6:07:56 PM6/26/10
to Google Web Toolkit
Hi I am trying to use uibinder to add an image in my web page using
clientbundle. Following the paradigm "Using an external resource" of
the documentation "Declarative Layout with UiBinder", I wrote the
following:

<ui:with field='res'
type='xel.villaView1.client.villaViewClientBundle'/>
<g:DockLayoutPanel unit='EM'>
<g:north size='14'>
<g:HTMLPanel>
<div class="titleblock">
<div id="logo"><img src="/images/dolphin.gif"/></div>
<div id="langMenu"><g:Image resource="res.bedroom" ></g:Image> </
div>
<h1 id="mainTitle"><ui:msg description="Main Title">Main title</
ui:msg></h1>
</div>
</g:HTMLPanel>

I have created a clientbundle using eclipse,

public interface villaViewClientBundle extends ClientBundle {

static villaViewClientBundle INSTANCE =
GWT.create(villaViewClientBundle.class);

ImageResource el();

@Source("xel/villaView1/client/design/images/photos/bedroom.jpg")
ImageResource bathroom();

}
but when I run it, I am getting the following message:
Cannot parse value: "res.bedroom" as type ImageResource
What do you think?

André Severo Meira

unread,
Jun 26, 2010, 9:41:32 PM6/26/10
to google-we...@googlegroups.com
Helo!
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xml:lang="it" dir="ltr"  
               
xmlns="http://www.w3.org/1999/xhtml"  
               
xmlns:ui='urn:ui:com.google.gwt.uibinder' 
               
xmlns:gwt='urn:import:com.google.gwt.user.client.ui'> 
    
       
<head> 
               
<title>Use case for GWT + UiBinder + XHTML</title> 
               
<script type="text/javascript" src="mymodule/mymodule.nocache.js"></script> 
       
</head> 
         
       
<body> 
               
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' 
                       
style="position: absolute; width: 0; height: 0; border: 0"></iframe> 
         
               
<div id="sample_content_1"> 
                       
<!-- same example of the hello world --> 
                       
<ui:UiBinder> 
                               
<div> 
                                        Hello,
<span ui:field='nameSpan'/>
                               
</div> 
                       
</ui:UiBinder> 
               
</div> 
                 
               
<div id="sample_content_2"> 
                       
<!--  
                                creating a declarative layout for an app, intended to produce a layout 
                                similar to http://gwt.google.com/samples/Showcase/Showcase.html#CwVerticalPanel  
                        -->
 
                       
<ui:UiBinder> 
                               
<gwt:VerticalPanel spacing="5" debugId="cwVerticalPanel"> 
                                       
<gwt:Button text="Button 1" /> 
                                       
<gwt:Button text="Button 2" /> 
                                       
<gwt:Button text="Button 3" /> 
                                       
<gwt:Button text="Button 4" /> 
                                       
<gwt:Button text="Button 5" /> 
                                       
<gwt:Button text="Button 6" /> 
                                       
<gwt:Button text="Button 7" /> 
                                       
<gwt:Button text="Button 8" /> 
                                       
<gwt:Button text="Button 9" />                           
                               
</gwt:VerticalPanel> 
                       
</ui:UiBinder> 
               
<div> 
       
</body> 
</html>
 
 
 
 
//////////////////////////////////////////////////////////


 
2010/6/26 giannisdag <pasco...@gmail.com>

--
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.


giannisdag

unread,
Jun 27, 2010, 2:06:40 AM6/27/10
to Google Web Toolkit
Thank you for your reply, but I can't understand what do you suggest.
If I remove the code in uibinder that calls <g:Image>, then my code
works fine, I don' t have to change it the way you are showing, if I
get it right. To be more presice, I will paste the entire code of my
ui.xml

<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui"

ui:generateFormat='com.google.gwt.i18n.rebind.format.PropertiesFormat'

ui:generateKeys="com.google.gwt.i18n.rebind.keygen.MD5KeyGenerator"
ui:generateLocales="default">
<ui:with field='res'
type='xel.villaView1.client.villaViewClientBundle'/>
<g:DockLayoutPanel unit='EM'>
<g:north size='14'>
<g:HTMLPanel>
<div class="titleblock">
<div id="logo"><img src="/images/dolphin.gif"/></div>
<div id="langMenu"><g:Image resource="res.bedroom" ></g:Image> </
div>
<h1 id="mainTitle"><ui:msg description="Main Title">Main title</
ui:msg></h1>
</div>
</g:HTMLPanel>
</g:north>
<g:center>
<g:TabLayoutPanel barUnit='PX' barHeight='20'>
<g:tab>
<g:header size='7'><ui:msg description="Home">Home</ui:msg></
g:header>
<g:Label>adsfaable</g:Label>
</g:tab>
<g:tab>
<g:header size='7'><ui:msg description="Photos">Photos</
ui:msg></g:header>
<g:Label>photos</g:Label>
</g:tab>
<g:tab>
<g:header size='7'><ui:msg description="Prices">Prices</
ui:msg></g:header>
<g:Label>Prices</g:Label>
</g:tab>
<g:tab>
<g:header size='7'><ui:msg description="Map">Map</ui:msg></
g:header>
<g:Label>Map</g:Label>
</g:tab>
<g:tab>
<g:header size='7'><ui:msg description="Contact">Contact</
ui:msg></g:header>
<g:Label>contact</g:Label>
</g:tab>
</g:TabLayoutPanel>
</g:center>
<g:south size='2'>
<g:Label>Giannis</g:Label>
</g:south>
</g:DockLayoutPanel>
</ui:UiBinder>
and the code of the relevant java file

public class helloWorld extends Composite {

private static helloWorldUiBinder uiBinder = GWT
.create(helloWorldUiBinder.class);

interface helloWorldUiBinder extends UiBinder<Widget, helloWorld> {
}

public helloWorld() {
initWidget(uiBinder.createAndBindUi(this));
}

}

giannisdag

unread,
Jun 27, 2010, 2:15:04 AM6/27/10
to Google Web Toolkit
Also, if I write:
<div id="langMenu"><g:Image ui:field='myImage' ></g:Image> </div>
and then access it programmatically:

@UiField Image myImage;

public helloWorld() {
initWidget(uiBinder.createAndBindUi(this));
myImage.setResource(villaViewClientBundle.INSTANCE.bathroom());
}

It works fine.

Thomas Broyer

unread,
Jun 27, 2010, 6:52:33 AM6/27/10
to Google Web Toolkit
Could it simply be that in the code originally posted you're
referencing res.bedroom instead of res.bathroom?

(as a side note, shouldn't your @Source reference "design/images/
photos/bedroom.jpg", i.e. without the "xel/villaView1/client/" part?)

giannisdag

unread,
Jun 27, 2010, 12:27:41 PM6/27/10
to Google Web Toolkit
> Could it simply be that in the code originally posted you're
> referencing res.bedroom instead of res.bathroom?
>
> (as a side note, shouldn't your @Source reference "design/images/
> photos/bedroom.jpg", i.e. without the "xel/villaView1/client/" part?)

Thank you, for this observation, I did a lot of testing changing
photos etc. just to be sure, which sometimes after some hour causes
such mistakes, but the problem remains, even when I correct this. The
problem seems to happen because uibinder cannot instanciate the
clientbundle as far as I can tell. Its not a big issue for me, as I
can continue accessing the clientbundle resource with code, but I
should know what I can do and what I can't.

giannisdag

unread,
Jun 27, 2010, 12:45:36 PM6/27/10
to Google Web Toolkit
Also I checked this, it isn' t a problem, I just use the automated
method of eclipse, and eclipse adds the absolute path to clientbundle

Thomas Broyer

unread,
Jun 27, 2010, 6:45:37 PM6/27/10
to Google Web Toolkit


On 27 juin, 00:07, giannisdag <pascoua...@gmail.com> wrote:
> Hi I am trying to use uibinder to add an image in my web page using
> clientbundle. Following the paradigm "Using an external resource" of
> the documentation "Declarative Layout with UiBinder", I wrote the
> following:
>
>         <ui:with field='res'
> type='xel.villaView1.client.villaViewClientBundle'/>
>         <g:DockLayoutPanel unit='EM'>
>                   <g:north size='14'>
>                     <g:HTMLPanel>
>                       <div class="titleblock">
>                                 <div id="logo"><img src="/images/dolphin.gif"/></div>
>                                         <div id="langMenu"><g:Image resource="res.bedroom" ></g:Image> </
> div>

Haven't you forgotten the braces?
<g:Image resource="{res.bedroom}" />

giannisdag

unread,
Jun 28, 2010, 2:43:12 AM6/28/10
to Google Web Toolkit
Yes this is the problem. Sorry again, I have to be more careful :(((
Reply all
Reply to author
Forward
0 new messages