List of usage examples for org.apache.wicket Application get
public static Application get()
From source file:org.wicketstuff.extjs.ExtBundleContribution.java
License:Open Source License
public ResourceReference EXT_ALL_JS() { String resource = Application.get().getDebugSettings().isAjaxDebugModeEnabled() ? "ext-all-debug.js" : "ext-all.js"; return get(resource); }
From source file:org.wicketstuff.extjs.tree.ExtTreeDataLinkBehavior.java
License:Apache License
public void onRequest() { Request request = getComponent().getRequestCycle().getRequest(); final String input = request.getParameter(QUERY_PARAM); if (log.isDebugEnabled()) { log.debug("Store request input: '{}'", input); }/*from w w w . java 2s.c o m*/ IRequestTarget target = new IRequestTarget() { public void respond(RequestCycle requestCycle) { WebResponse webResponse = (WebResponse) requestCycle.getResponse(); // Determine encoding final String encoding = Application.get().getRequestCycleSettings().getResponseRequestEncoding(); webResponse.setCharacterEncoding(encoding); webResponse.setContentType("text/plain; 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"); ExtTreeNode expandedNode = provider.findNode(input); Iterator<ExtTreeNode> choices = provider.iterator(expandedNode); webResponse.write("["); while (choices.hasNext()) { final ExtTreeNode item = choices.next(); expandedNode.appendChild(item); webResponse.write(item.toString()); if (choices.hasNext()) webResponse.write(","); } webResponse.write("]"); } public void detach(RequestCycle requestCycle) { } }; getComponent().getRequestCycle().setRequestTarget(target); }
From source file:org.wicketstuff.extjs.util.ExtConfigResourceLoader.java
License:Apache License
public ExtConfigResourceLoader() { // Load the properties associated with the path propertiesFactory = Application.get().getResourceSettings().getPropertiesFactory(); }
From source file:org.wicketstuff.extjs.util.ExtConfigResourceLoader.java
License:Apache License
protected void loadStringResource(final Component component, final String key, final Config config) { if (component == null) { return;/*from w w w . j a v a2 s . c o m*/ } Locale locale = component.getLocale(); String style = component.getStyle(); // The key prefix is equal to the component path relative to the // current component on the top of the stack. String prefix = Strings.replaceAll(component.getPageRelativePath(), ":", ".").toString(); // The reason why we need to create that stack is because we need to // walk it downwards starting with Page down to the Component List searchStack = getComponentStack(component); // Walk the component hierarchy down from page to the component for (int i = searchStack.size() - 1; i >= 0; i--) { Class clazz = (Class) searchStack.get(i); // First, try the fully qualified resource name relative to the // component on the path from page down. if ((prefix != null) && (prefix.length() > 0)) { loadStringResource(clazz, prefix + '.' + key, locale, style, config); prefix = Strings.afterFirst(prefix, '.'); } if (i == 0 && component.getClass().equals(clazz)) { /* * Before the last component that is supposed to contains the components default we try in the application configuration file */ loadStringResource(Application.get().getClass(), key, locale, style, config); } loadStringResource(clazz, key, locale, style, config); } }
From source file:org.wicketstuff.jamon.component.JamonProvider.java
License:Apache License
public JamonProvider(MonitorSpecification specification) { this.specification = specification; jamonRepository = Application.get().getMetaData(MonitoringRepositoryKey.KEY); setSort("label", SortOrder.ASCENDING); }
From source file:org.wicketstuff.jeeweb.ajax.JEEWebGlobalAjaxHandler.java
License:Apache License
/** * Receives ajax events and delegates them to the page which where rendered previously. *//*ww w .j a va 2 s. com*/ @Override public IResource getResource() { return new IResource() { private static final long serialVersionUID = 3070290312369930992L; @Override public void respond(Attributes attributes) { try { PageParameters parameters = attributes.getParameters(); int pageId = parameters.get("pageId").toInt(); Page page = (Page) WebSession.get().getPageManager().getPage(pageId); AjaxRequestTarget newAjaxRequestTarget = ((WebApplication) Application.get()) .newAjaxRequestTarget(page); RequestCycle.get().scheduleRequestHandlerAfterCurrent(newAjaxRequestTarget); page.send(page, Broadcast.BREADTH, new JEEWebGlobalAjaxEvent(newAjaxRequestTarget, parameters, RequestCycle.get().getRequest().getPostParameters())); } catch (Exception e) { LOGGER.error("Error while processing the ajax request", e); } } }; }
From source file:org.wicketstuff.jquery.JQueryBehavior.java
License:Apache License
@Override public void renderHead(Component component, IHeaderResponse response) { try {//from www . j av a 2s . c om super.renderHead(component, response); if (getIncludeJQueryJS(response)) { response.render(JavaScriptHeaderItem.forReference(JQueryResourceReference.get())); if (Application.get().usesDevelopmentConfig()) { response.render(JavaScriptHeaderItem.forReference(JQUERY_DEBUG_JS)); } } CharSequence script = getOnReadyScript(); if (script != null && script.length() > 0) { StringBuilder builder = new StringBuilder(); builder.append("<script type=\"text/javascript\">\n$(document).ready(function(){\n"); builder.append(script); builder.append("\n});</script>"); response.render(StringHeaderItem.forString(builder)); } } catch (RuntimeException exc) { throw exc; } catch (Exception exc) { throw new RuntimeException("wrap: " + exc.getMessage(), exc); } }
From source file:org.wicketstuff.js.ext.ExtObservableHelper.java
License:Apache License
static JSONObject renderResources(final IExtObservable extObservable, Class<?> baseClass) throws JSONException { JSONObject resources = new JSONObject(); IPropertiesFactory propertiesFactory = Application.get().getResourceSettings().getPropertiesFactory(); Session session = Session.get();/*from w ww . j a v a 2 s . co m*/ String style = session.getStyle(); Locale locale = session.getLocale(); Class<?> clazz = extObservable.getClass(); while (clazz != baseClass) { String path = clazz.getName().replace('.', '/'); ResourceNameIterator iter = new ResourceNameIterator(path, style, null, locale, null, false); while (iter.hasNext()) { String newPath = iter.next(); final Properties props = propertiesFactory.load(clazz, newPath); if (props != null) { ValueMap all = props.getAll(); for (Map.Entry<String, Object> entry : all.entrySet()) { if (!resources.has(entry.getKey())) { resources.put(entry.getKey(), entry.getValue()); } } } } clazz = clazz.getSuperclass(); } return resources; }
From source file:org.wicketstuff.js.ext.util.ExtJsonRequestTarget.java
License:Apache License
@Override public void respond(IRequestCycle requestCycle) { WebResponse r = (WebResponse) requestCycle.getResponse(); // Determine encoding final String encoding = Application.get().getRequestCycleSettings().getResponseRequestEncoding(); r.setContentType("application/json;charset=" + encoding); // Make sure it is not cached r.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); r.setHeader("Cache-Control", "no-cache, must-revalidate"); r.setHeader("Pragma", "no-cache"); r.write(responseJson.toString());//from w w w . ja va 2 s. c o m }
From source file:org.wicketstuff.js.ext.util.ExtResourcesHeaderItem.java
License:Apache License
@Override public List<? extends HeaderItem> getProvidedResources() { List<HeaderItem> resources = new ArrayList<HeaderItem>(); String extBase, extAll, patchedExtAjax, extAdapt; if (Application.get().getConfigurationType().equals(RuntimeConfigurationType.DEVELOPMENT)) { extBase = ExtBundle.EXT_BASE_DEBUG; extAll = ExtBundle.EXT_ALL_DEBUG; patchedExtAjax = ExtWicketAdapterBundle.PATCHED_EXT_BASE_AJAX; extAdapt = ExtWicketAdapterBundle.EXT_WICKET_ADAPTER_DEBUG; } else {//from w w w . ja v a2 s .c o m extBase = ExtBundle.EXT_BASE_DEPLOY; extAll = ExtBundle.EXT_ALL_DEPLOY; patchedExtAjax = ExtWicketAdapterBundle.PATCHED_EXT_BASE_AJAX; extAdapt = ExtWicketAdapterBundle.EXT_WICKET_ADAPTER_DEPLOY; } resources.add(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(ExtBundle.class, extBase))); resources.add(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(ExtBundle.class, extAll))); resources.add(JavaScriptHeaderItem .forReference(new JavaScriptResourceReference(ExtBundle.class, patchedExtAjax))); resources .add(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(ExtBundle.class, extAdapt))); return resources; }