Recent Notes

Displaying keyword search results 11 - 20
Created by Fang on March 30, 2012 15:04:04    Last update: March 30, 2012 15:04:04
Spring MVC 3.1 can send either JSON or HTML response on the same URL, depending on the type of response requested. With this mechanism, a page can be sent when directly requested from a link, but a JSON response can be sent in response to an AJAX request. This is the controller code: package com.example; import java.util.Map; ... In the above example, JSON response will be sent when the HTTP request contains header "Accept: application/json". HTML response will be sent then the header is "Accept: */*", or "Accept: text/html", or anything else. You can add a limitation that the HTML response does not produce "application/json". But then the question is which response will be sent when the HTTP header is "Accept: */*"? Both methods will...
Created by James on June 22, 2010 18:56:40    Last update: February 13, 2012 10:25:47
Version 1.6.4: <!-- jQuery --> <script type="text/javascript" ... Version 1.7.1: <script type="text/javascript" src="https://ajax.g... Google URL:
Created by Fang on February 10, 2012 16:17:13    Last update: February 10, 2012 16:17:13
The annotation @org.hibernate.annotations.Type overrides the default hibernate mapping type used for a column. This can usually be omitted since Hibernate normaly infers the correct type to use. But @Type is required in ambiguous scenarios such as a java.util.Date attribute, which can map to SQL DATE , TIME or TIMESTAMP . You use the @Type("timestamp") annotation to tell Hibernate that a timestamp converter should be used, which identifies an instance of org.hibernate.type.TimestampType . @Type can also be used to identify custom type converters, which can be defined with @TypeDef at the class level: @TypeDefs( { @TypeDef( na... or with an xml file: <?xml version="1.0"?> <!DOCTYPE hibernate-mappi...
Created by James on February 02, 2012 16:09:05    Last update: February 02, 2012 16:09:17
flowplayer is another way to embed Flash in a web page. The code looks like this: <object width="6400" height="380" data="swf/flowpl... You need to download two swf files:
Created by James on February 02, 2012 15:40:32    Last update: February 02, 2012 15:40:32
It's pretty easy to embed Flash video in HTML with swfobject . This example comes directly from the docs: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Stric... where swfobject.js and expressInstall.swf comes with swfobjects. I provide these files: swf/MySwfFile.swf images/CoverArt.jpg video/MyFlashVideo.flv
Created by James on February 02, 2012 09:20:22    Last update: February 02, 2012 09:20:22
This example came from the jQuery validation documentation. The required rule can be used to validate a required selection box when you set the value of the first option to empty. <!DOCTYPE HTML> <html> <head> <scrip... The error message is the title since no error message is specified. A more fully defined validation check would look like this: $('#my-form').validate({ errorElement: "p", ...
Created by zhidao on January 25, 2012 19:27:53    Last update: January 25, 2012 19:28:47
The spring MVC annotation-driven declaration: <?xml version="1.0" encoding="UTF-8"?> <beans x... does the following magic : Among others, registers: RequestMappingHandlerMapping RequestMappingHandlerAdapter ExceptionHandlerExceptionResolver in support of processing requests with annotated controller methods using annotations such as @RequestMapping , @ExceptionHandler , etc. Enables Spring 3 style type conversion through a ConversionService instance in addition to the JavaBeans PropertyEditors used for Data Binding. Enables support for formatting Number fields using the @NumberFormat annotation through the ConversionService . Enables support for formatting Date, Calendar, Long, and Joda Time fields using the @DateTimeFormat annotation, if Joda Time 1.3 or higher is present on the classpath. Enables support for validating @Controller inputs with @Valid , if a JSR-303 Provider is present on the classpath. Enables HttpMessageConverter support for @RequestBody method parameters and...
Created by Dr. Xi on January 17, 2012 11:58:16    Last update: January 17, 2012 11:58:16
Steps to configure JavaMail resource for Tomcat 6 & 7: Install JavaMail jar: download the JavaMail API , unzip the archive and copy mail.jar to $CATALINA_HOME/lib . Add JavaMail resource to $CATALINA_BASE/conf/context.xml : <?xml version="1.0"?> <Context> . ... Add resource-ref for the JavaMail resource to your webapp WEB-INF/web.xml : <?xml version="1.0" encoding="UTF-8"?> <web-app... Use the JavaMail resource in your webapp: // import javax.naming.*; // import javax.mail....
Created by Fang on January 04, 2012 11:14:46    Last update: January 04, 2012 11:14:46
Assume that your messages are defined in , this is how you load and use the messages: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Stric... In : pageTitle = JSF Resource Bundle Example page.he...
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
Previous  1 2 3 4 5 6 7 8 9 10 Next