Recent Notes
Displaying keyword search results 1 - 10
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 October 22, 2011 19:51:05
Last update: October 22, 2011 20:31:48
I built a very basic JSF application and deployed to Tomcat 7.0.22, but it failed with this error:
Caused by: java.lang.ClassFormatError: Absent Code... That looks weird and I wasn't able to find a sensible explanation! So I copied the jsf-api-2.1.jar , which was downloaded from the java.net Maven repository by Maven, into a temp folder. And tested it with this simple program: public class ClassFormatErrorTest { public ... I also copied servlet-api.jar from Tomcat's lib folder to the temp folder. Sure enough it failed with the same error: C:\tmp>java -cp .;jsf-api-2.1.jar;servlet-api.jar ... But when I replaced the javax.faces.webapp.FacesServlet class with one I compiled from source, the error disappears! Conclusions: The jar file jsf-api-2.1.jar from java.net Maven repository is good for compilation only (cannot be used...
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 August 25, 2011 09:07:40
Last update: August 25, 2011 20:45:43
This is a list of built-in Android permission values: Permission Description Since API Level android.permission.ACCESS_CHECKIN_PROPERTIES Allows read/write access to the "properties" table in the checkin database, to change values that get uploaded. 1 android.permission.ACCESS_COARSE_LOCATION Allows an application to access coarse (e.g., Cell-ID, WiFi) location 1 android.permission.ACCESS_FINE_LOCATION Allows an application to access fine (e.g., GPS) location 1 android.permission.ACCESS_LOCATION_EXTRA_COMMANDS Allows an application to access extra location provider commands 1 android.permission.ACCESS_MOCK_LOCATION Allows an application to create mock location providers for testing 1 android.permission.ACCESS_NETWORK_STATE Allows applications to access information about networks 1 android.permission.ACCESS_SURFACE_FLINGER Allows an application to use SurfaceFlinger's low level features 1 android.permission.ACCESS_WIFI_STATE Allows applications to access information about Wi-Fi networks 1 android.permission.ACCOUNT_MANAGER Allows applications to call into AccountAuthenticators. Only the system can get this permission. 5 android.permission.AUTHENTICATE_ACCOUNTS...
Created by freyo on August 17, 2011 12:29:46
Last update: August 17, 2011 12:29:46
In Android.mk , you can define LOCAL_JARJAR_RULES like this:
LOCAL_JARJAR_RULES := $(LOCAL_PATH)/jarjar-rules.t...
and in jarjar-rules.txt define a rule like this:
rule org.bouncycastle.** com.android.@0
The build will change all org.bouncycastle to com.android.org.bouncycastle . Therefore, in your classes which are dependent on the library produced, the import statements should look like:
import com.android.org.bouncycastle...
Help for the jarjar utility (in prebuilt/common/jarjar/ ):
$ java -jar jarjar-1.0rc8.jar
Jar Jar Links - ...
Created by freyo on April 12, 2011 13:30:33
Last update: May 09, 2011 14:43:46
You can look at the file /data/system/packages.xml to find out which package is using a particular sharedUserId .
Copy the file /data/system/packages.xml to the local drive with:
adb pull /data/system/packages.xml packages.xml
Open the file in an editor, search for the shared user id, for example: com.google.android.apps.maps
Search for packages with the corresponding numerical id of sharedUserId , for example: sharedUserId="10017"
Or, Programatically :
// import android.os.Process;
PackageInfo pkgIn...
Created by Dr. Xi on March 28, 2011 11:11:33
Last update: March 28, 2011 11:13:21
grep is a versatile command with many variations (grep, egrep, fgrep, then various implementations). It uses a regula expression (regex) pattern to filter input. But then there are basic and extended flavors of regex - leading to even more confusion. And, beware that there are lots of bad examples of regex in the wild... There are two critical questions to ask when you use grep: which grep implementation are you using? what is the flavor of the regex? Here are some examples for gnu grep v2.7:
# Find all numbers (no decimal point), basic regex... Use the -o flag to show only the matching part instead of the whole matching line: grep -o -E '\b[0-9]{2}\b' The good thing about the gnu grep is that it...
Created by Dr. Xi on July 19, 2010 21:58:34
Last update: July 23, 2010 21:37:23
Parsing XML in Java is really simple:
import java.io.*; import javax.xml.parsers.Docu... The parser implementation details are hidden behind the JAXP API. In case you want to know which parser implementation is used, this is what the JavaDoc for DocumentBuilderFactory.newInstance says: Use the javax.xml.parsers.DocumentBuilderFactory system property. Use the properties file " lib/jaxp.properties " in the JRE directory. This configuration file is in standard java.util.Properties format and contains the fully qualified name of the implementation class with the key being the system property defined above. The jaxp.properties file is read only once by the JAXP implementation and it's values are then cached for future use. If the file does not exist when the first attempt is made to read from it, no further attempts are made to...
Created by Dr. Xi on June 20, 2010 14:35:17
Last update: June 20, 2010 14:35:17
This XML signature validator comes from the Apache XML Security project. It validates the signature according to the core validation processing rules .
It does not verify that the key used to generate the signature is a trusted key. You can override the KeySelector class to make sure that the signing key is from a trusted store.
import javax.xml.crypto.*;
import javax.xml.cry...
Created by Dr. Xi on June 11, 2010 23:11:59
Last update: June 11, 2010 23:14:02
Given a simple XML file like this:
<?xml version="1.0"?> <root id="1"> ... Calling Document.getElementById returns null (surprisingly!): import java.io.*; import org.w3c.dom.*; impo... In fact the JavaDoc says something along the lines that getElementById returns the Element that has an ID attribute with the given value. An attribute with the name "ID" or "id" is not of type ID unless it is so defined. How is an attribute defined as an ID attribute ? With a DTD or schema. If you are not validating the XML, then the API is useless. So, what to do if you want to find an element for which the attribute named "id" has a given value? Several options were offered in GetElementById Pitfalls . One of them is to...