Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-5635

Provide a way to modify ResourceReferenceRegistry.DefaultResourceReferenceFactory externally to be used by wicket-bootstrap-less

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.16.0
    • Fix Version/s: 7.0.0-M3, 6.17.0
    • Component/s: wicket
    • Labels:
      None

      Description

      As described in https://github.com/l0rdn1kk0n/wicket-bootstrap/issues/409#issuecomment-48505042 :

      Add

          @Override
          protected ResourceReferenceRegistry newResourceReferenceRegistry() {
              return new LessAwareRR(super.newResourceReferenceRegistry());
          }
      
          private static class LessAwareRR extends ResourceReferenceRegistry {
              private final ResourceReferenceRegistry delegate;
      
              private LessAwareRR(ResourceReferenceRegistry delegate) {
                  this.delegate = delegate;
              }
      
              @Override
              protected ResourceReference createDefaultResourceReference(ResourceReference.Key key) {
                  if (key.getName().endsWith(".less")) {
                      return new LessResourceReference(key);
                  }
                  return super.createDefaultResourceReference(key);
              }
          }
      

      to WicketApplication.java and it starts to work as desired.

      Another way to do the same is:

      @Override
          protected ResourceReferenceRegistry newResourceReferenceRegistry() {
              return new ResourceReferenceRegistry(new LessRRFactory());
          }
      
          private static class LessRRFactory extends ResourceReferenceRegistry.DefaultResourceReferenceFactory {
      
              @Override
              public ResourceReference create(ResourceReference.Key key) {
                  if (key.getName().endsWith(".less")) {
                      return new LessResourceReference(key);
                  } else {
                      return super.create(key);
                  }
              }
          }
      

      Unfortunately at the moment there is no way to do this automatically with de.agilecoders.wicket.less.BootstrapLess#install(Appllication).

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mgrigorov Martin Tzvetanov Grigorov
                Reporter:
                ceefour Hendy Irawan
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: