示例#1
0
  /** FILTER: remote control for advanced file search (open the widjet) */
  public void onActionFromToggleAdvancedSearch() {
    advancedSearchMode = !advancedSearchMode;

    Object[] ob = {advancedSearchMode};

    // componentResources.getContainer().getComponentResources().triggerEvent("eventToggleAdvancedSearchFromListDocument",	ob, null);

    // sorter component MUST BE a component of a list of document
    // we want to call the parent of list of document (index)
    componentResources
        .getContainer()
        .getComponentResources()
        .getContainer()
        .getComponentResources()
        .triggerEvent("eventToggleAdvancedSearchSorterComponent", ob, null);
  }
示例#2
0
  private void sortAndsendEvent(String propertyName) {
    List<T> listToSort = sorterPersist.getListToSort();

    if (null != sorterPersist.getComparator(propertyName)) {
      Collections.sort(listToSort, sorterPersist.getComparator(propertyName));
    }

    if (Order.DESC.equals(sorterPersist.getOrder(propertyName))) {
      Collections.reverse(listToSort);
    }

    componentResources
        .getContainer()
        .getComponentResources()
        .triggerEvent(eventName, new Object[] {listToSort}, null);
  }
  @AfterRender
  public void afterRender(MarkupWriter writer) {
    String id;
    if (elementName == null) {
      elementName = resources.getElementName();
      if (elementName == null) {
        elementName = "ul";
      }
    }
    if (draggableName == null) {
      draggableName = "div";
      if (elementName.equals("ul")) {
        draggableName = "li";
      }
    }

    Object compoment = resources.getContainer();
    if (ClientElement.class.isAssignableFrom(compoment.getClass())) {
      id = ((ClientElement) compoment).getClientId();
    } else {
      id = javaScriptSupport.allocateClientId(resources);
    }
    if (Grid.class.isAssignableFrom(compoment.getClass())) {
      elementName = "tbody";
      draggableName = "tr";
    }

    element = writer.getElement();

    element.visit(
        new Visitor() {

          public void visit(Element e) {
            if (e.getName().equals(elementName)) {
              element = e;
            }
            if (e.getName().equals("tr")) {
              String c = e.getAttribute("class");
              if (c != null) {
                e.forceAttributes("id", c.split(" ")[0]);
              }
            }
          }
        });
    String currentID = element.getAttribute("id");
    if (currentID != null) {
      id = currentID;
    } else {
      element.forceAttributes("id", id);
    }
    // element.addClassName("sortable");
    // logger.info("spec {}",spec);
    if (!spec.has("selector")) {
      spec.put("selector", String.format("#%s %s", id, draggableName));
    }
    if (!spec.has("context")) {
      ArrayEventContext aec = new ArrayEventContext(typeCoercer, defaulted(context));
      spec.put("context", String.format("/%s", contextPathEncoder.encodeIntoPath(aec)));
    }
    javaScriptSupport.addInitializerCall("jqDraggable", spec);
  }