Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stuff Enter Key pogramatically

Status
Not open for further replies.

MGoel

Programmer
Jan 26, 2002
17
US
Hi Guys,

I have a servlet which captures the login id and shows a page with several links. One of the links is to a swing based applet app, which when starts shows a form where we have to type the login id.

Since we are capturing the login id already I wanted to stuff the login id and then enter key programatically so that it simulates an action similar to what user would have had to do.

How can we do that in java,please help


Servlet->calls applet->shows a form->auto type in login id and hit enter key. This is the sequence.


Thanks in advance.

Manoj
 
Hello MGoel.
One idea: Create an automatic login function in your applet that takes in a Login id. Have it set the login textbox text to the login and call the actionPerformed method of your login submit button. Since this may be hard to access, you might want to put your existing login logic in a separate method (if you haven't already done so). This way, you can even just bypass the login gui completely with your automatic login. When you call the applet, pass a boolean value doAutomate (or something like that) along with a loginid. If doAutomate is true, call the automatic login with the supplied id. (However, I dont know how secure it to pass information to an applet like this)
Hope this helps.
 
Here's an alternative.
Use a servlet/JSP to generate the page that holds the applet. As part of the JSP/servlet put the user id/password info as a parameter within the <APPLET> tags. Then simply read the parameter in your applet.

Marcin.
Light on the fizz, so you can slap him down fast.
 
hi,

if you want to keep your code in the actionPerformed of the OK button, here is the answer:

Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new ActionEvent(btnOk,666,&quot;ok clicked&quot;))


Write this piece of code of putting the login and password in their respective fields. This would invoke the actionPerformed event for the okButton


Hope this helps








 
Hi Guys,

Thank you very much for your suggestions.

My first thought was to use a jsp page to show the applet
and as mrcincloes suggested get the login id as parameter
inside the applet,but I was hesitant to change the html file to a jsp file type.

But then I was also thinking how can i use html file still and pass login id as a param and then type in the login id
in the text box and invoke a code like juliaroberts suggested.

So I have enough idea now I think

Thanks guys once again


Regards

Manoj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top