为什么 Wicket ListView 仅将更改分配给最后一行?

发布于 2024-11-26 12:11:00 字数 1594 浏览 1 评论 0原文

1) 我正在使用 ListView 从数据库填充一些 2 个标签。该表有 100 行,因此我得到 100 个 。这很好用。

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) 一个标签带有超链接,并打开一个弹出窗口,我可以从中选择标签 2 的可能值。弹出窗口完美打开。

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) 在弹出窗口中,可能的值带有超链接。单击它会关闭弹出窗口并将可能的值发送到主页。这工作正常...我想。

4)使用以下方法将新值分配给标签 2:

target.addComponent(selectView);

这就是我陷入困境的地方。 Wicket 应该更改同一行上的标签(至少我认为),但它正在更新最后一行的标签 2。

我做错了什么?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一曲琵琶半遮面シ 2024-12-03 12:11:00

我还没有遍历您选择行的逻辑,但我相信我对类似问题的解决方案会对您有所帮助。问题是,当 AJAX 请求传入时,ListView 不会自动单独刷新每一行。我使用的解决方案是 将整个 shebang 包装在 WebMarkupContainer 中。完成后,所有内容都将根据请求重新生成。

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.

弃爱 2024-12-03 12:11:00

我认为帖子中缺少代码的相关部分......
就像:

  • 为 ModalWindow设置 gclOrg 的位置
  • ,为 ModalWindow 设置 selParentGclOrg 的地方

从我所看到的来看,我会把赌注押在 populateItem 的问题上,在其他问题之后运行你的类中的代码...大部分代码将在构造函数时间或 onBeforeRender 上运行,populateItem 有时会在渲染过程中被调用...但这只是一个疯狂的猜测。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文