Change /javax.faces.resource prefix of resource URLs

后端 未结 2 564
予麋鹿
予麋鹿 2020-12-18 15:03

When I use

 

or



        
2条回答
  •  -上瘾入骨i
    2020-12-18 15:45

    This is possible. The code on FacesServlet looks like this:

        ResourceHandler resourceHandler = facesContext.getApplication().getResourceHandler();
    
        // Call ResourceHandler.isResourceRequest(javax.faces.context.FacesContext).
        if (resourceHandler.isResourceRequest(facesContext))
        {
            // If this returns true call ResourceHandler.handleResourceRequest(javax.faces.context.FacesContext).
            resourceHandler.handleResourceRequest(facesContext);
        }
    

    The default implementation uses ResourceHandler#RESOURCE_IDENTIFIER constant by default, but it is technically possible to write a ResourceHandlerWrapper that uses other structure. The only problem is the wrapper should implement everything, and you can't delegate anything to the default algorithm. You can reuse the code on MyFaces Shared but remember this are internals, so use something like maven shade plugin or a hard copy to relocate the package name.

    What is not possible is change it for existing ResourceHandler implementations (for example, components that use a custom ResourceHandler implementation like t:captcha or other variants), because all those are tied to the constant.

    Anyway, I created MFCOMMONS-36 to add this to the extended ResourceHandler implementation that is being added on MyFaces Commons.

提交回复
热议问题