GWT 2.5 Cell rendering using uiBinder + image
The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
From:
Evgeniy Bogdanov <ebogda... @gmail.com>
Date: Mon, 5 Nov 2012 07:23:56 -0800 (PST)
Local: Mon, Nov 5 2012 10:23 am
Subject: GWT 2.5 Cell rendering using uiBinder + image
Hi, Is there an any example - how to add image into Cell with UiBinder? There is great example in showcase ( http://gwt.google.com/samples/Showcase/Showcase.html#!CwCellList ) but without uiBinder. UiBinder file:
<!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:with field='contact' type='com.billmanager.client.model.ClientContact'/> <ui:with field='res' type='com.billmanager.client.common.Resources'/> <g:HTMLPanel> <span><ui:text from='{contact.getDisplayName}'/></span> <span><ui:text from='{contact.getDisplayEmail}'/></span> <g:Image resource='{res.delete}'/> </g:HTMLPanel> </ui:UiBinder>
Do not displays image.
My java class is simple:
public class ContactCell extends AbstractCell<ClientContact> {
interface MyUiRenderer extends UiRenderer { void render(SafeHtmlBuilder sb, ClientContact contact);
}
private static MyUiRenderer renderer = GWT.create(MyUiRenderer.class);
@Override public void render(com.google.gwt.cell.client.Cell.Context context, ClientContact value, SafeHtmlBuilder sb) { renderer.render(sb, value);
} }
What I thought is to get rendered element (empty) and add image as html,
but I don't thing it is the right way.
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Thomas Broyer <t.bro... @gmail.com>
Date: Mon, 5 Nov 2012 09:14:14 -0800 (PST)
Local: Mon, Nov 5 2012 12:14 pm
Subject: Re: GWT 2.5 Cell rendering using uiBinder + image
On Monday, November 5, 2012 4:23:56 PM UTC+1, Evgeniy Bogdanov wrote:
> Hi, > Is there an any example - how to add image into Cell with UiBinder? > There is great example in showcase ( > http://gwt.google.com/samples/Showcase/Showcase.html#!CwCellList ) but > without uiBinder. > UiBinder file:
> <!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:with field='contact' > type='com.billmanager.client.model.ClientContact'/> > <ui:with field='res' type='com.billmanager.client.common.Resources'/> > <g:HTMLPanel> > <span><ui:text from='{contact.getDisplayName}'/></span> > <span><ui:text from='{contact.getDisplayEmail}'/></span> > <g:Image resource='{res.delete}'/> > </g:HTMLPanel> > </ui:UiBinder>
> Do not displays image.
> My java class is simple:
> public class ContactCell extends AbstractCell<ClientContact> {
> interface MyUiRenderer extends UiRenderer { > void render(SafeHtmlBuilder sb, ClientContact contact); > }
> private static MyUiRenderer renderer = GWT.create(MyUiRenderer.class);
> @Override > public void render(com.google.gwt.cell.client.Cell.Context context, > ClientContact value, SafeHtmlBuilder sb) { > renderer.render(sb, value); > }
> }
> What I thought is to get rendered element (empty) and add image as html, > but I don't thing it is the right way.
You cannot use a widget (<g:HTMLPanel>, <g:Image>) in a Cell. Replace those
with HTML elements (<div> for instance); and for displaying an
ImageResource in a Cell, use an ImageResourceRenderer to generate the
SafeHtml that you can then pass as argument to the UiRenderer and use in
the template with <ui:safehtml> (similar to <ui:text>).
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Evgeniy Bogdanov <ebogda... @gmail.com>
Date: Mon, 5 Nov 2012 13:38:09 -0800 (PST)
Local: Mon, Nov 5 2012 4:38 pm
Subject: Re: GWT 2.5 Cell rendering using uiBinder + image
On Monday, November 5, 2012 7:14:15 PM UTC+2, Thomas Broyer wrote:
> On Monday, November 5, 2012 4:23:56 PM UTC+1, Evgeniy Bogdanov wrote:
>> Hi, >> Is there an any example - how to add image into Cell with UiBinder? >> There is great example in showcase ( >> http://gwt.google.com/samples/Showcase/Showcase.html#!CwCellList ) but >> without uiBinder. >> UiBinder file:
>> <!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:with field='contact' >> type='com.billmanager.client.model.ClientContact'/> >> <ui:with field='res' type='com.billmanager.client.common.Resources'/> >> <g:HTMLPanel> >> <span><ui:text from='{contact.getDisplayName}'/></span> >> <span><ui:text from='{contact.getDisplayEmail}'/></span> >> <g:Image resource='{res.delete}'/> >> </g:HTMLPanel> >> </ui:UiBinder>
>> Do not displays image.
>> My java class is simple:
>> public class ContactCell extends AbstractCell<ClientContact> {
>> interface MyUiRenderer extends UiRenderer { >> void render(SafeHtmlBuilder sb, ClientContact contact); >> }
>> private static MyUiRenderer renderer = GWT.create(MyUiRenderer.class);
>> @Override >> public void render(com.google.gwt.cell.client.Cell.Context context, >> ClientContact value, SafeHtmlBuilder sb) { >> renderer.render(sb, value); >> }
>> }
>> What I thought is to get rendered element (empty) and add image as html, >> but I don't thing it is the right way.
> You cannot use a widget (<g:HTMLPanel>, <g:Image>) in a Cell. Replace > those with HTML elements (<div> for instance); and for displaying an > ImageResource in a Cell, use an ImageResourceRenderer to generate the > SafeHtml that you can then pass as argument to the UiRenderer and use in > the template with <ui:safehtml> (similar to <ui:text>).
Yah, that works.
finally I was able to display image in Cell, but I don't think it is
optimal way.
So the UiBinder file:
<!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:with field='contact' type='com.billmanager.client.model.ClientContact' /> <div> <span> <ui:text from='{contact.getDisplayName}' /> </span> <span> <ui:text from='{contact.getDisplayEmail}' /> </span> <span> <ui:safehtml from='{contact.getDeleteBtn}' /> </span> </div> </ui:UiBinder>
Corresponding Java file:
public class ContactCell extends AbstractCell<ClientContact> { private static ImageResourceRenderer imageRenderer = new ImageResourceRenderer(); interface MyUiRenderer extends UiRenderer { void render(SafeHtmlBuilder sb, ClientContact contact);
}
private static MyUiRenderer renderer = GWT.create(MyUiRenderer.class);
@Override public void render(com.google.gwt.cell.client.Cell.Context context, ClientContact value, SafeHtmlBuilder sb) { value.setDeleteBtn(imageRenderer.render(Resources.INSTANCE.delete())); renderer.render(sb, value);
} }
The problme is I have to add image into ClientContact model. I didn't find
other way to pass several arguments into UiRenderer. Any ideas about that?
Thank you,
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Thomas Broyer <t.bro... @gmail.com>
Date: Tue, 6 Nov 2012 00:55:52 -0800 (PST)
Local: Tues, Nov 6 2012 3:55 am
Subject: Re: GWT 2.5 Cell rendering using uiBinder + image
On Monday, November 5, 2012 10:38:09 PM UTC+1, Evgeniy Bogdanov wrote:
> On Monday, November 5, 2012 7:14:15 PM UTC+2, Thomas Broyer wrote:
>> On Monday, November 5, 2012 4:23:56 PM UTC+1, Evgeniy Bogdanov wrote:
>>> Hi, >>> Is there an any example - how to add image into Cell with UiBinder? >>> There is great example in showcase ( >>> http://gwt.google.com/samples/Showcase/Showcase.html#!CwCellList ) but >>> without uiBinder. >>> UiBinder file:
>>> <!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:with field='contact' >>> type='com.billmanager.client.model.ClientContact'/> >>> <ui:with field='res' type='com.billmanager.client.common.Resources'/> >>> <g:HTMLPanel> >>> <span><ui:text from='{contact.getDisplayName}'/></span> >>> <span><ui:text from='{contact.getDisplayEmail}'/></span> >>> <g:Image resource='{res.delete}'/> >>> </g:HTMLPanel> >>> </ui:UiBinder>
>>> Do not displays image.
>>> My java class is simple:
>>> public class ContactCell extends AbstractCell<ClientContact> {
>>> interface MyUiRenderer extends UiRenderer { >>> void render(SafeHtmlBuilder sb, ClientContact contact); >>> }
>>> private static MyUiRenderer renderer = GWT.create(MyUiRenderer.class);
>>> @Override >>> public void render(com.google.gwt.cell.client.Cell.Context context, >>> ClientContact value, SafeHtmlBuilder sb) { >>> renderer.render(sb, value); >>> }
>>> }
>>> What I thought is to get rendered element (empty) and add image as html, >>> but I don't thing it is the right way.
>> You cannot use a widget (<g:HTMLPanel>, <g:Image>) in a Cell. Replace >> those with HTML elements (<div> for instance); and for displaying an >> ImageResource in a Cell, use an ImageResourceRenderer to generate the >> SafeHtml that you can then pass as argument to the UiRenderer and use in >> the template with <ui:safehtml> (similar to <ui:text>).
> Yah, that works. > finally I was able to display image in Cell, but I don't think it is > optimal way. > So the UiBinder file:
> <!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:with field='contact' type='com.billmanager.client.model.ClientContact' > /> > <div> > <span> > <ui:text from='{contact.getDisplayName}' /> > </span> > <span> > <ui:text from='{contact.getDisplayEmail}' /> > </span> > <span> > <ui:safehtml from='{contact.getDeleteBtn}' /> > </span> > </div> > </ui:UiBinder>
> Corresponding Java file:
> public class ContactCell extends AbstractCell<ClientContact> { > private static ImageResourceRenderer imageRenderer = new > ImageResourceRenderer(); > interface MyUiRenderer extends UiRenderer { > void render(SafeHtmlBuilder sb, ClientContact contact); > }
> private static MyUiRenderer renderer = GWT.create(MyUiRenderer.class);
> @Override > public void render(com.google.gwt.cell.client.Cell.Context context, > ClientContact value, SafeHtmlBuilder sb) { > value.setDeleteBtn(imageRenderer.render(Resources.INSTANCE.delete())); > renderer.render(sb, value); > }
> }
> The problme is I have to add image into ClientContact model. I didn't find > other way to pass several arguments into UiRenderer. Any ideas about that?
Did you try defining your UiRenderer's render() method with one more
argument?
interface MyUiRenderer extends UiRenderer { void render(SafeHtmlBuilder sb, ClientContact contact, SafeHtml imageResource);
}
And of course two <ui:with> in the template.
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Evgeniy Bogdanov <ebogda... @gmail.com>
Date: Tue, 6 Nov 2012 03:32:32 -0800 (PST)
Local: Tues, Nov 6 2012 6:32 am
Subject: Re: GWT 2.5 Cell rendering using uiBinder + image
Great! Didn't know that there could be several arguments in render method and all of them are matching parameters with exact the same name in uiBinder file. Actually found in documentation: https://developers.google.com/web-toolkit/doc/latest/DevGuideUiBinder... (*UiBinder uses the names of the parameters in MyUiRenderer.render() to match the fields defined in <ui:with>** tags. Use as many as needed to render your data.*)
So finally, my UiBinder file is:
<!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:with field='contact' type='com.billmanager.client.model.ClientContact' /> <ui:with field='image' type='com.google.gwt.safehtml.shared.SafeHtml'/> <div> <span> <ui:text from='{contact.getDisplayName}' /> </span> <span> <ui:text from='{contact.getDisplayEmail}' /> </span> <span> <ui:safehtml from='{image}' /> </span> </div> </ui:UiBinder>
Java file:
public class ContactCell extends AbstractCell<ClientContact> {
private static ImageResourceRenderer imageRenderer = new ImageResourceRenderer(); interface MyUiRenderer extends UiRenderer { void render(SafeHtmlBuilder sb, ClientContact contact, SafeHtml image);
}
private static MyUiRenderer renderer = GWT.create(MyUiRenderer.class);
@Override public void render(com.google.gwt.cell.client.Cell.Context context, ClientContact value, SafeHtmlBuilder sb) { renderer.render(sb, value, imageRenderer.render(Resources.INSTANCE.delete()));
} }
My image safeHtml is second argument to be passed to uiBinder.
Thank you for help. Will be trying to handle events now.
On Tuesday, November 6, 2012 10:55:52 AM UTC+2, Thomas Broyer wrote:
> On Monday, November 5, 2012 10:38:09 PM UTC+1, Evgeniy Bogdanov wrote:
>> On Monday, November 5, 2012 7:14:15 PM UTC+2, Thomas Broyer wrote:
>>> On Monday, November 5, 2012 4:23:56 PM UTC+1, Evgeniy Bogdanov wrote:
>>>> Hi, >>>> Is there an any example - how to add image into Cell with UiBinder? >>>> There is great example in showcase ( >>>> http://gwt.google.com/samples/Showcase/Showcase.html#!CwCellList ) but >>>> without uiBinder. >>>> UiBinder file:
>>>> <!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:with field='contact' >>>> type='com.billmanager.client.model.ClientContact'/> >>>> <ui:with field='res' type='com.billmanager.client.common.Resources'/> >>>> <g:HTMLPanel> >>>> <span><ui:text from='{contact.getDisplayName}'/></span> >>>> <span><ui:text from='{contact.getDisplayEmail}'/></span> >>>> <g:Image resource='{res.delete}'/> >>>> </g:HTMLPanel> >>>> </ui:UiBinder>
>>>> Do not displays image.
>>>> My java class is simple:
>>>> public class ContactCell extends AbstractCell<ClientContact> {
>>>> interface MyUiRenderer extends UiRenderer { >>>> void render(SafeHtmlBuilder sb, ClientContact contact); >>>> }
>>>> private static MyUiRenderer renderer = GWT.create(MyUiRenderer.class);
>>>> @Override >>>> public void render(com.google.gwt.cell.client.Cell.Context context, >>>> ClientContact value, SafeHtmlBuilder sb) { >>>> renderer.render(sb, value); >>>> }
>>>> }
>>>> What I thought is to get rendered element (empty) and add image as >>>> html, but I don't thing it is the right way.
>>> You cannot use a widget (<g:HTMLPanel>, <g:Image>) in a Cell. Replace >>> those with HTML elements (<div> for instance); and for displaying an >>> ImageResource in a Cell, use an ImageResourceRenderer to generate the >>> SafeHtml that you can then pass as argument to the UiRenderer and use in >>> the template with <ui:safehtml> (similar to <ui:text>).
>> Yah, that works. >> finally I was able to display image in Cell, but I don't think it is >> optimal way. >> So the UiBinder file:
>> <!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:with field='contact' >> type='com.billmanager.client.model.ClientContact' /> >> <div> >> <span> >> <ui:text from='{contact.getDisplayName}' /> >> </span> >> <span> >> <ui:text from='{contact.getDisplayEmail}' /> >> </span> >> <span> >> <ui:safehtml from='{contact.getDeleteBtn}' /> >> </span> >> </div> >> </ui:UiBinder>
>> Corresponding Java file:
>> public class ContactCell extends AbstractCell<ClientContact> { >> private static ImageResourceRenderer imageRenderer = new >> ImageResourceRenderer(); >> interface MyUiRenderer extends UiRenderer { >> void render(SafeHtmlBuilder sb, ClientContact contact); >> }
>> private static MyUiRenderer renderer = GWT.create(MyUiRenderer.class);
>> @Override >> public void render(com.google.gwt.cell.client.Cell.Context context, >> ClientContact value, SafeHtmlBuilder sb) { >> value.setDeleteBtn(imageRenderer.render(Resources.INSTANCE.delete())); >> renderer.render(sb, value); >> }
>> }
>> The problme is I have to add image into ClientContact model. I didn't >> find other way to pass several arguments into UiRenderer. Any ideas about >> that?
> Did you try defining your UiRenderer's render() method with one more > argument?
> interface MyUiRenderer extends UiRenderer { > void render(SafeHtmlBuilder sb, ClientContact contact, SafeHtml > imageResource); > }
> And of course two <ui:with> in the template.
You must
Sign in before you can post messages.
You do not have the permission required to post.