Wicket
  1. Wicket
  2. WICKET-990

Localizer complains about component not being added to the page when the component is a page

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.0-beta3
    • Fix Version/s: 1.3.0-beta4
    • Component/s: wicket
    • Labels:
      None

      Description

      In Localizer, this code doesn't correctly detect when the component is actually a page:

      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 = (component != null && null != component.findParent(Page.class));
      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);
      }

      This results in excessive warnings in the logs when attempting to use the Page as the root for a resource lookup. This is such a common idiom that it should be accounted for. For instance, the javadoc description for StringResourceModel includes examples of using the page as the component for the resource lookup.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Igor Vaynberg
            Reporter:
            Mark Sandori
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development