Example #1
0
  /**
   * @param hierarchy
   * @return
   */
  protected UIComponent createFilterItem(Hierarchy hierarchy) {
    String id = "filter-item-" + hierarchy.getUniqueName().hashCode();

    HtmlPanelGroup panel = new HtmlPanelGroup();
    panel.setId(id);
    panel.setLayout("block");
    panel.setStyleClass("ui-widget-header filter-item");

    CommandLink link = new CommandLink();
    link.setId(id + "-link");
    link.setValue(hierarchy.getCaption());
    link.setTitle(hierarchy.getUniqueName());

    FacesContext context = FacesContext.getCurrentInstance();
    ExpressionFactory factory = context.getApplication().getExpressionFactory();

    link.setActionExpression(
        factory.createMethodExpression(
            context.getELContext(), "#{filterHandler.show}", Void.class, new Class<?>[0]));
    link.setUpdate(":filter-form");
    link.setOncomplete("PF('filterDialog').show();");

    UIParameter parameter = new UIParameter();
    parameter.setName("hierarchy");
    parameter.setValue(hierarchy.getName());

    link.getChildren().add(parameter);

    panel.getChildren().add(link);

    CommandButton closeButton = new CommandButton();
    closeButton.setId(id + "-button");
    closeButton.setIcon("ui-icon-close");
    closeButton.setActionExpression(
        factory.createMethodExpression(
            context.getELContext(),
            "#{filterHandler.removeHierarchy}",
            Void.class,
            new Class<?>[0]));
    closeButton.setUpdate(
        ":filter-items-form,:source-tree-form,:grid-form,:editor-form:mdx-editor,:editor-form:editor-toolbar");
    closeButton.setOncomplete("onViewChanged()");

    UIParameter parameter2 = new UIParameter();
    parameter2.setName("hierarchy");
    parameter2.setValue(hierarchy.getName());

    closeButton.getChildren().add(parameter2);

    panel.getChildren().add(closeButton);

    return panel;
  }