aspose file tools*
The moose likes GWT and the fly likes Get GWT value in Javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » GWT
Bookmark "Get GWT value in Javascript" Watch "Get GWT value in Javascript" New topic
Author

Get GWT value in Javascript

jaan bhavsar
Ranch Hand

Joined: Aug 23, 2008
Posts: 32
Hi to all,

I am trying to learn GWT,and confuse how to get GWT textbox value in javascript.
Like i am rendering GWT textbox with Div tag
<div id="tBox"/>

User enter some value in the Textbox.
I want that value in javascript?
Can anyone give me someguide line?

Thank you
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 928

1. You can use ensureDebugId method to set an id to it and then use that id in javascript to access that textbox
2. You know the parent's id is 'tBox' you can use DOM in javascript to get its child
3. Passing the textbox element in to native javascript function.


My Website: [Salvin.in] Cool your mind:[Salvin.in/painting] My Sally:[Salvin.in/sally]
jaan bhavsar
Ranch Hand

Joined: Aug 23, 2008
Posts: 32
Hi thank you for your Reply.Still i am not able to send value back to javascript.I tried with native method ,Here I am ataching code.


On Jsp I have added GWT textbox and button.


I wann text entered by user in the nameFieldContainer(which is GWT textbox) on the same Jsp Page in javascript.

salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 928

Here is what i tried and it worked:




corresponding HTML:

jaan bhavsar
Ranch Hand

Joined: Aug 23, 2008
Posts: 32
Hey salvin Thank you for your kind reply.but instead of taking value in window i wann that in $doc there i am confuse.
I already done for window.value but how to get in Javascript.

Is there any way that i can get window.value inside script variable.

Like var s = window.value;
So instead of returning value in window i want it in doc?

Can you suggest some way.?
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 928

I havent tried it yet.
is there any particular reason why you are not preferring to use the $wnd object ?
jaan bhavsar
Ranch Hand

Joined: Aug 23, 2008
Posts: 32
Yeah,I wann that value in script variable so i can use that for validation on submit buttons onclick event.
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 928

jaan bhavsar wrote:Yeah,I wann that value in script variable so i can use that for validation on submit buttons onclick event.


Yes, But isnt that precisely what my code has accomplished ?

Also you should probably do your validations in GWT itself rather than writing javascript code for it. After all thats what the technology is for !!

As a side note, I think the best way was using ensureDebugId, did you explore that option ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Get GWT value in Javascript