JSF Application's getResourceBundle() is fired when using pretty:urlbuffer

Splash Forums PrettyFaces Users JSF Application's getResourceBundle() is fired when using pretty:urlbuffer

Tagged: 

This topic contains 1 reply, has 2 voices, and was last updated by  Lincoln Baxter III 5 years, 2 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #18275

    0swald
    Participant

    In order to provide special resource bundles for my JSF application, I’ve created custom application factory and noticed that method public ResourceBundle getResourceBundle(FacesContext ctx, String name) of javax.faces.application.Application is fired for every occurrence of <pretty:urlbuffer> on the page. Is it a bug or feature?

    Here is the code to reproduce:

    public class CustomApplication extends ApplicationWrapper {
    private static final Logger logger = Logger.getLogger(CustomApplication.class.getName());

    private Application wrapped;

    public CustomApplication(Application wrapped) {
    this.wrapped = wrapped;
    }

    @Override
    public Application getWrapped() {
    return this.wrapped;
    }

    @Override
    public ResourceBundle getResourceBundle(FacesContext ctx, String name) {
    ResourceBundle result = super.getResourceBundle(ctx, name);
    if(result == null) {
    logger.info("Null bundle returned for '" + name + "'");
    return result;
    }
    logger.info("Bundle : " + name + " : " + result.getClass());
    return result;
    }
    }

    Application factory:

    public class CustomApplicationFactory extends ApplicationFactory {
    private ApplicationFactory wrapped;

    public CustomApplicationFactory(ApplicationFactory wrapped) {
    this.wrapped = wrapped;
    }

    @Override
    public ApplicationFactory getWrapped() {
    return this.wrapped;
    }

    @Override
    public Application getApplication() {
    Application application = wrapped.getApplication();
    if (application instanceof CustomApplication) return application;
    else return new CustomApplication(application);
    }

    @Override
    public void setApplication(Application application) {
    if (application instanceof CustomApplication) wrapped.setApplication(application);
    else wrapped.setApplication(new CustomApplication(application));
    }
    }

    faces-config.xml:

    <faces-config xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
    version="2.0">
    <factory>
    <application-factory>test.CustomApplicationFactory</application-factory>
    </factory>
    </faces-config>

    #22383

    It’s probably a feature of JSF. URLBuffer doesn’t do anything special with resource bundles.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

Comments are closed.