• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Get GWT value in Javascript

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 2911
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jordan Josh
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2911
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is what i tried and it worked:




corresponding HTML:

 
Jordan Josh
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Bartender
Posts: 2911
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I havent tried it yet.
is there any particular reason why you are not preferring to use the $wnd object ?
 
Jordan Josh
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah,I wann that value in script variable so i can use that for validation on submit buttons onclick event.
 
salvin francis
Bartender
Posts: 2911
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ?
 
Did Steve tell you that? Fuh - Steve. Just look at this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic