Win a copy of Event Streams in Action this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

How to load input textfields dynamically in my web page using Spring roo?

Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys!

I'm very new with spring roo. I managed to convert my Spring Roo to GWT, and did some CRUD stuffs through the tutorials provided. However, I got stuck with this problem:

1) I have defined fields that I should retrieve from the DB (e.g. Username, Employee Number, etc..)
2) I want to load these fields in the UI of my web app dynamically:

2.1) Retrieve the fields from the DB
2.2) Iterate them
2.3) Show them in my page as "Label of the Field <e.g. Username>" : <Input Textfield>

3) The client user can then enter values and save them somewhere.

These are my entities, generated via Spring roo:

And the transaction entity that's supposed to store my dynamic fields

I am kinda lost on where/what to begin. Hope your expertise can help me. Thank you in advance!
Posts: 11445
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Disclaimer: I dont work on Roo. My opinion is purely from a programming perspective

Decide what kind of visual layout you need for the fields. Consider the fact that the number of fields is not know. This will decide what container/parent/widget you should be using to display the fields.
Iterate over the Set. Extract individual MyField objects. Create and maintain another collection for the TextBox.
For every field object, add the label+TextBox to the UI. Dont forget to add the TextBox to the collection too.
Repeat for all objects in your set.

For saving, the index of the TextBox in its collection will correspond to the index of the MyField in the Set.
Get the user vales from the TextBox, invoke getter on MyField. Repeat for all TextBox instances.
Now your set contains MyField objects with updated values.
Process as required.
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!