Exemplo n.º 1
0
  public void filterChanged(
      boolean sort, boolean requiredLabelsChanged, boolean otherLabelsChanged) {
    // Re-render what is needed
    AjaxRequestTarget art = getRequestCycle().find(AjaxRequestTarget.class);

    art.add(eventsList);

    if (requiredLabelsChanged) {
      art.add(requiredLabelsWrapper);
      art.add(sidePanel.getRequiredLabelsWrapper());
    }

    if (otherLabelsChanged) {
      art.add(sidePanel);
    }
  }
Exemplo n.º 2
0
  @Override
  protected void onInitialize() {
    super.onInitialize();

    addTabComponent();

    // Tab content
    tabContent = new WebMarkupContainer("tabContent");
    tabContent.setOutputMarkupId(true);
    add(tabContent);
    addOrReplaceTabContentPanel();

    // Required labels
    requiredLabelsWrapper = new WebMarkupContainer("requiredLabelsWrapper");
    requiredLabelsWrapper.setOutputMarkupId(true);
    add(requiredLabelsWrapper);
    requiredLabelsWrapper.add(
        new ListView<Label>("requiredLabels", filterModel.getObject().getRequiredLabels()) {
          @Override
          protected void populateItem(ListItem<Label> item) {
            final Label labelObj = item.getModelObject();

            // Add wrapping link
            AjaxLink link =
                new AjaxLink<Label>("requiredOne", item.getModel()) {
                  @Override
                  public void onClick(AjaxRequestTarget target) {
                    // Set just this link to model
                    FilterEvent filter = filterModel.getObject();
                    filter.getRequiredLabels().clear();
                    filter.getRequiredLabels().add(labelObj);

                    // Refresh
                    filterChanged(false, true, false);
                  }
                };
            link.add(
                new org.apache.wicket.markup.html.basic.Label(
                    "text", WordUtils.capitalize(labelObj.getName())));
            item.add(link);

            // Add remove link (we must do it by behavior because it is link within link)
            WebMarkupContainer removeLink = new WebMarkupContainer("removeLink");
            link.add(removeLink);
            removeLink.add(
                new AjaxEventBehavior("click") {
                  @Override
                  protected void onEvent(AjaxRequestTarget target) {
                    FilterEvent filter = filterModel.getObject();
                    filter.getRequiredLabels().remove(labelObj);

                    filterChanged(false, true, false);
                  }
                });
          }
        });

    sidePanel = new FilterEventsSidePanel("filterEvents", filterModel);
    sidePanel.setOutputMarkupId(true);
    add(sidePanel);
  }