Displaying keyword search results 1 - 10
Created by Fang on January 28, 2012 13:24:09 Last update: January 28, 2012 13:31:22
This is a simple JSP custom tags library with tag body. Just like the JSF counterpart , it splits a string and repeats the body for each word, i.e., with this markup:
<%@ taglib uri="http://custom.tag.com/demo" prefix...output:
<html> <body> <p>Hello Tigger!</p> <p>H...With Maven, this is the directory structure:
./src ./src/main ./src/main/resources ./s...There are three files to write: pom.xml :
<project xmlns="http://maven.apache.org/POM/4.0.0"...src/main/java/tagdemo/IterateTag.java :
package tagdemo; import java.io.IOException...src/main/resources/META-INF/demotag.tld :
<?xml version="1.0" encoding="UTF-8"?> <!DO...Build with:
mvn clean installTo use it as a dependency in other Maven projects:
<dependency> <groupId>tag-demo</groupId> ...
Created by Fang on November 22, 2011 10:40:16 Last update: November 22, 2011 10:40:16
This is an example that uses tag handler, UI component and renderer together to support a custom taglib. The main purpose is to show how these components play together. The tag renders
<ui:param name="extra" value="el interpreted"/> ...as
<h3>my:foreach</h3> <ul class="css class" extra...These are the files: The tag handler ( src/main/java/com/example/ForeachTagHandler.java ):
package com.example; import java.util.Map; ...The UI component ( src/main/java/com/example/UIForeach.java ):
package com.example; import java.io.IOExcep...The renderer ( src/main/java/com/example/ForeachRenderer.java ):
package com.example; import java.io.IOExcep...Faces config ( src/main/resources/META-INF/faces-config.xml ):
<?xml version="1.0" encoding="UTF-8"?> <faces-c...Taglib config ( src/main/resources/META-INF/foreach.taglib.xml ):
<?xml version="1.0" encoding="UTF-8"?> <facelet...
Created by Fang on November 08, 2011 20:55:00 Last update: November 21, 2011 18:19:44
In the simple taglib example , I used a tag handler class to implement a taglib. This is an example to implement a taglib with a UI component. The purpose is to use a custom tag to split a string and print each part in a separate paragraph, i.e., print
<p>john</p> <p>steve</p> <p>mike</p>with custom tag <my:foreach> :
<my:foreach var="who" value="john steve mike"> ...These are the files: pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"...src/main/java/com/example/UIForeash.java :
package com.example; import java.io.IOExcep...src/main/resources/META-INF/faces-config.xml :
<?xml version="1.0" encoding="UTF-8"?> <faces-c...src/main/resources/META-INF/foreach.taglib.xml :
<?xml version="1.0" encoding="UTF-8"?> <facelet...How to use: Put the JAR file generated by the above project in the WEB-INF/lib folder of the web app. If the web app is a Maven project, just add the taglib project as a dependency:...
Created by freyo on May 13, 2011 15:45:29 Last update: September 20, 2011 08:08:12
This is an Android app that dumps any binarized xml file as plain text - to the sdcard on the device or emulator. build.xml :
<?xml version="1.0" encoding="UTF-8"?> <project...AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> <man...res/layout/main.xml
<?xml version="1.0" encoding="utf-8"?> <Lin...res/values/strings.xml :
<?xml version="1.0" encoding="utf-8"?> <res...src/com/android/xmltool/DumpXml.java
package com.android.xmltool; import java.ut...Screenshot Pre-built APK can be downloaded from: http://code.google.com/p/android-binxml-dump/
Created by freyo on August 31, 2011 15:49:54 Last update: August 31, 2011 15:49:54
Got this error while trying to build Android app:
[apkbuilder] Creating AppInfo-debug-unaligned.ap...Solution: Delete the Android debug keystore:
$ rm ~/.android/debug.keystoreBuild again:
$ ant debugThe new key is valid for 30 years (keystore password is 'android'):
$ keytool -list -v -keystore ~/.android/debug.keys...
Created by alfa on June 03, 2011 09:41:03 Last update: June 03, 2011 09:41:03
Dynamic proxy can be used to eliminate the need to stub out unused interface methods. This is an example for a simple SAX content handler for XML parsing. The org.xml.sax.ContentHandler interface requires 11 methods be implemented but we only need three:
import java.io.IOException; import java.util.Ar...With a dynamic proxy, we don't need the empty blocks for the unused methods:
import java.io.IOException; import java.util.Ar...Equivalently (with anonymous inner class):
import java.io.IOException; import java.util.Ar...demo.xml :
<breakfast-menu> <food> <name>Belgian W...
Created by freyo on May 23, 2011 14:30:18 Last update: May 23, 2011 14:31:08
There are two distinct ways to process XPath: with namespace and without namespace. The code is different depending on whether the parser is namespace aware. Code without namespace:
import java.io.*; import javax.xml.parsers.*; ...code with namespace:
import java.io.*; import java.util.Iterator; ...XML without namespace:
<?xml version="1.0" encoding="UTF-8" standalone="n...XML with namespace:
<?xml version="1.0" encoding="UTF-8" standalone="n...The same XPath expression works for both XML files when the parser is not namespace aware. When the parser is namespace aware, you have to adjust the XPath accordingly depending on whether the XML has namespace declarations: " /test-license/licensee/name/text() " works for the XML file without namespace, while " /p:test-license/p:licensee/p:name/text() " works for the XML file with namespace.
Created by freyo on April 12, 2011 15:13:32 Last update: May 03, 2011 15:20:55
Create new project
$ tools/android create project \ > --package co...Edit res/values/string.xml , add strings for the main screen.
<?xml version="1.0" encoding="utf-8"?> <resourc...Add widgets to main layout ( res/layout/main.xml ).
<?xml version="1.0" encoding="utf-8"?> <LinearL...Edit src/com/android/apkinfo/GetAPKPermissions.java and change contents to:
package com.android.apkinfo; import android...Install the debug package to the emulator:
ant installThe screen should look like: Add display permissions activity. Start by creating a new layout res/layout/display_permissions.xml :
<?xml version="1.0" encoding="utf-8"?> <LinearL...Add the strings used by the new Activity ( res/values/strings.xml ):
<?xml version="1.0" encoding="utf-8"?> <resourc...Add the Display Permissions Activity ( src/com/android/apkinfo/DisplayPermissions.java ):
package com.android.apkinfo; import android...Change src/com/android/apkinfo/GetAPKPermissions.java to invoke the Display Permissions Activity:
package com.android.apkinfo; import android...Declare Display Permissions Activity in AndroidManifest.xml :
<?xml version="1.0" encoding="utf-8"?> <manifes......
Created by freyo on April 20, 2011 15:10:03 Last update: April 20, 2011 15:10:03
When you sign an APK with existing signature, the new certificate is appended to the existing one. If you want to replace the existing certificate, you need to remove it first. But since an APK is just a zip file, this is pretty easy: Remove existing signature:
$ zip -d HelloWorld-new.apk META-INF/* deleting...Verify:
$ unzip -l HelloWorld-new.apk Archive: HelloWo...Sign it again:
$ jarsigner HelloWorld-new.apk android-root Ent...
Created by Fang on August 23, 2010 22:55:58 Last update: August 24, 2010 15:45:04
The tags XML flow control tags are exactly the same as their Core flow control equivalents, except that the test condition with a boolean EL expression is replaced by the select condition with an XPath expression. In the case of the forEach tag, the items attribute is replaced with the select attribute. In a test condition, the XPath expression is evaluated to a boolean value by the rules of the XPath boolean() function, which converts its argument to a boolean as follows: a number is true if and only if it is neither positive or negative zero nor NaN. a node-set is true if and only if it is non-empty. a string is true if and only if its length is non-zero. an object of...