Dynamically building up a page.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Thursday, December 6, 2007 02:28 PM

Hello, I'm trying to dynamically adding labels and textboxes to a gridpanel. the labels get their text from a db. So i don't know how many labels i'll have to put in that gridpanel so i can't hardcode it. Anyway i tried doing it simple like this. for(ExtraVeld extra: extras) { final Label label1 = new Label(); label1.setText(extra.getWaarde()); labels.add(label1); TextArea text = new TextArea(); parent.getChildren().add(label1); parent.getChildren().add(text); } That worked for the amount of labels i need. BUT the text in the labels is always the same. I think I know why that could be, probably it just uses the same object of Label over and over. Now    More>>

Hello,

I'm trying to dynamically adding labels and textboxes to a gridpanel.
the labels get their text from a db. So i don't know how many labels i'll have to put in that gridpanel so i can't hardcode it. Anyway i tried doing it simple like this.

for(ExtraVeld extra: extras)
{
final Label label1 = new Label();
label1.setText(extra.getWaarde());
labels.add(label1);
TextArea text = new TextArea();

parent.getChildren().add(label1);
parent.getChildren().add(text);
}

That worked for the amount of labels i need. BUT the text in the labels is always the same. I think I know why that could be, probably it just uses the same object of Label over and over. Now I have no idea how to make it use/create a new object of Label everytime the for will loop.

Tnx in Advance

Tristan.

   <<Less
About | Sitemap | Contact