• 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
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

GWT - Capture values of dynamically created components

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a GWT page with 2 text boxes, 1 hyperlink and 1 button initially (on page load).
When I click on the hyperlink, I add another text box (dynamically without refreshing the page).

Now when I click the button, I need to capture the values that lie in all the three text boxes. How can I do it?

I am desparately looking for some help on this area because I am working on a critical project and badly need help on this.

--
Thanks!
Bhavin
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What have you tried so far, and where are you stuck.

All you need to do is when you create the new text box, hold a reference to it in your code. When the user clicks the button, you can then obtain the text from the text box and process accordingly.
 
Bhavin B Parekh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you, Maneesh.

Yes, I have tried that already but the issue with my scenario is that when I set the Id for any widget, I want to set with some dynamic value rather than just any other Id. And GWT is not allowing me to make use of the reflection API; ccan you please tell me whether GWT allows the usage of Reflection API or not?

--
Thanks!
Bhavin
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Reflection! In this scenario? Why? Sounds like an overkill.
Why do you want to play with the id even?

Something this simple is all you really need
 
Bhavin B Parekh
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have pasted my code below.



As you can see, the construction of the entire section is happening inside a for-loop, hence, it is all dynamic. Now, if I just say getText(), I doubt if it'll work out. Can you please provide me some alternate solution to this?
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I will still recommend what I suggested in my first reply. Did you try it out?
 
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
You have posted a huge code thats irrelevant to your actual question.


Here is what i see:



Well my friend, this is not GWT issue, But it's rather a Java 'issue'. Your code logic is to reuse a field variable to point to another object
So Its obvious that you have lost its reference. (Or in simple words, 'txt' will point to the LAST textbox in the loop)

Considering that you are adding some kind of panel on the fly ... you can consider an approach like:



I hope I have solved / correctly understood your problem
 
reply
    Bookmark Topic Watch Topic
  • New Topic