Example usage for org.apache.wicket Component add

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

Introduction

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

Prototype

public Component add(final Behavior... behaviors) 

Source Link

Document

Adds a behavior modifier to the component.

Usage

From source file:com.googlecode.wicket.kendo.ui.widget.splitter.SplitterBehavior.java

License:Apache License

@Override
public void bind(Component component) {
    super.bind(component);

    if (this.listener.isExpandEventEnabled()) {
        this.onExpandAjaxBehavior = this.newOnExpandAjaxBehavior(this);
        component.add(this.onExpandAjaxBehavior);
    }//from   w ww. j a  v a 2  s.  c o m

    if (this.listener.isCollapseEventEnabled()) {
        this.onCollapseAjaxBehavior = this.newOnCollapseAjaxBehavior(this);
        component.add(this.onCollapseAjaxBehavior);
    }
}

From source file:com.googlecode.wicket.kendo.ui.widget.tabs.TabsBehavior.java

License:Apache License

@Override
public void bind(Component component) {
    super.bind(component);

    if (this.listener.isSelectEventEnabled()) {
        this.onSelectAjaxBehavior = this.newOnSelectAjaxBehavior(this);
        component.add(this.onSelectAjaxBehavior);
    }//  w w w.  j  a  v a  2 s.  com

    if (this.listener.isShowEventEnabled()) {
        this.onShowAjaxBehavior = this.newOnShowAjaxBehavior(this);
        component.add(this.onShowAjaxBehavior);
    }

    if (this.listener.isActivateEventEnabled()) {
        this.onActivateAjaxBehavior = this.newOnActivateAjaxBehavior(this);
        component.add(this.onActivateAjaxBehavior);
    }
}

From source file:com.googlecode.wicket.kendo.ui.widget.treeview.AjaxTreeViewBehavior.java

License:Apache License

@Override
public void bind(Component component) {
    super.bind(component);

    // behaviors //

    if (this.listener.isExpandEventEnabled()) {
        this.onExpandAjaxBehavior = this.newOnExpandAjaxBehavior(this);
        component.add(this.onExpandAjaxBehavior);
    }//from   w w w. ja va2 s  . c o m

    if (this.listener.isSelectEventEnabled()) {
        this.onSelectAjaxBehavior = this.newOnSelectAjaxBehavior(this);
        component.add(this.onSelectAjaxBehavior);
    }
}

From source file:com.googlecode.wicket.kendo.ui.widget.window.WindowBehavior.java

License:Apache License

@Override
public void bind(Component component) {
    super.bind(component);

    if (this.listener.isActionEventEnabled()) {
        this.onActionAjaxBehavior = this.newOnActionAjaxBehavior(this);
        component.add(this.onActionAjaxBehavior);
    }//from  ww w .  j  a v a 2  s  .  c  om

    if (this.listener.isCloseEventEnabled()) {
        this.onCloseAjaxBehavior = this.newOnCloseAjaxBehavior(this);
        component.add(this.onCloseAjaxBehavior);
    }
}

From source file:com.googlecode.wicketwebbeans.containers.BeanForm.java

License:Apache License

/**
 * Registers the given component with this form. This is usually called by Fields
 * (for example, see {@link AbstractField}) to add the form behavior to their
 * components./*from www  . ja  v a2 s .  c o  m*/
 * 
 * @param component
 * @param beanModel
 * @param element
 */
public void registerComponent(Component component, BeanPropertyModel beanModel, ElementMetaData element) {
    ComponentPropertyMapping mapping = new ComponentPropertyMapping(beanModel, element);
    componentPropertyMappings.add(mapping);

    // Make sure we don't register ourself twice.
    if (beanModel != null && beanModel.getBeanForm() == null) {
        // Listen for PropertyChangeEvents on this bean, if necessary.
        // TODO When do we unregister?? Maybe a WeakRef to ourself in the listener? Then listener unregisters
        // TODO if we don't exist anymore.
        element.getBeanMetaData().addPropertyChangeListener(beanModel, listener);
        beanModel.setBeanForm(this);
    }

    if (component instanceof MarkupContainer) {
        ((MarkupContainer) component).visitChildren(formVisitor);
    } else {
        component.add(new FormSubmitter("onchange"));
    }
}

From source file:com.googlecode.wicketwebbeans.datepicker.PopupDatePicker.java

License:Apache License

/**
 * Construct./*w  w w . ja  v  a2  s .  co m*/
 * 
 * @param id
 *            the component id
 * @param label
 *            the label component (may be null)
 * @param target
 *            the receiving component
 * @param settings
 *            datepicker properties
 */
public PopupDatePicker(final String id, final Component label, final Component target,
        final DatePickerSettings settings) {
    super(id, settings);

    if (target == null) {
        throw new IllegalArgumentException("Target must be not null");
    }

    target.add(new PathAttributeModifier("id", target));
    this.target = target;

    if (label != null) {
        label.add(new PathAttributeModifier("for", target));
    }
    add(triggerButton = new TriggerButton("trigger", settings.getIcon()));
}

From source file:com.googlecode.wicketwebbeans.model.BeanMetaData.java

License:Apache License

/**
 * Applies any metadata-based CSS classes for the given bean or property to the component.
 * @param bean// ww  w .jav  a2 s. c o  m
 * @param metaData
 * @param applyToComponent
 */
public void applyCss(Object bean, MetaData metaData, Component applyToComponent) {
    String css = metaData.getParameter(PARAM_CSS);

    if (!Strings.isEmpty(css)) {
        applyToComponent.add(new AttributeAppender("class", new Model<String>(css), " "));
    }

    String dynamicCssMethod = metaData.getParameter(PARAM_DYNAMIC_CSS);
    if (!Strings.isEmpty(dynamicCssMethod)) {
        Method method = null;
        String cssReturn = null;
        try {
            method = component.getClass().getMethod(dynamicCssMethod,
                    new Class[] { beanClass, metaData.getClass() });
        } catch (NoSuchMethodException ex) {
            throw new RuntimeException("dynamicCss method " + dynamicCssMethod + "(" + beanClass.getName()
                    + ", " + metaData.getClass().getName() + ") is not defined in " + component.getClass());
        } catch (SecurityException ex) {
            throw new RuntimeException("securty exception accessing dynamicCss method " + dynamicCssMethod + "("
                    + beanClass.getName() + ", " + metaData.getClass().getName() + ") in "
                    + component.getClass(), ex);
        }
        if (bean instanceof IModel) {
            bean = ((IModel) bean).getObject();
        }
        try {
            cssReturn = (String) method.invoke(component, new Object[] { bean, metaData });
        } catch (IllegalAccessException ex) {
            throw new RuntimeException("access to dynamicCss method " + dynamicCssMethod + "("
                    + beanClass.getName() + ", " + metaData.getClass().getName() + ") in "
                    + component.getClass() + " is not allowed");
        } catch (IllegalArgumentException ex) {
            throw new RuntimeException(
                    "illegal arguments for dynamicCss method " + dynamicCssMethod + "(" + beanClass.getName()
                            + ", " + metaData.getClass().getName() + ") in " + component.getClass());
        } catch (InvocationTargetException ex) {
            throw new RuntimeException("invocation to dynamicCss method " + dynamicCssMethod + "("
                    + beanClass.getName() + ", " + metaData.getClass().getName() + ") in "
                    + component.getClass() + " has thrown an exception", ex);
        }
        if (!Strings.isEmpty(cssReturn)) {
            applyToComponent.add(new AttributeAppender("class", new Model<String>(cssReturn), " "));
        }
    }
}

From source file:com.googlecode.wicketwebbeans.model.ElementMetaData.java

License:Apache License

/**
 * @param wicketId/*from   ww  w .j  a va2  s.co m*/
 * @return the Component used to render the label. If a label image was specified, this is the
 *  image, otherwise a plain-text label. 
 */
public Component getLabelComponent(String wicketId) {
    Component component;
    if (getLabelImage() == null) {
        component = new Label(wicketId, getLabel());
    } else {
        component = new ImageLabel(wicketId, getBeanMetaData().getComponent().getClass(), getLabelImage(),
                getLabel());
    }

    if (isRequired()) {
        component.add(new AttributeAppender("class", new Model<String>(CSS_REQUIRED_FIELD_CLASS), " "));
    }

    return component;
}

From source file:com.locke.library.web.utilities.focus.Focuser.java

License:Apache License

/**
 * Sets focus to the first component returned by the locator
 *//*from w  w w.  ja v a  2s .  c  o  m*/
public void setFocus() {
    final Component focus = componentSource.first();
    if (focus != null) {
        focus.add(new FocusBehavior());
    }
}

From source file:com.locke.library.web.visitors.error.ShowError.java

License:Apache License

public Object component(final Component component) {
    component.add(new AttributeModifier("class", true, new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 5439355914401726391L;

        @Override/*from   w  w w .  j  a v a 2s.com*/
        public String getObject() {
            return component.hasErrorMessage() ? errorCssClass : "";
        }
    }));
    return CONTINUE_TRAVERSAL;
}