Example usage for org.apache.wicket Application get

List of usage examples for org.apache.wicket Application get

Introduction

In this page you can find the example usage for org.apache.wicket Application get.

Prototype

public static Application get() 

Source Link

Document

Get Application for current thread.

Usage

From source file:com.gitblit.utils.GitBlitDiffFormatter.java

License:Apache License

/**
 * Returns a localized message string, if there is a localization; otherwise the given default value.
 *
 * @param key//from   w  w  w  . ja  v a  2s .  co m
 *            message key for the message
 * @param defaultValue
 *            to use if no localization for the message can be found
 * @return the possibly localized message
 */
private String getMsg(String key, String defaultValue) {
    if (Application.exists()) {
        Localizer localizer = Application.get().getResourceSettings().getLocalizer();
        if (localizer != null) {
            // Use getStringIgnoreSettings because we don't want exceptions here if the key is missing!
            return localizer.getStringIgnoreSettings(key, null, null, defaultValue);
        }
    }
    return defaultValue;
}

From source file:com.gitblit.wicket.pages.BasePage.java

License:Apache License

@Override
protected void onBeforeRender() {
    if (app().isDebugMode()) {
        // strip Wicket tags in debug mode for jQuery DOM traversal
        Application.get().getMarkupSettings().setStripWicketTags(true);
    }//  ww  w  .  j a v  a2s.  c  o m
    super.onBeforeRender();
}

From source file:com.gitblit.wicket.pages.BasePage.java

License:Apache License

@Override
protected void onAfterRender() {
    if (app().isDebugMode()) {
        // restore Wicket debug tags
        Application.get().getMarkupSettings().setStripWicketTags(false);
    }//from ww  w .j  a  v  a  2 s  . c o m
    super.onAfterRender();
}

From source file:com.github.ilmoeuro.hackmikkeli2016.ui.HmApplication.java

License:Open Source License

@SuppressWarnings("unchecked")
public static HmApplication get() {
    try {//from  w ww. j a  v a  2 s . c  o  m
        return (HmApplication) Application.get();
    } catch (ClassCastException ex) {
        String error = "Called get() from wrong app";
        log.error(error, ex);
        throw new RuntimeException(error, ex);
    }
}

From source file:com.github.javawithmarcus.wicket.cdi.CdiConfiguration.java

License:Apache License

protected ConfigurationParameters getApplicationParameters() {
    ConfigurationParameters params = parameters.get(Application.get().getApplicationKey());
    if (params == null) {
        try {// ww w. j  a  va 2 s  .  com
            Application app = Application.get();
            if (app.getApplicationKey() == null) {
                throw new WicketRuntimeException();
            }
            params = new ConfigurationParameters();
            parameters.put(app.getApplicationKey(), params);
        } catch (WicketRuntimeException wre) {
            throw new IllegalStateException("Application is not ready.");
        }
    }
    return params;
}

From source file:com.github.javawithmarcus.wicket.cdi.CdiConfiguration.java

License:Apache License

private void disablePropagation(ConfigurationParameters params) {
    IRequestCycleListener requestCycleListener = params.getActiveRequestCycleListener();
    if (requestCycleListener != null) {
        Application.get().getRequestCycleListeners().remove(requestCycleListener);
        params.setActiveRequestCycleListener(null);
    }/*from   w  ww. jav a  2  s .  co m*/
    IComponentOnBeforeRenderListener componentOnBeforeRenderListener = params
            .getActiveComponentOnBeforeRenderListener();
    if (componentOnBeforeRenderListener != null) {
        Application.get().getComponentPreOnBeforeRenderListeners().remove(componentOnBeforeRenderListener);
        params.setActiveComponentOnBeforeRenderListener(null);
    }
}

From source file:com.gmail.volodymyrdotsenko.jqxwicket.core.JQueryAbstractBehavior.java

License:Apache License

/**
 * Gets the {@link JQueryLibrarySettings}
 * //from w  ww.  ja  v  a  2  s . co  m
 * @return The {@link JQueryLibrarySettings} or <tt>null</tt> if
 *         {@link Application}'s {@link IJavaScriptLibrarySettings} is not
 *         an instance of {@link JQueryLibrarySettings}
 */
public static JQueryLibrarySettings getJQueryLibrarySettings() {
    if (Application.exists()
            && (Application.get().getJavaScriptLibrarySettings() instanceof JQueryLibrarySettings)) {
        return (JQueryLibrarySettings) Application.get().getJavaScriptLibrarySettings();
    }

    return null;
}

From source file:com.gmail.volodymyrdotsenko.jqxwicket.widgets.JQueryUIBehavior.java

License:Apache License

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

    if (!Application.get().getMarkupSettings().getStripWicketTags()) {
        LOG.warn(/*  w ww.  j  a va 2  s.  c om*/
                "Application > MarkupSettings > StripWicketTags: setting is currently set to false. It is highly recommended to set it to true to prevent widget misbehaviors.");
    }
}

From source file:com.google.code.jqwicket.JQContributionConfig.java

License:Apache License

public static JQContributionConfig get() {
    return Application.get().getMetaData(configKey);
}

From source file:com.google.code.jqwicket.JQContributionConfig.java

License:Apache License

public static void set(JQContributionConfig config) {
    Application.get().setMetaData(configKey, config);
}