Recent Notes

Displaying keyword search results 1 - 10
Created by James on September 21, 2012 12:18:10    Last update: September 21, 2012 12:23:07
When one element overlaps another, which one gets the event when you click on it? The top one, of course! Not so for IE. If the top element is transparent, the click falls through on areas in the bottom element where there's "content". Try the simple HTML below. When you click on the letter "A", the bottom DIV gets the event in IE. <!doctype html> <html> <head> <style ... There's a CSS property pointer-events which controls click through behavior in case of overlay, but it doesn't have any effect in IE.
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 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 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...
Created by Fang on November 10, 2011 09:26:12    Last update: November 10, 2011 09:26:12
Syntax highlighted XML schema for JSF 2.0 Application Configuration Resource File ( faces-config.xml ). Almost 3000 lines! <?xml version="1.0" encoding="UTF-8"?> <xsd:sch...
Created by Fang on October 28, 2011 13:49:40    Last update: October 30, 2011 19:23:25
This is a simple example to demonstrate the templating power of JSF facelets. If you've used struts tiles before, you'll recognize the simplicity of templating with facelets. I've stripped out everything else except the pages themselves, just to put our focus on facelets. This is a Maven based project, and you need Tomcat (or any servlet container) to run the resulting webapp. To begin with this is the list of files: ./pom.xml ./src/main/webapp/home.xhtml ./src... I left faces-config.xml in there for completeness sake, it may not be needed. The Maven POM ( pom.xml ): <?xml version="1.0" encoding="UTF-8"?> <project... Web app configuration ( WEB-INF/web.xml ): <?xml version="1.0" encoding="UTF-8"?> <web-app... Empty WEB-INF/faces-config.xml : <?xml version="1.0" encoding="UTF-8"?> <!-- Thi... index.jsp is simply a redirect to home.jsf : <% response.sendRedirect("home.jsf"); %>...
Created by freyo on September 09, 2011 11:43:36    Last update: September 09, 2011 11:45:45
When you run automated Android tests with Eclipse or from the command line, you get text output, which isn't good for reporting purposes. If you run a large set of test cases with automated build, the text report isn't very helpful. Fortunately, Android CTS generates test reports in XML with accompanying XSL to make it look nice in a browser. To run your own tests with Android CTS: Download Android CTS Make a new directory MyRepository under android-cts , alongside the existing repository directory. Copy host_config.xml from repository to MyRepository Create directory plans under MyRepository , add a test plan ( MyTests.xml ): <?xml version="1.0" encoding="UTF-8"?> <TestPla... Create directory testcases under MyRepository . Copy TestDeviceSetup.apk from repository/testcases to MyRepository/testcases Under MyRepository/testcases , create a test...
Created by freyo on September 07, 2011 16:46:14    Last update: September 07, 2011 19:23:00
The Android unit test framework is based on JUnit 3 , not JUnit 4. Test cases have to extend junit.framework.TestCase or a subclass (such as android.test.InstrumentationTestCase ). Tests are identified by public methods whose name starts with test , not methods annotated with @Test (as in JUnit 4). An Android test suite is packaged as an APK, just like the application being tested. To create a test package, first you need to identify the application package it is testing. Google suggests to put the test package source in a directory named tests/ alongside the src/ directory of the main application. At runtime, Android instrumentation loads both the test package and the application under test into the same process. Therefore, the tests can invoke methods on...
Created by Dr. Xi on July 11, 2011 12:04:52    Last update: July 11, 2011 12:04:52
From the Java Language Specification : Because some type information is erased during compilation, not all types are available at run time. Types that are completely available at run time are known as reifiable types . A type is reifiable if and only if one of the following holds: It refers to a non-generic type declaration. It is a parameterized type in which all type arguments are unbounded wildcards. It is a raw type. It is a primitive type. It is an array type whose component type is reifiable. For example: int is a reifiable type (primitive type) List is a reifiable type (raw type) List<?> is a reifiable type (parameterized type with unbound wildcards) List<String> is not a reifiable type (generic type) Class<?> is...
Created by James on July 19, 2009 20:51:23    Last update: January 11, 2011 20:14:18
If CSS3 border-image is properly supported, making a rounded corner box is very easy. You just need a round corner image like this: The following markup: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" ... would render like this (try it in Firefox 3.5 and Google Chrome): However, IE as of version 8.0 does not support border-image . So until border-image is reliably supported in all major browsers, we still have to rely on tried and true tricks to make it work. In general, I found three general categories of tricks to make rounded corners: Good old tables. This trick creates a table of 9 cells and uses the 8 cells on the perimeter to render the borders and rounded corners. The central cell is used for...
Previous  1 2 Next