List of usage examples for org.apache.wicket Application get
public static Application get()
From source file:org.wicketstuff.dojo11.AbstractDefaultDojoBehavior.java
License:Apache License
/** * @see org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#renderHead(org.apache.wicket.markup.html.IHeaderResponse) *//*from w w w .ja v a2 s .c o m*/ public void renderHead(Component c, IHeaderResponse response) { super.renderHead(c, response); IDojoSettings dojoSettings = ((IDojoApplication) Application.get()).getDojoSettings(); List<ResourceReference> dojoResourceReferences = dojoSettings.getDojoResourceReferences(); renderConfig(response); for (ResourceReference r : dojoResourceReferences) { response.renderJavaScriptReference(r); } registerDojoModulePathes(response, getDojoModules()); }
From source file:org.wicketstuff.dojo11.AbstractDefaultDojoBehavior.java
License:Apache License
protected void renderConfig(IHeaderResponse response) { DojoPackagedTextTemplate template = new DojoPackagedTextTemplate(AbstractDefaultDojoBehavior.class, AbstractDefaultDojoBehavior.class.getSimpleName() + ".js"); MiniMap map = new MiniMap(3); map.put("debug", RuntimeConfigurationType.DEVELOPMENT.equals(Application.get().getConfigurationType())); map.put("baseUrl", DojoSettings.get().getDojoBaseUrl()); map.put("locale", ((IDojoApplication) Application.get()).getDojoSettings().getDefaultLocale().toString() .replace('_', '-')); response.renderJavaScript(template.asString(map), template.getStaticKey()); }
From source file:org.wicketstuff.dojo11.AbstractDefaultDojoBehavior.java
License:Apache License
/** * XXX untested, using first ref might not work as expected * @return reference to the Dojo scripts. */// www . ja v a2 s . c o m public ResourceReference getDojoResourceReference() { return ((IDojoApplication) Application.get()).getDojoSettings().getDojoResourceReferences().get(0); }
From source file:org.wicketstuff.dojo11.application.DojoApplication.java
License:Apache License
/** * @return IDojoApplication or null if Applicatoin.get() doesn't implement it *//*from w ww .j a va2s . co m*/ public static IDojoApplication getDojoApplication() { Application app = Application.get(); return (app instanceof IDojoApplication) ? (IDojoApplication) app : null; }
From source file:org.wicketstuff.dojo11.application.DojoSettings.java
License:Apache License
/** * @return IDojoSettingis of current IDojoApplication * @see Application#get()//from ww w .j a v a 2 s .c o m */ public static IDojoSettings get() { return ((IDojoApplication) Application.get()).getDojoSettings(); }
From source file:org.wicketstuff.event.annotation.AnnotationEventDispatcher.java
License:Apache License
@Override public void dispatchEvent(final Object sink, final IEvent<?> event, final Component component) { AnnotationEventSink eventSink = eventSinkByClass.get(sink.getClass()); AnnotationEventDispatcherConfig config = Application.get() .getMetaData(Initializer.ANNOTATION_EVENT_DISPATCHER_CONFIG_CONTEXT_KEY); if (eventSink != null && eventSink != EMPTY_SINK && (config.getEventFilter() == null || config.getEventFilter().isAssignableFrom(event.getPayload().getClass()))) { eventSink.onEvent(sink, event);/* www . j a v a 2 s.c om*/ } }
From source file:org.wicketstuff.event.annotation.AnnotationEventSink.java
License:Apache License
public AnnotationEventSink(final Class<?> clazz) { boolean isDevelopmentMode = Application.get().getConfigurationType() == DEVELOPMENT; for (Method method : getAllMethods(clazz)) { if (method.isAnnotationPresent(OnEvent.class)) { Class<?> parameterTypes[] = method.getParameterTypes(); if (isDevelopmentMode) { checkParameters(method, parameterTypes); }// w w w . j av a 2 s. c o m if (parameterTypes.length == 1) { addOnEventMethodForType(parameterTypes[0], method); } } } }
From source file:org.wicketstuff.extjs.behavior.ExtAbstractBehavior.java
License:Apache License
/** * Render the Ext component in the page header on a DOM Ready event * /*from w w w .j a va 2 s. co m*/ * @see {@link #renderExtScript()} */ @Override public void renderHead(IHeaderResponse response) { super.renderHead(response); final IDebugSettings debugSettings = Application.get().getDebugSettings(); /* * required wicket ajax support */ response.renderJavascriptReference(WicketEventReference.INSTANCE); response.renderJavascriptReference(WicketAjaxReference.INSTANCE); if (debugSettings.isAjaxDebugModeEnabled()) { response.renderJavascriptReference( new JavascriptResourceReference(AbstractDefaultAjaxBehavior.class, "wicket-ajax-debug.js")); response.renderJavascript("wicketAjaxDebugEnable=true;", "wicket-ajax-debug-enable"); } /* * Ext resources contributions */ IHeaderContributor[] contributions = Ext.bundle().getContributions(); for (IHeaderContributor contrib : contributions) { contrib.renderHead(response); } }
From source file:org.wicketstuff.extjs.behavior.ExtComponentBehavior.java
License:Apache License
@SuppressWarnings("unchecked") private void componentTagConfig(ComponentTag tag, Config config) { List<String> attributes = new ArrayList<String>(tag.getAttributes().keySet()); for (String attr : attributes) { if (attr.startsWith("ext:")) { Object val = tag.getAttributes().get(attr); config.put(attr.substring(4), Ext.parseValue(val != null ? val.toString() : null)); if (Application.get().getMarkupSettings().getStripWicketTags()) { // remove the attribute from the markup tag.remove(attr);/* w w w. ja v a 2 s . c om*/ } } } }
From source file:org.wicketstuff.extjs.behavior.ExtDataLinkBehavior.java
License:Apache License
public void onRequest() { Request request = getComponent().getRequestCycle().getRequest(); final Query query = new Query().setFilter(request.getParameter(getParamQuery())) .setLimit(request.getParameter(getParamLimit())).setStart(request.getParameter(getParamStart())) .setSort(request.getParameter(getParamSort())) .setDirection(request.getParameter(getParamDirection())); if (log.isDebugEnabled()) { log.debug("Store request input: '{}'", query); }//from w w w.j av a2 s.c om IRequestTarget target = new IRequestTarget() { public void respond(RequestCycle requestCycle) { WebResponse webResponse = (WebResponse) requestCycle.getResponse(); XmlRenderer<T> xml = new XmlRenderer<T>(provider); // Determine encoding final String encoding = Application.get().getRequestCycleSettings().getResponseRequestEncoding(); webResponse.setCharacterEncoding(encoding); webResponse.setContentType("text/xml; charset=" + encoding); // Make sure it is not cached by a webResponse.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); webResponse.setHeader("Cache-Control", "no-cache, must-revalidate"); webResponse.setHeader("Pragma", "no-cache"); Iterator<T> choices = provider.iterator(query); xml.renderHeader(webResponse); while (choices.hasNext()) { final T item = choices.next(); xml.render(item, webResponse); } xml.renderFooter(webResponse); } public void detach(RequestCycle requestCycle) { } }; getComponent().getRequestCycle().setRequestTarget(target); }