Very good point. Didn't think about that. Thanks, I've solved my problem! Original Message: ----------------- From: Martin Makundi martin.maku...@koodaripalvelut.com Date: Mon, 4 Jan 2010 18:19:46 +0200 To: users@wicket.apache.org Subject: Re: ListView Behavior
Hi! Why do you need to count items? You can refer to different components using their markupid. ** Martin 2010/1/4 wic...@geofflancaster.com <wic...@geofflancaster.com>: > Due to Wicket handling things in a weird order, would anyone mind giving me > a hand in solving this issue? > > When I create a ListView, populateItem() is called for each item in the > list which is passed into the ListView and then it goes back and creates > the Label named "chart". The problem is that I'm trying to keep a counter > on each chart item being created so I can render javascript on the > component. See below for code and output (for a test with 2 items being > passed in via the list in the ListView Constructor). > > ------------ BEGIN CODE-------------- > > addOrReplace(new ListView<StringBuilder>("graphTable",xml){ > �...@override > protected void populateItem(ListItem<StringBuilder> item){ > StringBuilder sb = (StringBuilder) item.getModelObject(); > System.out.println("populating item number - "+divNum); > Label chart = new Label("chart",new Model()){ > �...@override > protected void onComponentTag(final ComponentTag tag){ > System.out.println("adding componentTag with id="+divNum); > super.onComponentTag(tag); > tag.put("id", "chart_"+ divNum); > } > }; > > item.add(chart); > > Label script = new Label("script",parseJS(sb,"chart_"+divNum)); > > script.setRenderBodyOnly(true); > script.setEscapeModelStrings(false); > > item.add(script); > divNum++; > } > }); > > ---------- END CODE --------- > > > ---------- BEGIN OUTPUT ------------- > > populating item number - 0 > populating item number - 1 > adding componentTag with id=2 > adding componentTag with id=2 > > ----------- END OUTPUT -------------- > > I need the componentTag to correspond with the numbers listed after > "populating item number" > > for example, I need the output to show something to the affect of: > > populating item number - 0 > adding componentTag with id=0 > populating item number - 1 > adding componentTag with id=1 > > or > > populating item number - 0 > populating item number - 1 > adding componentTag with id=0 > adding componentTag with id=1 > > > > > -------------------------------------------------------------------- > mail2web.com - Microsoft® Exchange solutions from a leading provider - > http://link.mail2web.com/Business/Exchange > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -------------------------------------------------------------------- mail2web.com - Microsoft® Exchange solutions from a leading provider - http://link.mail2web.com/Business/Exchange --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org