Uploaded image for project: 'Tapestry 5'
  1. Tapestry 5
  2. TAP5-2659

Direct instantiation of ComponentResourceSelector should be replaced with delegation to ComponentRequestSelectorAnalyzer

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 5.6.2, 5.7.0
    • Component/s: tapestry-core
    • Labels:
      None

      Description

      Some implementation methods in tapestry core still use direct instantiation of ComponentResourceSelector instead of delegating to ComponentRequestSelectorAnalyzer, namely:

      in ComponentMessageSourceImpl.java

       

      public Messages getMessages(ComponentModel componentModel, Locale locale)
      {
          return getMessages(componentModel, new ComponentResourceSelector(locale));
      }
      public Messages getApplicationCatalog(Locale locale)
      {
          return messagesSource.getMessages(appCatalogBundle, new ComponentResourceSelector(locale));
      } 
      

      in ComponentTemplateSourceImpl.java

       

      public ComponentTemplate getTemplate(ComponentModel componentModel, Locale locale)
      {
          return getTemplate(componentModel, new ComponentResourceSelector(locale));
      }

      Which makes it impossible to use axes with message bundles and component templates.

       

      Default implementation of ComponentRequestSelectorAnalyzer interface uses ThreadLocale instead of directly passed Locale instance. To workaround this above methods may temporarily set passed locale into ThreadLocal and restore original value after `#buildSelectorForRequest` is returned, i.e.:

      public Messages getMessages(ComponentModel componentModel, Locale locale)
      {
          Locale original = threadLocale.getLocale();
      
          try
          {
              threadLocale.setLocale(locale);
      
              return getMessages(componentModel, analyzer.buildSelectorForRequest());
          }
          finally
          {
              threadLocale.setLocale(original);
          }
      }

      {{}}

       

        Attachments

          Activity

            People

            • Assignee:
              thiagohp Thiago Henrique De Paula Figueiredo
              Reporter:
              dmitrygusev Dmitry Gusev
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: