can we control what element will build in widget?

20 views
Skip to first unread message

wahaha

unread,
Oct 21, 2011, 2:19:46 AM10/21/11
to Google Web Toolkit
for example,the Label widget will be compiled as a "div" element in
browser.
can we control what kind of element will be compiled in browser?
this is to say,if we are defining a widget,then can we control the
element's kind by the source code?

i hope you can understand my poor english.

wahaha

unread,
Oct 23, 2011, 9:13:38 PM10/23/11
to Google Web Toolkit
why there is nobody knows?

Gal Dolber

unread,
Oct 23, 2011, 10:54:31 PM10/23/11
to google-we...@googlegroups.com
You cannot change the element a widget uses internally.

If you are looking for span implementations(instead of div) you can use: InlineLabel, InlineHTML

Otherwise you can create your own widgets, checkout the source code of HTML or Label, its not hard to do.

Regards

On Sun, Oct 23, 2011 at 10:13 PM, wahaha <il...@yahoo.com.cn> wrote:
why there is nobody knows?

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




--
Guit: Elegant, beautiful, modular and *production ready* gwt applications.

http://code.google.com/p/guit/




wahaha

unread,
Oct 23, 2011, 10:57:39 PM10/23/11
to Google Web Toolkit
anybody knows?

wahaha

unread,
Oct 23, 2011, 11:22:12 PM10/23/11
to Google Web Toolkit
i hava checkouted the source code of Label(and its super class),but i
hava no clue.

wahaha

unread,
Oct 24, 2011, 10:55:42 PM10/24/11
to Google Web Toolkit
help!

Patrick Julien

unread,
Oct 24, 2011, 11:02:30 PM10/24/11
to google-we...@googlegroups.com
If you want this level of control you can use Element directly or an HTMLPanel



wahaha

unread,
Oct 25, 2011, 9:35:55 AM10/25/11
to Google Web Toolkit
ok,now i have the last question:
the element compiled by gwt,what will determine its type?by gwt
compiler,or the class's source code?

On Oct 25, 11:02 am, Patrick Julien <pjul...@gmail.com> wrote:
> If you want this level of control you can use Element directly or an
> HTMLPanel
>
> http://google-web-toolkit.googlecode.com/svn/javadoc/2.4/com/google/g...

Jens

unread,
Oct 25, 2011, 9:52:32 AM10/25/11
to google-we...@googlegroups.com
http://google-web-toolkit.googlecode.com/svn/javadoc/2.4/com/google/gwt/dom/client/Element.html

Look at "direct known sub classes". There is one element type for each html tag. 

If you create a custom widget (class MyWidget extends Widget) you have to call setElement(Element e) in MyWidget's constructor. This will tell the Widget which HTML element to use as its container. A GWT Label for example calls setElement(DOM.createDiv()) whereas an InlineLabel does setElement(DOM.createSpan()).


Reply all
Reply to author
Forward
0 new messages