Hello.

I've still got problems with updating a page component from AJAX, this time from a popup window.

Everything starts with a specific component for entering a date (it's a special date, so I can't use the component provided with Wicket):


public class VRCDateField extends Panel
  {
public VRCDateField (final String id, final IModelT<VRCDate> date, final VRCDateModalWindow modal)
      {
        super(id);
        final String notSet = "not set";
final Label label = new Label("label", new DefaultModelT<String>()
          {
            @Override
            public String getValue()
              {
                return DateFormat.format(date.getValue(), notSet);
              }
          });

        label.setOutputMarkupId(true);
        label.setOutputMarkupPlaceholderTag(true);
        add(modal.createOpenLink("edit", date, label));
      }
  }

public class VRCDateModalWindow extends ModalWindow
  {
    private VRCDatePage datePage;
    private Label label;
    private IModelT<VRCDate> dateModel;

    public VRCDateModalWindow (final String id, final Page page)
      {
        super(id);
        setPageCreator(new ModalWindow.PageCreator()
          {
            public Page createPage()
              {
                datePage = new VRCDatePage(VRCDateModalWindow.this);
                datePage.setDateModel(dateModel);
                return datePage;
              }
          });

        setInitialWidth(500);
        setInitialHeight(170);
        setResizable(false);
      }

    @Override
    public void close (final AjaxRequestTarget target)
      {
        super.close(target);
        target.addComponent(label);
      }

public AjaxLink createOpenLink (final String id, final IModelT<VRCDate> dateModel, final Label label)
      {
        final AjaxLink ajaxLink = new AjaxLink(id)
              {
                public void onClick (final AjaxRequestTarget target)
                  {
                    VRCDateModalWindow.this.dateModel = dateModel;
                    VRCDateModalWindow.this.label = label;
                    VRCDateModalWindow.super.show(target);
                  }
              };

        ajaxLink.add(label);

        return ajaxLink;
      }
  }

I'm not attaching the whole listing of VRCDatePage, but the key points are:


        form.add(new AjaxSubmitButton("okButton", form)
              {
protected void onSubmit (final AjaxRequestTarget target, final Form form)
                  {
                    updateDate();
                    modalWindow.close(target);
                  }
              });

where updateDate() updates the date model. Indeed the model gets correctly updated since I see the new value gets to the database. But the label doesn't get updated. I supposes everything was with the setOutputMarkupId() and eventually with the setOutputMarkupPlaceholderTag(), but clearly I'm missing something else.

--
Fabrizio Giudici, Ph.D. - Java Architect, Project Manager
Tidalwave s.a.s. - "We make Java work. Everywhere."
weblogs.java.net/blog/fabriziogiudici - www.tidalwave.it/blog
[EMAIL PROTECTED] - mobile: +39 348.150.6941


Reply via email to