使用对话框模式更新wicket面板

时间:2013-04-10 09:41:51

标签: java wicket

我有一个面板,应使用对话模块中的数据进行更新。在Panels构造函数中,我有一个数据模型,它应该填充面板中的组件。

Panel构造函数如下所示:

      public MyPanel(String id, final MyDataMOdel aDataModel) {
    super(id);
            ....
          }

该面板在我的页面中添加为:

       MyDataModel myDataModel = new MyDataModel();
    MyPanel myPanel = new MyPanel("myPanel", myDataModel);

在Open Dialog setWindowClosedCallback方法中,我有更新的DataModel

            myModal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback()
            {
                private static final long serialVersionUID = -1746088901018629567L;

                public void onClose(AjaxRequestTarget target)
                {
                    update myDataModel here
                    Got the updated datamodel here (I can see that it is updated)
                      target.add(myPanel)
                 ....

这样,我看不到面板中的组件得到更新。

2 个答案:

答案 0 :(得分:0)

目前,我解决了以下问题:

    remove(myPanel);
    myPanel = new MyPanel("myPanel", myUpdatedDataModel);
    myPanel.setOutputMarkupId(true);
    add(myPanel);
    target.appendJavaScript("window.location.reload()");

答案 1 :(得分:0)

我不确定你的MyDataModel()是什么。但是你可以使用共享的wicket模型。

          Model<YourDataObjectToShare> dataObjectToSHare = new Model<YourDataObjectToShare>()
    {
        private static final long serialVersionUID = -6394439155356911110L;

        @Override
        public YourDataObjectToShare getObject()
        {
            return ... The Updated Shared data here
        }
    };

然后将dataObjectToSHare传递给面板参数

this