version of css and js

Forum rules
Please note that response time for technical support is within 3-5 business days.
Post Reply
spadovan
Posts: 178
Joined: 05 Jun 2013, 12:04

08 May 2017, 08:44

Hi,

is it possible to load css and js of ultima specifying version number like primefaces does ?

Code: Select all

  .../javax.faces.resource/components.js.xhtml?ln=primefaces&v=6.1
In this way new version of ultima resources could be loaded without affecting client (and its cache).

Thanks

Simone
Primefaces 12.0.2, Wildfly 24.0.1, JDK 11

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

11 May 2017, 12:01

I think you can override PrimeResource.java and PrimeResourceHandler.java by yourself.
https://github.com/primefaces/primeface ... ource.java
https://github.com/primefaces/primeface ... ndler.java

spadovan
Posts: 178
Joined: 05 Jun 2013, 12:04

11 May 2017, 12:06

I've created a custom ResourceHandler

Code: Select all

public class UltimaResourceHandler extends ResourceHandlerWrapper {

	private ResourceHandler wrapped;

	public UltimaResourceHandler(ResourceHandler wrapped) {
		this.wrapped = wrapped;
	}

	@Override
	public Resource createResource(String resourceName) {
		return createResource(resourceName, null, null);
	}

	@Override
	public Resource createResource(String resourceName, String libraryName) {
		return createResource(resourceName, libraryName, null);
	}

	@Override
	public Resource createResource(String resourceName, String libraryName, String contentType) {
		final Resource resource = super.createResource(resourceName, libraryName, contentType);

		if (resource == null) {
			return null;
		}

		return new ResourceWrapper() {

			@Override
			public String getRequestPath() {
				if (resource != null && resource.getLibraryName() != null && resource.getLibraryName().equalsIgnoreCase("ultima-layout")) {
					return super.getRequestPath() + "&v=" + getClass().getPackage().getImplementationVersion();
				}
				return super.getRequestPath();
			}

			@Override
			public Resource getWrapped() {
				return resource;
			}
		};
	}

	@Override
	public ResourceHandler getWrapped() {
		return wrapped;
	}

}
and i've added it in the faces-config.xml

Code: Select all

	<application>
		<resource-handler>it.bolzano.comune.common.UltimaResourceHandler</resource-handler>
...

Is it correct ? thanks

Simone
Primefaces 12.0.2, Wildfly 24.0.1, JDK 11

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

14 May 2017, 22:15

Yes, but I think you can use;
public class UltimaResourceHandler extends PrimeResourceHandler
instead of
public class UltimaResourceHandler extends ResourceHandlerWrapper

Post Reply

Return to “Ultima - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 7 guests