Package org.apache.wicket

Examples of org.apache.wicket.Localizer$ClassMetaDatabase


      if (Strings.isEmpty(prefix))
      {
        prefix = "";
      }

      final Localizer localizer = formComponent.getLocalizer();

      String resource = prefix + getId() + "." + key;

      // First use the parent for resolving so that
      // form1.textfield1.Required can be used.
View Full Code Here


   *
   * @return The string
   */
  public final String getString()
  {
    final Localizer localizer = getLocalizer();

    // Make sure we have a localizer before commencing
    if (getLocalizer() == null)
    {
      if (component != null)
      {
        setLocalizer(component.getLocalizer());
      }
      else
      {
        throw new IllegalStateException("No localizer has been set");
      }
    }

    // Make sure we have the locale
    if (locale == null)
    {
      locale = Session.get().getLocale();
    }

    String value = null;
    // Substitute any parameters if necessary
    Object[] parameters = getParameters();
    if (parameters == null)
    {
      // Get the string resource, doing any property substitutions as part
      // of the get operation
      value = localizer.getString(getResourceKey(), component, model, defaultValue);
      if (value == null)
      {
        value = defaultValue;
      }
    }
    else
    {
      // Get the string resource, doing not any property substitutions
      // that has to be done later after MessageFormat
      value = localizer.getString(getResourceKey(), component, null, defaultValue);
      if (value == null)
      {
        value = defaultValue;
      }
      if (value != null)
      {
        // Build the real parameters
        Object[] realParams = new Object[parameters.length];
        for (int i = 0; i < parameters.length; i++)
        {
          if (parameters[i] instanceof IModel)
          {
            realParams[i] = ((IModel)parameters[i]).getObject();
          }
          else if (model != null && parameters[i] instanceof String)
          {
            realParams[i] = PropertyVariableInterpolator.interpolate(
              (String)parameters[i], model.getObject());
          }
          else
          {
            realParams[i] = parameters[i];
          }
        }

        if (model != null)
        {
          // First escape all substitute properties so that message format doesn't try to
          // parse that.
          value = Strings.replaceAll(value, "${", "$'{'").toString();
        }
        // Apply the parameters
        final MessageFormat format = new MessageFormat(value, component != null
          ? component.getLocale() : locale);
        value = format.format(realParams);

        if (model != null)
        {
          // un escape the substitute properties
          value = Strings.replaceAll(value, "$'{'", "${").toString();
          // now substitute the properties
          value = localizer.substitutePropertyExpressions(component, value, model);
        }
      }
    }

    // Return the string resource
View Full Code Here

   */
  public Localizer getLocalizer()
  {
    if (localizer == null)
    {
      localizer = new Localizer();
    }
    return localizer;
  }
View Full Code Here

   */
  public Localizer getLocalizer()
  {
    if (localizer == null)
    {
      localizer = new Localizer();
    }
    return localizer;
  }
View Full Code Here

      // Use the following log4j config for detailed logging on the property resolution
      // process
      // log4j.logger.org.apache.wicket.resource.loader=DEBUG
      // log4j.logger.org.apache.wicket.Localizer=DEBUG

      final Localizer localizer = formComponent.getLocalizer();

      // retrieve prefix that will be used to construct message keys
      String prefix = formComponent.getValidatorKeyPrefix();
      String message = null;
View Full Code Here

  }

  private String getString(Component component)
  {

    final Localizer localizer = getLocalizer();
    final Locale locale;
    if (component != null)
    {
      locale = component.getLocale();
    }
    else
    {
      locale = Session.exists() ? Session.get().getLocale() : Locale.getDefault();
    }

    String value;

    // Substitute any parameters if necessary
    Object[] parameters = getParameters();
    if (parameters == null || parameters.length == 0)
    {
      // Get the string resource, doing any property substitutions as part
      // of the get operation
      value = localizer.getString(getResourceKey(), component, model, defaultValue);
      if (value == null)
      {
        value = defaultValue;
      }
    }
    else
    {
      // Get the string resource, doing not any property substitutions
      // that has to be done later after MessageFormat
      value = localizer.getString(getResourceKey(), component, null, defaultValue);
      if (value == null)
      {
        value = defaultValue;
      }
      if (value != null)
      {
        // Build the real parameters
        Object[] realParams = new Object[parameters.length];
        for (int i = 0; i < parameters.length; i++)
        {
          if (parameters[i] instanceof IModel<?>)
          {
            realParams[i] = ((IModel<?>)parameters[i]).getObject();
          }
          else if (model != null && parameters[i] instanceof String)
          {
            realParams[i] = PropertyVariableInterpolator.interpolate(
              (String)parameters[i], model.getObject());
          }
          else
          {
            realParams[i] = parameters[i];
          }
        }

        // Escape all single quotes outside {..}
        if (value.indexOf('\'') != -1)
        {
          value = escapeQuotes(value);
        }

        if (model != null)
        {
          // First escape all substitute properties so that message format doesn't try to
          // parse that.
          value = Strings.replaceAll(value, "${", "$'{'").toString();
        }

        // Apply the parameters
        final MessageFormat format = new MessageFormat(value, locale);
        value = format.format(realParams);

        if (model != null)
        {
          // un escape the substitute properties
          value = Strings.replaceAll(value, "$'{'", "${").toString();
          // now substitute the properties
          value = localizer.substitutePropertyExpressions(component, value, model);
        }
      }
    }

    // Return the string resource
View Full Code Here

   */
  public Localizer getLocalizer()
  {
    if (localizer == null)
    {
      localizer = new Localizer();
    }
    return localizer;
  }
View Full Code Here

  }

  private String getString(final Component component)
  {

    final Localizer localizer = getLocalizer();

    String value;

    // Substitute any parameters if necessary
    Object[] parameters = getParameters();
    if (parameters == null || parameters.length == 0)
    {
      // Get the string resource, doing any property substitutions as part
      // of the get operation
      value = localizer.getString(getResourceKey(), component, model, defaultValue);
      if (value == null)
      {
        value = defaultValue;
      }
    }
    else
    {
      // Get the string resource, doing not any property substitutions
      // that has to be done later after MessageFormat
      value = localizer.getString(getResourceKey(), component, null, defaultValue);
      if (value == null)
      {
        value = defaultValue;
      }
      if (value != null)
      {
        // Build the real parameters
        Object[] realParams = new Object[parameters.length];
        for (int i = 0; i < parameters.length; i++)
        {
          if (parameters[i] instanceof IModel<?>)
          {
            realParams[i] = ((IModel<?>)parameters[i]).getObject();
          }
          else if (model != null && parameters[i] instanceof String)
          {
            realParams[i] = localizer.substitutePropertyExpressions(component,
              (String)parameters[i], model);
          }
          else
          {
            realParams[i] = parameters[i];
          }
        }

        // Escape all single quotes outside {..}
        if (value.indexOf('\'') != -1)
        {
          value = escapeQuotes(value);
        }

        if (model != null)
        {
          // First escape all substitute properties so that message format doesn't try to
          // parse that.
          value = Strings.replaceAll(value, "${", "$'{'").toString();
        }

        // Apply the parameters
        final MessageFormat format = new MessageFormat(value, getLocale());
        value = format.format(realParams);

        if (model != null)
        {
          // un escape the substitute properties
          value = Strings.replaceAll(value, "$'{'", "${").toString();
          // now substitute the properties
          value = localizer.substitutePropertyExpressions(component, value, model);
        }
      }
    }

    // Return the string resource
View Full Code Here

      // Use the following log4j config for detailed logging on the property resolution
      // process
      // log4j.logger.org.apache.wicket.resource.loader=DEBUG
      // log4j.logger.org.apache.wicket.Localizer=DEBUG

      final Localizer localizer = formComponent.getLocalizer();

      // retrieve prefix that will be used to construct message keys
      String prefix = formComponent.getValidatorKeyPrefix();
      String message = null;
View Full Code Here

   */
  public Localizer getLocalizer()
  {
    if (localizer == null)
    {
      localizer = new Localizer();
    }
    return localizer;
  }
View Full Code Here

TOP

Related Classes of org.apache.wicket.Localizer$ClassMetaDatabase

Copyright © 2018 www.massapicom. 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.