Verona integration with java configuration

Post Reply
iljkr
Posts: 21
Joined: 30 Dec 2013, 20:52

02 Sep 2019, 17:00

I'm trying to integrate Verona into my webapplication.

My webapp don't have a web.xml and the relative configurations are in a java class that extends org.springframework.web.servlet.support.AbstractDispatcherServletInitializer.

I'm porting the configuration from the verona web.xml into my method

Code: Select all

	@Override
	public void onStartup(ServletContext servletContext) throws ServletException {
		super.onStartup(servletContext);
		
		servletContext.addListener(new SessionListener());
		
		String facesConfigFiles = "/WEB-INF/common/faces-config.xml";
		
		servletContext.setInitParameter("javax.faces.CONFIG_FILES", facesConfigFiles);
		
		servletContext.setInitParameter("javax.faces.DEFAULT_SUFFIX", ".xhtml");
		
		servletContext.setInitParameter("primefaces.THEME", "verona-amber");
	   
		servletContext.setInitParameter("javax.faces.STATE_SAVING_METHOD", "server");

	   servletContext.setInitParameter("javax.faces.PROJECT_STAGE", "Development");
	   
	   servletContext.setInitParameter("primefaces.FONT_AWESOME", "true");
   
	   servletContext.setInitParameter("javax.faces.FACELETS_LIBRARIES", "/WEB-INF/primefaces-verona.taglib.xml");
	   
	   
	   servletContext.setInitParameter("logbackConfigLocation", "classpath:/my/path/logback.xml");
	   
	   servletContext.setInitParameter("facelets.SKIP_COMMENTS", "true");
	   
		
	   EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD);
		
		ServletRegistration.Dynamic facesServlet = servletContext.addServlet("Faces Servlet", new FacesServlet());
        facesServlet.addMapping("*.xhtml");
        
        
        FileUploadFilter fileUploadFilter = new FileUploadFilter();
        FilterRegistration.Dynamic primeFacesFUF = servletContext.addFilter("PrimeFaces FileUpload Filter", fileUploadFilter);
        primeFacesFUF.addMappingForServletNames(dispatcherTypes, false, "Faces Servlet");
		
		
		DelegatingFilterProxy filter = new DelegatingFilterProxy("springSecurityFilterChain");
		filter.setContextAttribute("org.springframework.web.servlet.FrameworkServlet.CONTEXT.dispatcher");
		servletContext.addFilter("springSecurityFilterChain", filter).addMappingForUrlPatterns(null, false, "/*");
		
		DeviceResolverRequestFilter deviceResolverHandlerFilter = new DeviceResolverRequestFilter();
		servletContext.addFilter("deviceResolverHandlerFilter", deviceResolverHandlerFilter).addMappingForUrlPatterns(null, false, "/*");
		
		
		CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
        characterEncodingFilter.setEncoding("UTF-8");
        characterEncodingFilter.setForceEncoding(true);
        FilterRegistration.Dynamic characterEncoding = servletContext.addFilter("characterEncoding", characterEncodingFilter);
        characterEncoding.addMappingForUrlPatterns(dispatcherTypes, true, "/*");
        
//        
//        <filter>
//        <filter-name>Character Encoding Filter</filter-name>
//        <filter-class>org.primefaces.verona.filter.CharacterEncodingFilter</filter-class>
//    </filter>
//    <filter-mapping>
//        <filter-name>Character Encoding Filter</filter-name>
//        <servlet-name>Faces Servlet</servlet-name>
//    </filter-mapping>

 HOW TO DO THIS ?
        
        
	}
For example

<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>verona-#{guestPreferences.theme}</param-value>
</context-param>
<context-param>
<param-name>primefaces.FONT_AWESOME</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/primefaces-verona.taglib.xml</param-value>
</context-param>

become:

servletContext.setInitParameter("primefaces.THEME", "verona-amber");
servletContext.setInitParameter("primefaces.FONT_AWESOME", "true");
servletContext.setInitParameter("javax.faces.FACELETS_LIBRARIES", "/WEB-INF/primefaces-verona.taglib.xml");

My problem is I don't know how to mapping this:
<filter>
<filter-name>Character Encoding Filter</filter-name>
<filter-class>org.primefaces.verona.filter.CharacterEncodingFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Character Encoding Filter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
javax.faces-2.2.8 | primefaces-5.2 | tomcat 7

aragorn
Posts: 3718
Joined: 29 Jun 2013, 12:38

12 Sep 2019, 15:51

Hi,

Code: Select all

Character Encoding Filter
org.primefaces.verona.filter.CharacterEncodingFilter
- You don't have to add it. It is for settings of UTF-8 encoding.

A sample issue;
http://stackoverflow.com/questions/1762 ... s-to-utf-8

You can remove it.

Best Regards,

Post Reply

Return to “Verona - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest