开发者

Why does a Wicket ListView assign changes to the last row only?

1) I am using a ListView to populate some 2 labels from database. The table has 100 rows so I get 100 <TD>s. This works fine.

this.selectView = new PageableListView("selectedBG", new PropertyModel(this, "selectedList"), 10) {

private static final long serialVersionUID = 1L;

@Override
protected void populateItem(final ListItem item){
    selParentGclOrg = new Label("selParGclOrgId", new PropertyModel(gclOrg, "parentGclOrgId"));
    selParentGclOrg.setOutputMarkupId(true);

    final AjaxLink ajl = new AjaxLink("clickMe"){
        public void onClick(AjaxRequestTarget target){
            chilgGcl = gclOrg.getGclOrgId();
        开发者_运维百科    selectPopUp.show(target);
        }
    };

    ajl.add(selParentGclOrg);
    final Label lblGclOrg = new Label("selGclOrgId", Integer.valueOf(gclOrg.getGclOrgId()).toString());

    item.add(ajl);
    item.add(lblGclOrg);
}
}

2) One label is hyperlinked and opens a popup window from which I can select possible values for label 2. The popup window opens perfectly.

selectPopUp = new select_popUP("showModal",container){
        @Override
        public void onSelect(AjaxRequestTarget target, int gclOrgId){
            selParentGclOrg.setModelObject(Integer.toString(gclOrgId));
            target.addComponent(selectView);
            close(target);
        }

        @Override
        public void onCancel(AjaxRequestTarget target){
            close(target);
        }
    };

3) In the popup window, possible values are hyperlinked. Clicking on it closes the popup window and sends the possible value to the main page. This works ok... I think.

4) The new value is assigned to Label 2 using:

target.addComponent(selectView);

This is where I am getting stuck. Wicket is supposed to change the label on the same row (at least, I think) but it's updating the Label 2 of the last row.

What am I doing wrong?


I haven't run through your logic for selecting rows, but I believe my solution to a similar issue will help you. The problem is that ListViews don't automatically refresh each of their rows individually when AJAX requests come in. The solution I used was to wrap the whole shebang in a WebMarkupContainer. When that's done, everything will get regenerated on the request.


I think the relevant parts of your code are missing from the post... Like:

  • where gclOrg is set
  • where selParentGclOrgis set for the ModalWindow

Judging from what I can see, I would put my bet on an issue with populateItem beeing run way after the rest of the code in your class... Most of your code will be run on constructor time or onBeforeRender, populateItem will be called sometimes during rendering... But that's just a wild guess.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜