Unable to set "name" property for TextBox

331 views
Skip to first unread message

mercurysteam

unread,
Feb 4, 2008, 7:44:53 PM2/4/08
to Google Web Toolkit
I'm trying to set the name property for a TextBox by calling
TextBox.setName(name) but it doesn't seem to work. Following is the
code I've used:

TextBox box = new TextBox();
box.setName("element3245");
box.setText("This is a box");

When I try to add a custom property to the element by calling the
following code, the custom property is added properly:

DOM.setElementProperty(box.getElement(), "blah", "hola");

For some reason DOM.setElementProperty(box.getElement(), "name",
"hola"); doesn't do anything...

Has anyone ever come across this problem before?

Thanks!

Ian Bambury

unread,
Feb 4, 2008, 10:56:31 PM2/4/08
to Google-We...@googlegroups.com
What makes you say it doesn't do anything? What do you expect it to do? How are you checking whether it has been done or not?

mercurysteam

unread,
Feb 4, 2008, 11:58:33 PM2/4/08
to Google Web Toolkit
You are right it is set! But you can only verify this by calling
DOM.getElementProperty(textbox.getElement(), "name"); within Java.

The reason I said it was not set is because I looked at the output of
the HTML (in debug mode). The HTML is always missing the "name"
attribute, e.g.:

<INPUT class=gwt-TextBox customProp=customPro value=some text
__eventBits="8065">

I was expecting something like:

<INPUT class=gwt-TextBox customProp=customPro name=element3245
value=some text __eventBits="8065">

I'm trying to set the value of this textbox to something else from a
NONE GWT page (external HTML page). In order to do so I need to know
the "name" or "id" of this textbox thus I can use JavaScript from the
external HTML to rest the value of the textbox. This never worked for
me using the "name" attribute because it is NOT presented on the
output HTML. I've managed to use the "id" property so the problem is
solved.


Jason Essington

unread,
Feb 5, 2008, 10:51:29 AM2/5/08
to Google-We...@googlegroups.com
There does seem to be a difference in some cases between
setElementProperty, and setElementAttribute

I have also noticed that DOM inspectors don't necessarily show the
name attribute if it is added at a time other than element creation,
however it does appear to exist when a form element is submitted to
the server.

-jason

Reply all
Reply to author
Forward
0 new messages