@Override public void bind(final Component component) { super.bind(component); BootstrapBaseBehavior.addTo(component); component.add(cssClassNameAppender); }
@Override public void unbind(final Component component) { super.unbind(component); BootstrapBaseBehavior.removeFrom(component); component.remove(cssClassNameAppender); }
/* * (non-Javadoc) * * @see org.apache.wicket.behavior.Behavior#onComponentTag(org.apache.wicket.Component, * org.apache.wicket.markup.ComponentTag) */ @Override public void onComponentTag(Component component, ComponentTag tag) { super.onComponentTag(component, tag); if (!Form.class.isAssignableFrom(component.getClass())) { throw new WicketRuntimeException("This behavior is only applicable on a Form component"); } Form<?> form = (Form<?>) component; // Retrieve and set form name String formName = verifyFormName(form, tag); tag.put("onsubmit", "return yav.performCheck('" + formName + "', rules);"); // Open the Yav script (inlined JavaScript) AppendingStringBuffer buffer = new AppendingStringBuffer("<script>\n"); buffer.append("var rules=new Array();\n"); // Visit all form components and check for validators (and write the // appropriate Yav rules in the current inlined JavaScript) form.visitFormComponents(new YavFormComponentVisitor(buffer, form)); // Build the call to the yav.init with the proper form name buffer.append("function yavInit() {\n"); buffer.append(" yav.init('" + formName + "', rules);\n"); buffer.append("}\n"); // Close the Yav script buffer.append("</script>\n"); // Write the generated script into the response Response response = RequestCycle.get().getResponse(); response.write(buffer.toString()); }
@Override public void onComponentTag(Component component, ComponentTag tag) { super.onComponentTag(component, tag); IValueMap attributes = tag.getAttributes(); attributes.put("data-header-selector", "#" + header.getMarkupId()); attributes.put("data-footer-selector", "#" + footer.getMarkupId()); }
@Override public void detach(Component component) { super.detach(component); lineNumbers.detach(); cssClassNameModel.detach(); language.detach(); from.detach(); }
@Override public void onConfigure(Component component) { super.onConfigure(component); if (hasBeenRendered == false) { hasBeenRendered = true; form.visitChildren(FormComponent.class, new FormValidateVisitor()); } }
/** * Invokes a given interface on a component's behavior. * * @param rcomponent The component * @param behavior * @throws ListenerInvocationNotAllowedException when listener invocation attempted on a component * that does not allow it */ public final void invoke(final IRequestableComponent rcomponent, final Behavior behavior) { // we are in Wicket core land final Component component = (Component) rcomponent; if (!behavior.canCallListenerInterface(component)) { log.warn( "behavior not enabled; ignore call. Behavior {} at component {}", behavior, component); throw new ListenerInvocationNotAllowedException( component, behavior, "Behavior rejected interface invocation. "); } internalInvoke(component, behavior); }
@Override public void renderHead(final Component component, final IHeaderResponse response) { super.renderHead(component, response); response.render(CssHeaderItem.forReference(BootstrapPrettifyCssReference.INSTANCE)); References.renderWithFilter( Bootstrap.getSettings(), response, JavaScriptHeaderItem.forReference(BootstrapPrettifyJavaScriptReference.INSTANCE)); response.render( OnDomReadyHeaderItem.forScript(createInitializerScript(component.getMarkupId(true)))); }
@Override public void bind(Component component) { super.bind(component); if (component instanceof Form<?>) { form = (Form<?>) component; } else { form = Form.findForm(component); if (form == null) { throw new WicketRuntimeException( AjaxFormValidatingBehavior.class.getSimpleName() + " should be bound to a Form component or a component that is inside a form!"); } } }
/* * (non-Javadoc) * * @see org.apache.wicket.behavior.AbstractBehavior#renderHead(org.apache.wicket * .markup.html.IHeaderResponse) */ @Override public void renderHead(Component c, IHeaderResponse response) { super.renderHead(c, response); response.render( CssHeaderItem.forReference( new PackageResourceReference(YavBehavior.class, "style/yav-style.css"))); addJavascriptReference(response, "yav.js"); addJavascriptReference(response, "yav-config.js"); addJavascriptReference(response, "util.js"); // Add an onload contributor that will call a function which is defined // during onComponentTag method call which is processed after the head // is rendered (warning, not compliant with XHTML 1.0 Strict DTD) response.render(OnLoadHeaderItem.forScript("yavInit()")); }
@Override public void bind(Component component) { super.bind(component); component.add( new CssClassAppender( new CssClassToggleModel(BootstrapCssClass.FORM_HORIZONTAL) { @Override protected boolean isActive() { return FormStyleBehavior.this.isHorizontal(); } })); component.add( new CssClassAppender( new CssClassToggleModel(BootstrapCssClass.FORM_INLINE) { @Override protected boolean isActive() { return FormStyleBehavior.this.isInline(); } })); }
@Override public void bind(final Component component) { super.bind(component); this.component = component; this.component.setOutputMarkupId(true); if (addTitle && !isAjax()) component.add( new AttributeModifier("title", true, new Model<String>(title + "::" + content))); if (isAjax()) { this.component.add(new MootipAjaxListener(panel)); component.add( new AttributeModifier( "title", true, new Model<String>("CALLBACK:mootipAjax" + getEscapedComponentMarkupId() + "()"))); } component.add( new AttributeModifier( "class", true, new Model<String>("toolTipImg" + getEscapedComponentMarkupId()))); component.setOutputMarkupId(true); }
@Override public void onComponentTag(Component component, ComponentTag tag) { super.onComponentTag(component, tag); Components.assertTag(component, tag, "code", "pre"); }
/** {@inheritDoc} */ @Override public void onConfigure(final Component component) { super.onConfigure(component); cssClassNameModel.setObject(createCssClassNames()); }
@Override public void bind(Component component) { super.bind(component); this.component = component; component.add(getResourcePackage()); }
@Override public void beforeRender(Component component) { super.beforeRender(component); templateStrategy.load(this); write(templateStrategy.getBeforeRenderString()); }
@Override public void afterRender(Component component) { super.afterRender(component); write(templateStrategy.getAfterRenderString()); }
/** {@inheritDoc} */ @Override public void afterRender(final Component arg0) { for (final Behavior behavior : behaviors_) behavior.afterRender(arg0); }
/** {@inheritDoc} */ @Override public boolean isTemporary(final Component component) { boolean back = true; for (final Behavior behavior : behaviors_) back = back && behavior.isTemporary(component); return back; }
@Override public boolean isEnabled(final Component arg0) { boolean back = true; for (final Behavior behavior : behaviors_) back = back && behavior.isEnabled(arg0); return back; }
/** {@inheritDoc} */ @Override public boolean getStatelessHint(final Component arg0) { boolean back = true; for (final Behavior behavior : behaviors_) back = back && behavior.getStatelessHint(arg0); return back; }
@Override public void renderHead(Component component, IHeaderResponse response) { super.renderHead(component, response); response.render(JavaScriptHeaderItem.forReference(INSTANCE)); }
/** {@inheritDoc} */ @Override public void detach(final Component arg0) { for (final Behavior behavior : behaviors_) behavior.detach(arg0); }
/** {@inheritDoc} */ @Override public void bind(final Component arg0) { for (final Behavior behavior : behaviors_) behavior.bind(arg0); }
/** {@inheritDoc} */ @Override public void beforeRender(final Component arg0) { for (final Behavior behavior : behaviors_) behavior.beforeRender(arg0); }
/** {@inheritDoc} */ @Override public void onComponentTag(final Component aComponent, final ComponentTag aTag) { for (final Behavior behavior : behaviors_) behavior.onComponentTag(aComponent, aTag); }
@Override public void renderHead(Component component, IHeaderResponse headerResponse) { super.renderHead(component, headerResponse); headerResponse.renderOnLoadJavaScript( "document.getElementById('" + component.getMarkupId() + "').focus();"); }
public void exception(final Component component, final RuntimeException aException) { for (final Behavior behavior : behaviors_) behavior.onException(component, aException); }
/** {@inheritDoc} */ @Override public void renderHead(final Component component, final IHeaderResponse response) { super.renderHead(component, response); for (final Behavior behavior : behaviors_) behavior.renderHead(component, response); }