Example usage for org.apache.wicket Component get

List of usage examples for org.apache.wicket Component get

Introduction

In this page you can find the example usage for org.apache.wicket Component get.

Prototype

@Override
public Component get(final String path) 

Source Link

Document

Gets the component at the given path.

Usage

From source file:org.projectforge.web.tree.DefaultTreeTablePanel.java

License:Open Source License

@SuppressWarnings("unchecked")
public void setEvent(final AjaxRequestTarget target, final TreeTableEvent event, final TreeTableNode node) {
    if (onSetEvent(target, event, node) == false) {
        return;//from w ww. j a v  a2s .  com
    }
    if (treeTableBody == null) {
        log.error("Oups, treeTableContainer is null. Ignoring Ajax event.");
        return;
    }
    if (log.isDebugEnabled() == true) {
        log.debug("setEvent: node=" + node.getHashId() + ", event=" + event + ", nodeStatus="
                + node.getNodeStatus());
    }
    final Component currentRow = getTreeRow(node.getHashId());
    final AbstractLink link = (AbstractLink) currentRow.get("c1:icons:folder");
    if (event == TreeTableEvent.OPEN || event == TreeTableEvent.EXPLORE) {
        final StringBuffer prependJavascriptBuf = new StringBuffer();
        {
            // Add all childs
            final Component row = getTreeRowAfter(node.getHashId());
            refresh(); // Force to rebuild tree list.
            for (final T child : getTreeTable().getDescendants(getTreeList(), (T) node)) {
                final WebMarkupContainer newRow = createTreeRow(child);
                if (row != null) {
                    prependJavascriptBuf.append(WicketAjaxUtils.insertBefore(treeTableBody.getMarkupId(),
                            row.getMarkupId(), "tr", newRow.getMarkupId()));
                } else {
                    prependJavascriptBuf.append(WicketAjaxUtils.appendChild(treeTableBody.getMarkupId(), "tr",
                            newRow.getMarkupId()));
                }
                target.add(newRow);
            }
        }
        {
            // Replace opened-folder-icon by closed-folder-icon.
            replaceFolderImage(target, link, node, prependJavascriptBuf);
        }
        final String javaScript = prependJavascriptBuf.toString();
        if (javaScript.length() > 0) {
            target.prependJavaScript(javaScript);
        }
        target.appendJavaScript("updateEvenOdd();");
    } else {
        // Remove all childs
        final StringBuffer prependJavascriptBuf = new StringBuffer();
        final Iterator<Component> it = rowRepeater.iterator();
        final List<Component> toRemove = new ArrayList<Component>();
        while (it.hasNext() == true) {
            final Component row = it.next();
            final TreeTableNode model = (TreeTableNode) row.getDefaultModelObject();
            if (node.isParentOf(model) == true) {
                prependJavascriptBuf
                        .append(WicketAjaxUtils.removeChild(treeTableBody.getMarkupId(), row.getMarkupId()));
                toRemove.add(row);
            }
        }
        for (final Component row : toRemove) {
            rowRepeater.remove(row);
        }
        {
            // Replace closed-folder-icon by opened-folder-icon.
            replaceFolderImage(target, link, node, prependJavascriptBuf);
        }
        final String javaScript = prependJavascriptBuf.toString();
        if (javaScript.length() > 0) {
            target.prependJavaScript(javaScript);
        }
        target.appendJavaScript("updateEvenOdd();");
    }
}

From source file:org.wicketstuff.poi.excel.GeneralPurposeExporter.java

License:Apache License

public void exportCell(XmlTag tag, XmlPullParser parser, Cell cell, Component gridComponent)
        throws ParseException {
    XmlTag firstMostNestedTag = tag;/*from   w  ww  . j  a  va  2  s .c  o m*/
    // find the most inner tag value
    while ((tag = parser.nextTag()).getName().equals("td") == false) {
        if (tag.isOpen() || tag.isOpenClose()) {
            firstMostNestedTag = tag;
        } else {
            break;
        }
    }
    CharSequence possibleComponentReference = firstMostNestedTag
            .getAttribute(TableParser.OutputPathBehavior.PATH_ATTRIBUTE);
    if (possibleComponentReference != null) {
        Component firstMostNestedComponent = gridComponent.getPage().get(possibleComponentReference.toString());
        // exclude auto links
        if (firstMostNestedComponent.getClass().getName().contains("ResourceReferenceAutolink")) {
            cell.setCellValue("");
            return;
        }
        // handle links
        if (firstMostNestedComponent instanceof Link) {
            Link<?> link = (Link<?>) firstMostNestedComponent;
            firstMostNestedComponent = getLinkInnerComponent(link);
            if (firstMostNestedComponent == null) {
                cell.setCellValue("");
                return;
            }
        }
        Object modelValue = firstMostNestedComponent.getDefaultModelObject();
        if (modelValue != null) {
            if (modelValue instanceof Number) {
                handleNumber(cell, (Number) modelValue);
            } else if (modelValue instanceof CharSequence) {
                cell.setCellValue(modelValue.toString());
            } else if (modelValue instanceof CharSequence) {
                cell.setCellValue(modelValue.toString());
            } else if (modelValue instanceof Boolean) {
                cell.setCellValue((Boolean) modelValue);
            } else if (modelValue instanceof Calendar) {
                handleCalendar(cell, (Calendar) modelValue);
            } else if (modelValue instanceof Date) {
                handleDate(cell, (Date) modelValue);
            } else {
                cell.setCellValue(modelValue.toString());
            }
        }
    } else {
        // simply set the first most nested tag value
        String value = parser
                .getInput(firstMostNestedTag.getPos() + firstMostNestedTag.getLength(), tag.getPos())
                .toString();
        cell.setCellValue(value);
    }
}

From source file:org.yes.cart.web.page.component.cart.ShoppingCartView.java

License:Apache License

@Override
protected void onBeforeRender() {

    final Shop shop = getCurrentShop();
    final ShoppingCart cart = getCurrentCart();
    final long shopId = shop.getShopId();
    final String lang = getLocale().getLanguage();

    final Map<String, Object> dynaCtx = new HashMap<String, Object>();
    dynaCtx.put("shop", shop);
    dynaCtx.put("shoppingCart", cart);

    final Component form = get(CART_FORM);

    final boolean cartIsNotEmpty = cart.getCartItemsCount() > 0;
    String subTotalInclude = getContentInclude(shopId, "shopping_cart_checkout_include", lang, dynaCtx);
    form.get(SUBTOTAL_INCLUDE).replaceWith(new Label(SUBTOTAL_INCLUDE, subTotalInclude)
            .setVisible(cartIsNotEmpty).setEscapeModelStrings(false));

    final boolean allowCoupons = shop
            .isAttributeValueByCodeTrue(AttributeNamesKeys.Shop.CART_UPDATE_ENABLE_COUPONS);
    String couponsInclude = getContentInclude(shopId, "shopping_cart_coupons_include", lang, dynaCtx);
    form.get(COUPON_INCLUDE).replaceWith(
            new Label(COUPON_INCLUDE, couponsInclude).setEscapeModelStrings(false).setVisible(allowCoupons));

    final boolean allowMessages = shop
            .isAttributeValueByCodeTrue(AttributeNamesKeys.Shop.CART_UPDATE_ENABLE_ORDER_MSG);
    String messageInclude = getContentInclude(shopId, "shopping_cart_message_include", lang, dynaCtx);
    form.get(ORDERMSG_INCLUDE).replaceWith(
            new Label(ORDERMSG_INCLUDE, messageInclude).setEscapeModelStrings(false).setVisible(allowMessages));

    super.onBeforeRender();
}