Dynamically convert between TextBox and PasswordTextBox

137 views
Skip to first unread message

Ben Munge

unread,
Jul 29, 2011, 4:05:56 PM7/29/11
to Google Web Toolkit
I have a requirement to turn some financial fields into masked fields
and I wanted to use the password input type to simplify the logic. I
need to be able to change a TextBox to a PasswordTextBox and have it
change the value in the box to circles without affecting the value or
style of the element. I'm having trouble finding a good way to do this
as TextBox does not let you modify the type property. Any advice/help
would be greatly appreciated.

Thanks!

Gal Dolber

unread,
Jul 29, 2011, 4:17:24 PM7/29/11
to google-we...@googlegroups.com
From a code and css points of view they are exactly the same. You should be able to change from TextBox to PasswordTextBox without changing anything.


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




Ben Munge

unread,
Jul 29, 2011, 4:43:22 PM7/29/11
to Google Web Toolkit
Yes you should be able to, however you are not. There is no
constructor for PasswordTextBox that takes in a TextBox. I ended up
just using getElement and setting the attribute directly.

textBox.getElement().setAttribute("type", "password");

Ben Imp

unread,
Jul 29, 2011, 4:49:14 PM7/29/11
to google-we...@googlegroups.com
An resourceful user could probably still watch the value, via a javascript debugging tool like Firebug, as its being set into those input fields.  Assuming you are still sending the financial data to the client from the server, of course.

This is also assuming the reason you want to use a password field is to hide the value from the user.  If that isn't the use case, then ignore my ramblings.

-Ben
Reply all
Reply to author
Forward
Message has been deleted
0 new messages