Example usage for org.apache.wicket Component getStyle

List of usage examples for org.apache.wicket Component getStyle

Introduction

In this page you can find the example usage for org.apache.wicket Component getStyle.

Prototype

public final String getStyle() 

Source Link

Document

A convenience method to access the Sessions's style.

Usage

From source file:org.geoserver.web.GeoServerStringResourceLoader.java

License:Open Source License

/**
 * /*from ww  w.  j  a v  a2  s  .  c  o  m*/
 * @see org.apache.wicket.resource.loader.IStringResourceLoader#loadStringResource(org.apache.wicket.Component,
 *      java.lang.String)
 */
public String loadStringResource(final Component component, final String key) {
    if (component == null) {
        return null;
    }

    // The return value
    String string = null;
    Locale locale = component.getLocale();
    String style = component.getStyle();

    // 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 containmentStack = getComponentStack(component);

    // Walk the component hierarchy down from page to the component
    for (int i = containmentStack.size() - 1; (i >= 0) && (string == null); i--) {
        Class clazz = (Class) containmentStack.get(i);

        // First, try the fully qualified resource name relative to the
        // component on the path from page down.
        string = loadStringResource(clazz, key, locale, style);
    }

    // If not found, than check if a property with the 'key' provided by
    // the user can be found.
    if (string == null) {
        string = loadStringResource(null, key, locale, style);
    }

    return string;
}

From source file:org.modelibra.wicket.util.LocalizedText.java

License:Apache License

/**
 * Obtains a localized text from application properties. If the text is not
 * found, the method returns the text key. Use this method if you need
 * localized text in component constructor.
 * //from w w  w  . j av a 2  s.  com
 * @param comp
 *            the component requesting the text
 * @param textKey
 * @return text
 */
public static String getApplicationPropertiesText(Component comp, String textKey) {
    String text;
    text = classStringResourceLoader.loadStringResource(null, textKey, comp.getLocale(), comp.getStyle());
    return text;
}

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 ww  . j  a v  a2  s .co 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.extjs.util.ExtConfigResourceLoader.java

License:Apache License

protected String getCacheKey(final String key, final Component component) {
    String cacheKey = key;//from  ww w  .jav a2s.co  m
    if (component != null) {
        AppendingStringBuffer buffer = new AppendingStringBuffer(200);
        buffer.append(key);

        Component cursor = component;
        while (cursor != null) {
            buffer.append("-").append(cursor.getClass().hashCode());

            if (cursor instanceof Page) {
                break;
            }

            if (cursor.getParent() != null && !(cursor.getParent() instanceof AbstractRepeater)) {
                /*
                 * only append component id if parent is not a repeater because
                 *
                 * (a) these ids are irrelevant when generating resource cache keys
                 *
                 * (b) they cause a lot of redundant keys to be generated
                 */
                buffer.append(":").append(cursor.getId());
            }
            cursor = cursor.getParent();

        }

        buffer.append("-").append(component.getLocale());
        buffer.append("-").append(component.getStyle());
        // TODO 1.4 look if we want to properly separate getstyle/getvariation
        // for now getvariation() is rolled up into getstyle()
        // buffer.append("-").append(component.getVariation());
        cacheKey = buffer.toString();
    }
    return cacheKey;
}