Recent Notes

Displaying keyword search results 1 - 10
Created by Fang on January 06, 2014 12:22:17    Last update: January 06, 2014 12:22:17
Add <mvc:default-servlet-handler/> to the spring servlet config ( spring-servlet.xml ?) so that static files can be handled by the default servlet handler. This is a full configuration file for example: <?xml version="1.0" encoding="UTF-8"?> <beans x...
Created by Fang on August 28, 2013 20:37:17    Last update: August 28, 2013 20:37:17
The default extension for JSF facelet files is .xhtml, which looks so out-of-date these days. I wanted to change the extension from .xhtml to .html, to make it look more modern, even though I still use JSF xhtml in reality. This didn't work ( web.xml ): <servlet-mapping> <servlet-name>Faces Ser... Using the servlet-mapping config without the context-param works, given that the actual file extensions are still .xhtml . But the caveat is, if you request the .xhtml file directly, it will be sent to the browser unprocessed. This worked: <servlet-mapping> <servlet-name>Faces Ser... I'm using myfaces 2.1.11.
Created by Dr. Xi on March 21, 2013 19:47:46    Last update: March 22, 2013 12:30:27
It's normal practice to import types from an external xsd file in WSDL like this: <wsdl:types> <xsd:schema xmlns:xsd="htt... When you use <dynamic-wsdl> and have Commons XMLSchema on the class path, Spring-WS inlines the xsd in the wsdl. But that doesn't happen when you use <static-wsdl> . You can define a SimpleXsdSchema bean to expose the xsd: <?xml version="1.0" encoding="UTF-8"?> <beans x... where the bean id "hello" should match the schemaLocation attribute in the WSDL (without the .xsd suffix). But note that the SimpleXsdSchema does not inline the xsd. It only makes the xsd available via an HTTP URL. Alternatively, you can simply put the xsd file under the content directory of the webapp (just link any CSS or JavaScript). Anyway, that's a lot of manual...
Created by Fang on January 04, 2013 09:02:44    Last update: January 04, 2013 09:02:44
This snippet sets system properties from Maven surefire test plugin. This is useful when you want to set logging (for example, log4j) properties based on Maven project properties. Example that sets system property testlog.dir : <plugins> <plugin> <groupId>org.apach... Example log4j.xml that uses system property testlog.dir : <?xml version="1.0" encoding="UTF-8"?> <!DOCTYP...
Created by Dr. Xi on April 19, 2012 10:10:08    Last update: April 19, 2012 10:11:06
The default servlet for Tomcat is declared in $CATALINA_HOME/conf/web.xml : <servlet> <servlet-name>default</servle... Therefore, static content is rendered by the default configuration unless you override it with your own definitions. If you want to allow directory listing, just change the listing parameter to true : <init-param> <param-name>listings</para... Change the welcome-file-list to display a default page in lieu of a directory listing: <welcome-file-list> <welcome-file>home.xhtml</... Welcome pages are defined at the Web application level.
Created by Fang on February 23, 2012 14:25:57    Last update: March 01, 2012 13:53:59
Some example snippets for Spring message configuration and usage. To configure a message source in Spring context (basename=messages): <bean id="messageSource" class="org.springf... Locale change interceptor can also be setup with: <?xml version="1.0" encoding="UTF-8"?> <beans x... The messages file should be named messages.properties (or messages_en.properties , etc.) and located on CLASSPATH , for example: WEB-INF/classes . To use a message resource in JSP: <%@ taglib prefix="spring" uri="http://www.springf...
Created by James on February 02, 2012 16:00:15    Last update: February 02, 2012 16:00:15
Video for Everybody seems to be a generic way to embed video in a web page, even without flash. This code snippet comes from that site. <!-- first try HTML5 playback: if serving as XML, ...
Created by Dr. Xi on February 01, 2012 12:55:28    Last update: February 01, 2012 12:55:28
You can define environment variables in the Tomcat context.xml file like this: <?xml version="1.0" encoding="UTF-8"?> <Context... which is equivalent to the following in web.xml : <env-entry> <env-entry-name>varName</env-entr... In Java code, the variable can be looked up like this: // import javax.naming.Context; // import javax...
Created by Fang on January 31, 2012 13:57:56    Last update: January 31, 2012 15:04:29
These are the minimum steps to configure Spring MVC in web.xml : Bootstrap Spring MVC by registering ContextLoaderListener : <listener> <listener-class> org.springfra... Register the DispatcherServlet : <servlet> <servlet-name>spring</servlet-name> ... Add servlet-mapping : <servlet-mapping> <servlet-name>spring</servle... Configure DispatcherServlet with WEB-INF/spring-servlet.xml , which configures WebApplicationContext specific to this servlet. <?xml version="1.0" encoding="UTF-8"?> <beans x... Optionally, use context-param in web.xml to configure the global WebApplicationContext : <!-- XmlWebApplicationContext is the default, so t... If you omit this section, you have to create file WEB-INF/applicationContext.xml , even if it's empty. This is the full web.xml : <?xml version="1.0" encoding="UTF-8"?> <web-app...
Created by Fang on December 06, 2011 19:03:25    Last update: December 07, 2011 08:54:11
Our custom tag, as implemented in the previous note , is broken when a template is used. Create a template file ( home-template.xhtml ): <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Stric... and a test page that uses it ( home.xhtml ): <?xml version="1.0" encoding="UTF-8"?> <ui:comp... Then request the page with URL: http://localhost:8080/facelet-demo/home.jsf?name=Jack . You'll find that our hello tag works inside ui:repeat but fails to get the value defined by ui:param ! What's the problem? Our hello tag implementation evaluated the EL with the wrong EL context! This is the corrected implementation: package com.example; import java.io.IOExcep...
Previous  1 2 3 4 Next