aspose file tools*
The moose likes GWT and the fly likes Show default text in PasswordTextBox. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » GWT
Bookmark "Show default text in PasswordTextBox." Watch "Show default text in PasswordTextBox." New topic
Author

Show default text in PasswordTextBox.

Nilesh Pat
Ranch Hand

Joined: Mar 01, 2010
Posts: 46
i want to show some default text in PasswordTextBox. first time.
when user clicks on that text box the text should get removed n then i want to allow user to enter password.
so at 1st time it should show text, n then password characters...



Regards,
Nil
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 928

why have you posted in bold, huge letters ?

You could do something simple like using a label to display a message and when it's clicked, show a password box there.

My Website: [Salvin.in] Cool your mind:[Salvin.in/painting] My Sally:[Salvin.in/sally]
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

Salvin is correct.
Nilesh you can use the button to remove the bold


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Nilesh Pat
Ranch Hand

Joined: Mar 01, 2010
Posts: 46
Maneesh Godbole wrote:Salvin is correct.
Nilesh you can use the button to remove the bold




thank you for your replay..
and it was my first time when i post this message so.
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 928

Did you try my suggested solution Nilesh ?
Nilesh Pat
Ranch Hand

Joined: Mar 01, 2010
Posts: 46
yes i tried it's demo just now.
it's good solution. but i am using rounded corner text boxes. so i have to adjust label perfectly on password text box.
hope it will work.
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 928

Nilesh Pat wrote:yes i tried it's demo just now.
it's good solution. but i am using rounded corner text boxes. so i have to adjust label perfectly on password text box.
hope it will work.


I believe there is no such thing as a rounded corner textbox,
I think you are probably wrapping up your password widget in a panel having rounded corners (mostly a decorated panel)

What I am suggesting is to wrap a label instead of a password widget in the same place and when user clicks it, change it back to password widget.
Nilesh Pat
Ranch Hand

Joined: Mar 01, 2010
Posts: 46

i have used a single image of a rounded rectangle and set it as background of password textbox in css.
and then set the text box in a cell of flex table.

can i put two widgets in same cell?? so i can set one visible. and another invisible.
i think it will..
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 928

Nilesh Pat wrote:
can i put two widgets in same cell?


In the realm of HTML thats possible, in GWT, there is just one setWidget(Widget w) method, so you cant.

However, you could make a widget that contains 2 widgets and shows one at a time.
It sounds like a candidate for the DeckPanel. Heck i would prefer the horizontal panel with one element visible at a time.

As for the rounded corner background, its probably just a style, I dont see why that could create issues.
Jay Kang
Greenhorn

Joined: Jun 23, 2010
Posts: 3
This is my first time to post:

The way I solved this problem was to extend the TextBox and create a new widget (It was because I had a promptTextBox, which I used for both password and textbox functions: the original source was from turbomanage).

*note: because I'm using this as both a TextBox and PasswordTextBox, I added a Boolean isPassword to my constructor

1st I implement keypresshandler on the widget that extends the TextBox.

2nd onkeypress, I just store what they type into a String called passwordString, and cancel the input, then insert another String called masked with the ASCII code for *.


I know of the old swap of label with textbox, but I don't like the solution because when you add styles, it kind shifts a little.
I don't know how good the solution is for security, so use it at your own risk.

Hope this helps.

Jay
David Tolioupov
Greenhorn

Joined: Nov 06, 2010
Posts: 1
in case anyone wondered here is a very simple solution:

TextBox textBox = new TextBox();
textBox.getElement().setPropertyString("type", "password");
 
jQuery in Action, 2nd edition
 
subject: Show default text in PasswordTextBox.