Recent Notes

Displaying keyword search results 1 - 10
Created by Fang on April 16, 2012 13:32:10    Last update: April 16, 2012 13:32:10
There are two steps to create a custom function for JSP: Declare the function in the TLD: <?xml version="1.0" encoding="UTF-8" ?> <taglib... Implement the function (must be static): package com.example; public class UrlTransl... To use the function: <%@ taglib uri="" p...
Created by zhidao on January 25, 2012 16:07:29    Last update: January 25, 2012 16:07:29
A JSON response is auto-magically returned when you add the @ResponseBody annotation to the return value of a @RequestMapping annotated method: import org.springframework.stereotype.Controller; ... For magic to happen, you must: Add annotation-driven to the org.springframework.web.servlet.DispatcherServlet config xml: <?xml version="1.0" encoding="UTF-8"?> <beans x... Put Jackson jar files on CLASSPATH (i.e., under WEB-INF/lib ), which includes jackson-core-asl-1.6.4.jar and jackson-mapper-asl-1.6.4.jar .
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/ package; import java.ut... Screenshot Pre-built APK can be downloaded from:
Created by freyo on July 27, 2011 12:13:52    Last update: July 27, 2011 12:13:52
Implement the provider. Put the initialization code in onCreate , implement the necessary query and update methods. This is a skeleton: package my.package; import android.content.... Declare the content provider in AndroidManifest.xml , with content authority (any string identifier): <?xml version="1.0" encoding="utf-8"?> <manifes... Use the provider (content consumer code): // import android.content.ContentResolver; Cont...
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*; import javax.xml.parsers.*; ... code with namespace: import*; 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 May 17, 2011 11:13:17    Last update: May 17, 2011 11:13:17
This is an odd-ball content provider in that it doesn't provide database records, but provides a resource as a stream. It can be used to provide media files or XML resources. Start the project with: tools/android create project --package Create assets directory and add an XML file ( assets/demo.xml ): <? xml version="1.0" encoding="UTF-8"?> <people... Edit the layout ( res/layout/main.xml ): <?xml version="1.0" encoding="utf-8"?> <LinearL... Edit src/com/android/cptest/ : package; import Add content provider ( src/com/android/cptest/ ): package; import Update AndroidManifest.xml : <?xml version="1.0" encoding="utf-8"?> <manifes... Add this section to the end of build.xml : <target name="-package-resources"> <ech... Build and install: ant install Screenshot: Remove the Dummy activity ( AndroidManifest.xml ): <?xml version="1.0" encoding="utf-8"?> <manifes... Create a new project for...
Created by freyo on May 05, 2011 09:00:36    Last update: May 05, 2011 09:07:27
This example uses an Intent with Uri scheme tel: to invoke the phone dialer. Create a new project with: $ ~/android-sdk-linux_86/tools/android create proj... Update the layout res/layout/main.xml to add a text field and a button: <?xml version="1.0" encoding="utf-8"?> <LinearL... Update the Java class src/com/android/intenttest/ to handle button click and start the built-in phone dialer with Intent : package; import andr... Update AndroidManifest.xml to add CALL_PHONE permission: <?xml version="1.0" encoding="utf-8"?> <manifes... Install to the emulator and test: ant install The phone dialer will be invoked when you click the "Call" button. So how did this happen? The CallPhone activity creates an Intent with action Intent.ACTION_CALL and Uri tel:<a number> and sends it off to Android. Android starts the activity because the intent matches the...
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/ and change contents to: package; import android... Install the debug package to the emulator: ant install The 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/ ): package; import android... Change src/com/android/apkinfo/ to invoke the Display Permissions Activity: package; import android... Declare Display Permissions Activity in AndroidManifest.xml : <?xml version="1.0" encoding="utf-8"?> <manifes......
Created by Dr. Xi on April 27, 2011 11:57:36    Last update: April 27, 2011 11:58:35
This is a sample struts-config.xml file for Struts 1.x . <?xml version="1.0" encoding="UTF-8"?> <!DO...
Created by freyo on April 18, 2011 15:08:21    Last update: April 18, 2011 15:12:20
Generate android project $ ~/android-sdk-linux_86/tools/android create proj... Create XML file res/xml/books.xml : <?xml version="1.0"?> <catalog> <book id=... Edit layout ( res/layout/main.xml ): <?xml version="1.0" encoding="utf-8"?> <Lin... Edit code ( src/com/android/xmlres/ ): package; import Change activity label from app_name to booklist ( AndroidManifest.xml ): <?xml version="1.0" encoding="utf-8"?> <manifes... Add value for string resource ( res/values/string.xml ): <?xml version="1.0" encoding="utf-8"?> <resourc... Deploy and test: ant install
Previous  1 2 Next