Examples of IResourceSettings


Examples of org.apache.wicket.settings.IResourceSettings

   */
  public String getString(final String key, final Component component, final IModel<?> model,
    final Locale locale, final String style, final String defaultValue)
    throws MissingResourceException
  {
    final IResourceSettings resourceSettings = Application.get().getResourceSettings();

    String value = getStringIgnoreSettings(key, component, model, locale, style, null);
    if ((value == null) && (defaultValue != null))
    {
      // Resource not found, so handle missing resources based on
      // application configuration and try the default value
      if (resourceSettings.getUseDefaultOnMissingResource())
      {
        value = defaultValue;

        // If a property value has been found, or a default value was given,
        // than replace the placeholder and we are done
        if (value != null)
        {
          return substitutePropertyExpressions(component, value, model);
        }
      }
    }

    // If a property value has been found, or a default value was given,
    // than replace the placeholder and we are done
    if (value != null)
    {
      return value;
    }

    if (resourceSettings.getThrowExceptionOnMissingResource())
    {
      AppendingStringBuffer message = new AppendingStringBuffer("Unable to find property: '");
      message.append(key);
      message.append("'");

View Full Code Here

Examples of org.apache.wicket.settings.IResourceSettings

    super.commonBefore();
  }

  @Test
  public void check() {
    IResourceSettings settings = tester.getApplication().getResourceSettings();
    assertThat(settings.getDefaultCacheDuration(), is(equalTo(expected)));
  }
View Full Code Here

Examples of org.apache.wicket.settings.IResourceSettings

      properties = propertiesCache.get(path);
    }

    if (properties == null)
    {
      IResourceSettings resourceSettings = Application.get().getResourceSettings();

      Iterator<IPropertiesLoader> iter = propertiesLoader.iterator();
      while ((properties == null) && iter.hasNext())
      {
        IPropertiesLoader loader = iter.next();
        String fullPath = path + loader.getFileExtension();

        // If not in the cache than try to load properties
        IResourceStream resourceStream = resourceSettings.getResourceStreamLocator()
          .locate(clazz, fullPath);
        if (resourceStream == null)
        {
          continue;
        }

        // Watch file modifications
        final IModificationWatcher watcher = resourceSettings.getResourceWatcher(true);
        if (watcher != null)
        {
          addToWatcher(path, resourceStream, watcher);
        }
View Full Code Here

Examples of org.apache.wicket.settings.IResourceSettings

   */
  public String getString(final String key, final Component component, final IModel<?> model,
    final Locale locale, final String style, final String defaultValue)
    throws MissingResourceException
  {
    final IResourceSettings resourceSettings = Application.get().getResourceSettings();

    String value = getStringIgnoreSettings(key, component, model, locale, style, null);
    if ((value == null) && (defaultValue != null))
    {
      // Resource not found, so handle missing resources based on
      // application configuration and try the default value
      if (resourceSettings.getUseDefaultOnMissingResource())
      {
        value = defaultValue;

        // If a property value has been found, or a default value was given,
        // than replace the placeholder and we are done
        if (value != null)
        {
          return substitutePropertyExpressions(component, value, model);
        }
      }
    }

    // If a property value has been found, or a default value was given,
    // than replace the placeholder and we are done
    if (value != null)
    {
      return value;
    }

    if (resourceSettings.getThrowExceptionOnMissingResource())
    {
      AppendingStringBuffer message = new AppendingStringBuffer("Unable to find property: '");
      message.append(key);
      message.append("'");

View Full Code Here

Examples of org.apache.wicket.settings.IResourceSettings

   *             If resource not found and configuration dictates that exception should be thrown
   */
  public String getString(final String key, final Component component, final IModel<?> model,
    final String defaultValue) throws MissingResourceException
  {
    final IResourceSettings resourceSettings = Application.get().getResourceSettings();

    String value = getStringIgnoreSettings(key, component, model, null);
    if ((value == null) && (defaultValue != null))
    {
      // Resource not found, so handle missing resources based on
      // application configuration and try the default value
      if (resourceSettings.getUseDefaultOnMissingResource())
      {
        value = defaultValue;
      }
    }

    // If a property value has been found, or a default value was given,
    // than replace the placeholder and we are done
    if (value != null)
    {
      return substitutePropertyExpressions(component, value, model);
    }

    if (resourceSettings.getThrowExceptionOnMissingResource())
    {
      AppendingStringBuffer message = new AppendingStringBuffer("Unable to find property: '");
      message.append(key);
      message.append("'");

View Full Code Here

Examples of org.apache.wicket.settings.IResourceSettings

  public void required()
  {
    JavaxInjectTestComponent component = newTestComponent("id");

    // get the lazy proxy
    IResourceSettings nonExisting = component.getNonExisting();

    try
    {
      // call any method on the lazy proxy
      nonExisting.getCachingStrategy();
      fail("Fields annotated with @javax.inject.Inject are required!");
    }
    catch (ConfigurationException cx)
    {
      Message message = cx.getErrorMessages().iterator().next();
View Full Code Here

Examples of org.apache.wicket.settings.IResourceSettings

      }
    };
    WebApplication wicketApplication = new DummyWebApplication() {
      protected void init()
      {
        IResourceSettings resourceSettings = getResourceSettings();
        resourceSettings.setResourceFinder(customResourceFinder);
      }
    };
    new MockWebApplication(wicketApplication, "foo");
    IResourceFinder resourceFinderInApplication = Application.get().getResourceSettings().getResourceFinder();
    Assert.assertSame(customResourceFinder, resourceFinderInApplication);
View Full Code Here

Examples of org.apache.wicket.settings.IResourceSettings

   *             If resource not found and configuration dictates that exception should be thrown
   */
  public String getString(final String key, final Component component, final IModel model,
    final String defaultValue) throws MissingResourceException
  {
    final IResourceSettings resourceSettings = Application.get().getResourceSettings();

    boolean addedToPage = false;
    if (component != null)
    {
      if ((component instanceof Page) || null != component.findParent(Page.class))
      {
        addedToPage = true;
      }

      if (!addedToPage)
      {
        logger.warn(
          "Tried to retrieve a localized string for a component that has not yet been added to the page. "
            + "This can sometimes lead to an invalid or no localized resource returned. "
            + "Make sure you are not calling Component#getString() inside your Component's constructor. "
            + "Offending component: {}", component);
      }
    }


    String cacheKey = null;
    String string = null;

    // If this component is not yet added to page we do not want to check
    // cache as we can generate an invalid cache key
    if ((cache != null) && addedToPage)
    {
      cacheKey = getCacheKey(key, component);
    }

    // Value not found are cached as well (value = null)
    if ((cacheKey != null) && cache.containsKey(cacheKey))
    {
      string = getFromCache(cacheKey);
    }
    else
    {
      // Iterate over all registered string resource loaders until the
      // property has been found

      Iterator iter = resourceSettings.getStringResourceLoaders().iterator();
      while (iter.hasNext())
      {
        IStringResourceLoader loader = (IStringResourceLoader)iter.next();
        string = loader.loadStringResource(component, key);
        if (string != null)
        {
          break;
        }
      }

      // Cache the result incl null if not found
      if (cacheKey != null)
      {
        putIntoCache(cacheKey, string);
      }
    }

    if ((string == null) && (defaultValue != null))
    {
      // Resource not found, so handle missing resources based on
      // application configuration and try the default value
      if (resourceSettings.getUseDefaultOnMissingResource())
      {
        string = defaultValue;
      }
    }

    // If a property value has been found, or a default value was given,
    // than replace the placeholder and we are done
    if (string != null)
    {
      return substitutePropertyExpressions(component, string, model);
    }

    if (resourceSettings.getThrowExceptionOnMissingResource())
    {
      AppendingStringBuffer message = new AppendingStringBuffer("Unable to find resource: " +
        key);
      if (component != null)
      {
View Full Code Here

Examples of org.apache.wicket.settings.IResourceSettings

   */
  public String getString(final String key, final Component component, final IModel<?> model,
    final Locale locale, final String style, final String defaultValue)
    throws MissingResourceException
  {
    final IResourceSettings resourceSettings = Application.get().getResourceSettings();

    String value = getStringIgnoreSettings(key, component, model, locale, style, null);
    if ((value == null) && (defaultValue != null))
    {
      // Resource not found, so handle missing resources based on
      // application configuration and try the default value
      if (resourceSettings.getUseDefaultOnMissingResource())
      {
        value = defaultValue;

        // If a property value has been found, or a default value was given,
        // than replace the placeholder and we are done
        if (value != null)
        {
          return substitutePropertyExpressions(component, value, model);
        }
      }
    }

    // If a property value has been found, or a default value was given,
    // than replace the placeholder and we are done
    if (value != null)
    {
      return value;
    }

    if (resourceSettings.getThrowExceptionOnMissingResource())
    {
      AppendingStringBuffer message = new AppendingStringBuffer("Unable to find property: '");
      message.append(key);
      message.append("'");

View Full Code Here

Examples of org.apache.wicket.settings.IResourceSettings

   * @throws Exception
   */
  @Test
  public void testExceptionOnMissingResourceDefaultValue() throws Exception
  {
    IResourceSettings settings = new ResourceSettings(new MockApplication());
    Assert.assertTrue("exceptionOnMissingResource should default to true",
      settings.getThrowExceptionOnMissingResource());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.