List of usage examples for org.apache.wicket Component getPage
@Override public final Page getPage()
From source file:org.efaps.ui.wicket.components.split.AjaxStorePositionBehavior.java
License:Apache License
/** * @see org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#getCallbackScript() * @param _component Component the script belongs to * @return script/* w w w . j a v a2 s. c o m*/ */ @Override public CharSequence getCallbackScript(final Component _component) { final String borderPanelId = ((ContentContainerPage) _component.getPage()).getBorderPanelId(); final String leftPanelId = _component.getMarkupId(true); final String topPanelId = ((SidePanel) _component).getTopPanelId(); final StringBuilder js = new StringBuilder().append("require([\"dojo/ready\", \"dijit/registry\"]);\n"); if (this.vertical) { js.append("var storePosV = ").append(getCallbackFunction( CallbackParameter.explicit(AjaxStorePositionBehavior.PARAMETER_VERTICALPOSITION))); } js.append("var storePosH = ") .append(getCallbackFunction( CallbackParameter.explicit(AjaxStorePositionBehavior.PARAMETER_HORIZONTALPOSITION))) .append("dojo.ready(function() {\n").append("var bp = dijit.registry.byId(\"").append(borderPanelId) .append("\");\n").append("var lp = dijit.registry.byId(\"").append(leftPanelId).append("\");\n") .append("var hs = bp.getSplitter(\"leading\");\n"); if (this.vertical) { js.append("var tp = dijit.registry.byId(\"").append(topPanelId).append("\");\n") .append("var vs = lp.getSplitter(\"top\");\n"); } js.append(" dojo.connect(hs, \"onOpen\",function(pane){\n").append("storePosH(pane.domNode.clientWidth);") .append("});\n").append(" dojo.connect(hs, \"onClosed\",function(pane){\n") .append("storePosH(pane.domNode.clientWidth);").append("});\n") .append(" dojo.connect(hs, \"_stopDrag\",function(e){\n") .append("storePosH(lp.domNode.clientWidth);").append("});\n"); if (this.vertical) { js.append(" dojo.connect(vs, \"onOpen\",function(pane){\n") .append("storePosV(pane.domNode.clientHeight);").append("});\n") .append(" dojo.connect(vs, \"onClosed\",function(pane){\n") .append("storePosV(pane.domNode.clientHeight);").append("});\n") .append(" dojo.connect(vs, \"_stopDrag\",function(e){\n") .append("storePosV(tp.domNode.clientHeight);").append("});\n"); } js.append("});"); return js.toString(); }
From source file:org.hippoecm.frontend.behaviors.OnEnterAjaxBehavior.java
License:Apache License
/** * Don't call super since WicketAjax is loaded by Yui webapp behavior * TODO: webapp ajax is configurable, maybe check here and still load it. *//*from w w w . ja v a 2 s .c om*/ @Override public final void renderHead(Component component, IHeaderResponse response) { super.renderHead(component, response); if (_helper == null) { Page page = component.getPage(); for (Behavior behavior : page.getBehaviors()) { if (behavior instanceof IYuiManager) { _helper = ((IYuiManager) behavior).newContext(); _helper.addJavascriptReference( new JavaScriptResourceReference(OnEnterAjaxBehavior.class, "enter.js")); break; } } if (_helper == null) { throw new IllegalStateException( "Page has no yui manager behavior, unable to register module dependencies."); } _helper.addOnDomLoad("new Hippo.EnterHandler('" + component.getMarkupId() + "')"); } _helper.renderHead(response); }
From source file:org.hippoecm.frontend.plugins.yui.AbstractYuiAjaxBehavior.java
License:Apache License
/** * Don't call super since WicketAjax is loaded by Yui webapp behavior * TODO: webapp ajax is configurable, maybe check here and still load it. *//* ww w .j a v a2s.c o m*/ @Override public void renderHead(Component component, IHeaderResponse response) { if (context == null) { Page page = component.getPage(); for (Behavior behavior : page.getBehaviors()) { if (behavior instanceof IYuiManager) { context = ((IYuiManager) behavior).newContext(); addHeaderContribution(context); break; } } if (context == null) { throw new IllegalStateException( "Page has no yui manager behavior, unable to register module dependencies."); } } onRenderHead(response); context.renderHead(response); }
From source file:org.hippoecm.frontend.plugins.yui.AbstractYuiBehavior.java
License:Apache License
/** * Don't call super since WicketAjax is loaded by Yui webapp behavior * TODO: webapp ajax is configurable, maybe check here and still load it. *///w w w . j a v a 2s .c o m @Override public final void renderHead(Component component, IHeaderResponse response) { if (context == null) { Page page = component.getPage(); for (Behavior behavior : page.getBehaviors()) { if (behavior instanceof IYuiManager) { context = ((IYuiManager) behavior).newContext(); addHeaderContribution(context); break; } } if (context == null) { throw new IllegalStateException( "Page has no yui manager behavior, unable to register module dependencies."); } } context.renderHead(response); onRenderHead(response); }
From source file:org.obiba.onyx.webapp.base.panel.MenuBuilder.java
License:Open Source License
@SuppressWarnings({ "unchecked", "rawtypes" }) private static AbstractLink getLink(String linkId, Class<? extends Page> pageClass, PageParameters parameters, String labelId, String label, Component component) { AbstractLink link;/*from ww w .j a v a 2 s . c o m*/ if (pageClass == null) link = new BookmarkablePageLink(linkId, component.getPage().getClass(), component.getPage().getPageParameters()); else if (parameters != null) link = new BookmarkablePageLink(linkId, pageClass, parameters); else link = new BookmarkablePageLink(linkId, pageClass); link.add(new Label(labelId, new StringResourceModel(label, component, null))); link.add(new MenuItemSelectionBehavior()); return link; }
From source file:org.objetdirect.wickext.core.events.WickextEventBehavior.java
License:Open Source License
@Override public void bind(Component component) { super.bind(component); this.component = component; component.getPage().add(new HeaderContributor(new CoreJavaScriptHeaderContributor())); }
From source file:org.opensingular.form.wicket.util.WicketFormProcessing.java
License:Apache License
public static void onFieldProcess(Component component, AjaxRequestTarget target, IModel<? extends SInstance> model) { SInstance instance;// w ww . j a va2 s. co m if (model == null || (instance = model.getObject()) == null || target == null) { return; } validate(component, target, instance); Set<SInstance> updatedInstances = evaluateUpdateListenersAndCollect(instance); EventCollector eventCollector = new EventCollector(); updateAttributes(instance, eventCollector); Set<SInstance> instancesToUpdateComponents = new HashSet<>(); instancesToUpdateComponents.addAll(eventCollector.getEventSourceInstances()); instancesToUpdateComponents.addAll(updatedInstances); updateBoundComponents(component.getPage(), target, instancesToUpdateComponents); }
From source file:org.opensingular.lib.wicket.util.util.WicketUtils.java
License:Apache License
public static void clearMessagesForComponent(Component component) { new FeedbackCollector(component.getPage()) .collect(message -> Objects.equals(message.getReporter(), component)).stream() .forEach(it -> it.markRendered()); }
From source file:org.projectforge.web.wicket.WicketUtils.java
License:Open Source License
/** * Calls {@link Component#setResponsePage(Page)}. If the responseItem is an instance of a Page then setResponse for this Page is called * otherwise setResponse is called via {@link Component#getPage()}. * @param component//from www.j a v a 2 s . c o m * @param responseItem Page or Component. */ public static void setResponsePage(final Component component, final Component responseItem) { if (responseItem instanceof Page) { component.setResponsePage((Page) responseItem); } else { component.setResponsePage(responseItem.getPage()); } }
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. ja v a2s .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); } }