Sunday, September 18, 2011

Making-distinctions-between-different-kinds-of-JSF-managed-beans

JSF has a simple Inversion-of-Control (IoC) container called the JSF Managed Bean Facility (MBF). Although it has a verbose XML syntax, and is not as robust as the Spring BeanFactory, PicoContainer, or the JBoss Microcontainer, the MBF does have the basics of an IoC container, and offers features like dependency injection.

When a POJO is managed by the JSF MBF, it is typically referred to as a managed-bean. But if you're going to create a maintainable JSF webapp/portlet, it is necessary to distinguish between different kinds of managed-beans. This practice will also preserve the clean separation of concerns that JSF provides by implementing the Model-View-Controller (MVC) design pattern:

 

Managed-Bean Type Nickname Typical Scope
Model Managed-Bean model-bean session

Description: This type of managed-bean participates in the "Model" concern of the MVC design pattern. When you see the word "model" -- think DATA. A JSF model-bean should be a POJO that follows the JavaBean design pattern with getters/setters encapsulating properties. The most common use case for a model bean is to be a database entity, or to simply represent a set of rows from the result set of a database query.

Backing Managed-Bean backing-bean request

Description: This type of managed-bean participates in the "View" concern of the MVC design pattern. The purpose of a backing-bean is to support UI logic, and has a 1::1 relationship with a JSF view, or a JSF form in a Facelet composition. Although it typically has JavaBean-style properties with associated getters/setters, these are properties of the View -- not of the underlying application data model. JSF backing-beans may also have JSF actionListener and valueChangeListener methods.

Controller Managed-Bean controller-bean request

Description: This type of managed-bean participates in the "Controller" concern of the MVC design pattern. The purpose of a controller bean is to execute some kind of business logic and return a navigation outcome to the JSF navigation-handler. JSF controller-beans typically have JSF action methods (and not actionListener methods).

Support Managed-Bean support-bean session / application

Description: This type of bean "supports" one or more views in the "View" concern of the MVC design pattern. The typical use case is supplying an ArrayList<SelectItem> to JSF h:selectOneMenu drop-down lists that appear in more than one JSF view. If the data in the dropdown lists is particular to the user, then the bean would be kept in session scope. However, if the data applies to all users (such as a dropdown lists of provinces), then the bean would be kept in application scope, so that it can be cached for all users.

Utility Managed-Bean utility-bean application

Description: This type of bean provides some type of "utility" function to one or more JSF views. A good example of this might be a FileUpload bean that can be reused in multiple web applications.

 

Now... One of the main benefits in making fine distinctions like this is loose coupling. What's that you ask? Well let's first take a look at an example of tight coupling, where MVC concerns can be smashed/confused into a single managed-bean:

 

public class ModelAndBackingAndControllerBean {

	private String fullName; // model-bean property
	private boolean privacyRendered; // backing-bean property

	// model-bean getter
	public String getFullName() {
		return fullName;
	}
	
	// model-bean setter
	public void setFullName(String fullName) {
		this.fullName = fullName;
	}

	// backing-bean getter
	public boolean isPrivacyRendered() {
		return privacyRendered;
	}

	// backing-bean setter
	public void setPrivacyRendered(boolean privacyRendered) {
		this.privacyRendered = privacyRendered;
	}

	// backing-bean actionListener for UI support logic
	public void togglePrivacySection(ActionEvent actionEvent) {
		privacyRendered = !privacyRendered;
	}

	// controller-bean business logic
	public String submit() {
		System.out.println("fullName=" + fullName);
		return "success";
	}
}

The problem here is that the bean would have to be kept in session scope because of the model-bean property. Additionally, what if we wanted to do some unit testing with mock model data? Can't do it. So in order to fix these problems, and to promote loose coupling, we would have three separate Java classes:

public class ModelBean {

	private String fullName;

	public void setFullName(String fullName) {
		this.fullName = fullName;
	}

	public String getFullName() {
		return fullName;
	}
}

public class BackingBean {

	private boolean privacyRendered;

	public void setPrivacyRendered(boolean privacyRendered) {
		this.privacyRendered = privacyRendered;
	}

	public boolean isPrivacyRendered() {
		return privacyRendered;
	}

	public void togglePrivacySection(ActionEvent actionEvent) {
		privacyRendered = !privacyRendered;
	}

}

public class ControllerBean {

	private ModelBean modelBean;
	
	public ModelBean getModelBean() {
		return modelBean;
	}

	public void setModelBean(ModelBean modelBean) {
		// Dependency injected from the JSF managed-bean facility
		this.modelBean = modelBean;
	}

	public String submit() {
    	System.out.println("fullName=" + getModelBean().getFullName());
        return "success";
    }

}

 

Now that the beans are found in different classes, they can all be kept in their appropriate scopes. The model-bean can be kept in session scope, and the backing-bean and controller-bean can be kept in request scope, thus saving memory resources on the server.

Finally, we can use the dependency injection features of the JSF MBF in order to inject the model-bean into the controller-bean. This can be seen in the following WEB-INF/faces-config.xml example, where the #{modelBean} Expression Language (EL) binding is used:

<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
	version="1.2">
	<managed-bean>
		<managed-bean-name>modelBean</managed-bean-name>
		<managed-bean-class>myproject.ModelBean</managed-bean-class>
		<managed-bean-scope>session</managed-bean-scope>
	</managed-bean>
	<managed-bean>
		<managed-bean-name>backingBean</managed-bean-name>
		<managed-bean-class>myproject.BackingBean</managed-bean-class>
		<managed-bean-scope>request</managed-bean-scope>
	</managed-bean>
	<managed-bean>
		<managed-bean-name>controllerBean</managed-bean-name>
		<managed-bean-class>myproject.ControllerBean</managed-bean-class>
		<managed-bean-scope>request</managed-bean-scope>
		<managed-property>
			<property-name>modelBean</property-name>
			<value>#{modelBean}</value>
		</managed-property>
	</managed-bean>
</faces-config>
http://blog.icefaces.org/blojsom/blog/default/2009/04/23/Making-distinctions-between-different-kinds-of-JSF-managed-beans/	

Thursday, November 18, 2010

Postgresql Connection Pool in Glassfish 3.1

Create Postgresql Connection Pool with Netbeans 7.0 and Glassfish 3.1

Step 1.
Download the latest jdbc driver: http://jdbc.postgresql.org/download.html
Eg: postgresql-8.4-701.jdbc4.jar

Step 2.
Copy the downloaded archive postgresql-x.x.-xxx.jdbc4.jar in {glassfish}/lib directory and restart glassfish:
Eg: D:\programs\glassfish3.1b25\glassfish\lib

asadmin stop-domain domain1
asadmin start-domain domain1

Step3.
Add datasource details in web.xml (Java EE6)

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">


   <data-source>
    <name>java:app/env/myDataSourceName</name>
    <class-name>org.postgresql.Driver</class-name>
    <server-name>localhost</server-name>
    <port-number>5432</port-number>
    <database-name>your_database_name</database-name>
    <user>user_name</user>
    <password>password</password>
    <property>
      <name>url</name>
      <value>jdbc:postgresql://localhost:5432/your_database_name</value>
      </property>
  </data-source>


</web-app>

Step4. Get a Connection

Context ctx = new InitialContext();
javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup("java:app/env/myDataSourceName");
ds.getConnection();

Monday, November 15, 2010

6 Steps to Presentations

1 Your Slides
• Do not read your slides aloud
• Use few transitions and keep them simple
• Do Not give out your slides in advance.
Key: Everything on your slide must be there for a reason. That includes animation, colors, gradients, text, fonts, etc. If you can’t say clearly why you added it, take it out.

2 Your Body
• Stand up straight and keep your feet still
• Take your hands out of your pocket
• Use both arms
• Use big gestures
• If you have a “clicker” hold it in your weaker hand – putting a clicker in your dominant hand will “freeze” the other
Key: Your body should accent your presentation, not distract from it.

3 Your computer
• Set everything up in advance, and then double check it
• All software should be open and minimized – do not make the audience wait for software to start
• Get your resolution right before you start.
• Get your screen sharing set up in advance
• Learn how to zoom in on parts of the screen, and how to stop
• Have a complete backup and a spare computer
Key: Your computer should be invisible, working perfectly smoothly

4 Your Words
• Know your material cold
• Have a single key message
• Hammer that message
• Illustrate that message
• Articulate that message
• Then shut up
Practice. Nothing is as good as well practiced spontaneity!
If you are good at it, go off on tangents, rants and be funny. If it falls flat, maybe you aren’t good at it. If you are not good at it, don’t do it.
Key: Your words are your presentation – not your slides, not your handouts

5 Your Voice
Nothing in your presentation is more important than your voice.
• Record your practice and listen to your voice
• Pay attention to modulation: use loudness well
• Try changing speed – is faster better? slower?
• Avoid monotones like death itself
• Use pauses well…. let folks digest and then hit them with something interesting
• Unlean filler sounds like uhm, ahhh, hmmmm, So!, You know….
Key: Your voice is your instrument, play it well.

6 Time Management
• Know how much time you have
• Watch the time or use a timer
• Finishing early beats finishing late
• Never say “but we don’t have time to…”
• Use transition time well… if you need to fix your computer or adjust equipment have an interaction with the audience (take questions?).
Key: You have a specific amount of time; bring your presentation to a close with time to spare.

http://jesseliberty.com/2010/11/05/6-steps-to-presentations-that-dont-suck/#more-3949

Wednesday, July 7, 2010

The Java ME Universe Today


The current universe of configurations, profiles and optional packages is shown in the diagram below. The tables immediately following provide more details about the abbreviations in the figure.

Java ME Overview



Configurations

JSR 30 CLDC 1.0 Connected, Limited Device Configuration (http://jcp.org/en/jsr/detail?id=30)
JSR 139 CLDC 1.1 Connected, Limited Device Configuration 1.1
JSR 36 CDC Connected Device Configuration
JSR 218 CDC 1.1 Connected Device Configuration 1.1

Profiles

JSR 37 MIDP 1.0 Mobile Information Device Profile
JSR 118 MIDP 2.0 Mobile Information Device Profile 2.0
JSR 75 PDAP PDA Profile
JSR 46 FP Foundation Profile
JSR 219 FP 1.1 Foundation Profile 1.1
JSR 129 PBP Personal Basis Profile
JSR 217 PBP 1.1 Personal Basis Profile 1.1
JSR 62 PP Personal Profile
JSR 215 PP 1.1 Personal Profile 1.1
JSR 195 IMP Information Module Profile
JSR 228 IMP-NG Information Module Profile - Next Generation

Optional Packages

JSR 75 PIM PDA Optional Packages for the Java ME Platform
JSR 82 BTAPI Java APIs for Bluetooth
JSR 120 WMA Wireless Messaging API
JSR 205 WMA 2.0 Wireless Messaging API 2.0
JSR 135 MMAPI Mobile Media API
JSR 164 JAIN SIMPLE Presence
JSR 165 JAIN SIMPLE Instant Messaging
JSR 172 Java ME Web Services
JSR 177 SATSA Security and Trust Services API for Java ME
JSR 179 Location API for Java ME
JSR 180 SIP SIP API for Java ME
JSR 184 3D Mobile 3D Graphics API for Java ME
JSR 186 JAIN Presence
JSR 187 JAIN Instant Messaging
JSR 190 Event Tracking API for Java ME
JSR 209 Advanced Graphics and User Interface Optional Package for Java ME Platform
JSR 211 CHAPI Content Handling API
JSR 213 Micro WSCI Framework for Java ME
JSR 214 Micro BPSS for Java ME Devices
JSR 226 Scalable 2D Vector Graphics API
JSR 229 Payment API
JSR 230 Data Sync API
JSR 232 Mobile Operational Management
JSR 234 Advanced Multimedia Supplements
JSR 238 Mobile Internationalization API
JSR 239 Java Bindings for OpenGL ES
JSR 246 Device Management API
JSR 253 Mobile Telephony API (MTA)



As the diagram shows, Java ME has two main branches.The first is based on the Connected, Limited Device Configuration (CLDC). This configuration is for small wireless devices with intermittent network connections, like pagers, mobile phones, and Personal Digital Assistants (PDAs). The Mobile Information Device Profile (MIDP), which is based on CLDC, was the first finished profile and thus the first finished Java ME application environment. MIDP-compliant devices are widely available. http://developers.sun.com/mobility/device/

The other major branch of the Java ME tree is based on the Connected Device Configuration (CDC). This configuration is for larger devices (in terms of memory and processing power) with robust network connections. Set-top boxes and internet appliances are good examples of CDC devices, although high-end PDAs like the Sharp Zaurus also fit this configuration well. The Foundation Profile extends CDC and serves as the basis for several other profiles. It provides fundamental APIs gleaned from Java SE, including classes and interfaces from java.lang, java.io, java.security, java.util, and more. For a list of Java ME terms and definitions, see our glossary http://developers.sun.com/mobility/glossary/

Optional packages bubble like a froth above the CLDC and CDC branches of Java ME. These provide all sorts of capabilities ranging from Bluetooth communication through web services and instant messaging. Look in the table for links to the specifications themselves.

For a thorough look at Java ME, see:

A Survey of Java ME Today http://developers.sun.com/mobility/getstart/articles/survey/

The world of wireless Java technology also includes Java Card, for smart cards. For more information on Java Card, see:

An Introduction to Java Card Technology - Part 1 http://developers.sun.com/mobility/javacard/articles/javacard1/

Overview of Java ME

Unlike Java SE, Java ME is not a piece of software, nor is it a single specification. This difference can be confusing, even for developers who are already familiar with Java SE. Instead, Java ME is a platform, a collection of technologies and specifications that are designed for different parts of the small device market. Because Java ME spans such a variety of devices, it wouldn't make sense to try to create a one-size-fits-all solution.

Java ME, therefore, is divided into configurations, profiles,and optional packages. Configurations are specifications that detail a virtual machine and a base set of APIs that can be used with a certain class of device. A configuration, for example, might be designed for devices that have less than 512 KB of memory and an intermittent network connection. The virtual machine is either a full Java Virtual Machine1 (as described in the specification) or some subset of the full JVM1. The set of APIs is customarily a subset of the Java SE APIs.

A profile builds on a configuration but adds more specific APIs to make a complete environment for building applications. While a configuration describes a JVM1 and a basic set of APIs, it does not by itself specify enough detail to enable you to build complete applications. Profiles usually include APIs for application life cycle, user interface, and persistent storage.

An optional package provides functionality that may not be associated with a specific configuration or profile. One example of an optional package is the Bluetooth API (JSR 82), which provides a standardized API for using Bluetooth networking. This optional package could be implemented alongside virtually any combination of configurations and profiles.

Overview of the Java Platform

The Java Platform comprises three elements:
The Java programming language is syntactically similar to C++ but differs fundamentally. While C++ uses unsafe pointers and programmers are responsible for allocating and freeing memory, the Java programming language uses type safe object references, and unused memory is reclaimed automatically. Furthermore, the Java programming language eschews multiple inheritance (a likely source of confusion and ambiguity in C++) in favor of a cleaner construct, interfaces.

A virtual machine forms the foundation of the Java platform. This architecture offers several attractive features: The virtual machine can be implemented to run a top a variety of operating systems and hardware, with binary-compatible Java applications operating consistently across many implementations. In addition, the virtual machine provides tight control of executed binaries, enabling safe execution of untrusted code.

Finally, an extensive set of standard application programming interfaces(APIs) rounds out the Java platform. These support almost everything you might want your applications to do, from user interface through cryptography, from CORBA connectivity through internationalization.

Taken together, the Java language, Java virtual machine1, and Java APIs compose the Java platform. Moreover, the Java platform is designed to encompass a wide range of computer hardware, everything from smart cards through enterprise servers. Therefore, the Java platform comes in three flavors:
Java Platform, Standard Edition (Java SE) is designed for desktop computers. Most often it runs on top of OS X, Linux, Solaris, or Microsoft Windows.

Java Platform, Enterprise Edition (Java EE) is a comprehensive platform for multiuser,enterprise-wide applications. It is based on Java SE and adds APIs for server-side computing.

Java Platform, Micro Edition (Java ME) is a set of technologies and specifications developed for small devices like pagers, mobile phones, and set-top boxes. Java ME uses subsets of Java SE components, such as smaller virtual machines and leaner APIs.

To learn much more about Java technology or the Java platform, visit http://java.sun.com/:
The New to Java Programming Center offers an excellent entry point into the Java platform, understanding it, getting it installed on your computer, and starting to program.

The Java Community Process (JCP)

Specifications for Java SE, Java EE, and Java ME are developed under the aegis of the Java Community Process (JCP). A specification begins life as a Java Specification Request (JSR). An expert group consisting of representatives from interested companies is formed to create the specification. The JSR then passes through various stages in the JCP before it is finished. Every JSR is assigned a number. Java ME specifications are commonly referred to by their JSR number.

http://developers.sun.com/mobility/getstart/

Introduction to Wireless Communications

To develop applications using wireless Java technology, you'll need to assimilate information from several fields. You'll need to understand something about wireless communications technology, the business of wireless communications, and a lot about the Java platform. Where should you begin? This page contains a high-level overview of wireless Java technology and many links to detailed information about specific subjects.

Overview of Wireless Communications

Wireless communications is a huge field, encompassing everything from radio and television broadcasting through pagers, mobile phones, and satellite communications. The field of mobile phones is expanding very fast at the same time that standards and protocols are being adopted, used, updated, and sometimes discarded. The other rapidly expanding part of the wireless world is that of wireless local area networks (LANs). Driven by widespread acceptance of the IEEE 802.11 standard, wireless local networking for computers and other devices is spreading rapidly.

Although wireless may seem like a special case, it is actually more intuitive and more natural than wired networking. Some day soon the need to plug a laptop into a network physically will seem quaint and antiquated. The notion that you could walk into a room with your cell phone and have it unable to interact with other devices in the room will seem unbelievably primitive. The future will reveal that wired networks are the special case.

Conceptually, wireless communications can be split into two types, local and wide area. A local device is similar to a key fob with a button that unlocks a car, a 900 MHz cordless phone, a radio control toy, or a Bluetooth network. All of these devices operate over short distances, typically just a few meters.

Wide area wireless devices operate effectively over a much greater area. A pager or mobile phone is a good example; you can talk on your mobile phone to any other phone on the planet. These devices' greater range relies on a trick, however: a more elaborate land-based network. A mobile phone doesn't have that much more radio power than a radio control toy. What it does have is a network of carefully placed radio antennas (cell towers); the phone can continue to operate as long as it is within range of at least one tower. The mobile phone device receives service from a wireless carrier, a company that operates the land-based network.

While a number of industry consortia and standard bodies, such as the International Telecommunication Union, are trying to define or foster the development of standards for the wireless world, today's wireless world is still fragmented and complex. If you buy a mobile phone in the U.S. today, it might run on Motorola's iDEN network or Sprint's PCS network. Take it overseas to Europe and you'll be out of luck--your phone will not work with Europe's GSM network, nor will it work with the PDC network or any of the other mobile networks that live in Japan.

http://developers.sun.com/mobility/getstart/

Thursday, May 28, 2009

Look Mom, No Electricity


"Look Mom, No Electricity"
Self-powered "infofuses" use chemical reactions to transmit coded messages as far as two kilometers.
Monday, May 25, 2009
By Katherine Bourzac


The data encoding these words was carried as pulses of light on its journey from my computer to yours. But, as new research demonstrates, using light to carry encoded alphanumeric messages over long distances doesn't require computers, optical fiber, or even electricity.

By patterning flammable metallic salts on a nitrocellulose fuse, researchers at Harvard and Tufts University have encoded messages that can be transmitted without the need for a power source. When one fuse burns, the metallic salts along its length emit pulses of infrared and visible light of different colors whose sequence encodes, "LOOK MOM NO ELECTRICITY." The system, described today in the journal Proceedings of the National Academy of Sciences, is inspired by chemical information storage in biological cells.

David Walt, professor of chemistry at Tufts and Harvard's George Whitesides developed the infofuses in response to a call from the Defense Advanced Research Projects Agency (DARPA) for technologies to allow soldiers stranded without a power source to communicate. DARPA wanted "something that doesn't require any electronics or heavy equipment to lug around," says Walt.

Civilians stranded in a mountainous area without cell reception could use the infofuses, too, Walt says. His cell phone dropped our call a moment later. When he called back, I suggested maybe he needed an infofuse now. "That's the problem--it doesn't work over three thousand miles," he says. The group is now working on extending the range of the optics used to read the signal, which can currently be read from 600 meters away in bright ambient light using a CCD camera; Walt says 1.5 kilometers should be possible using the current optics. "We're [also] trying to figure out a way to dynamically encode a message on the fly in the field without specialized equipment," says Walt. So far they've used micropipetters and ink-jet printers to pattern the fuses.

http://www.technologyreview.com/blog/editors/23561/


Evolution of cooperation by phenotypic similarity

The emergence of cooperation in populations of selfish individuals is a fascinating topic that has inspired much work in theoretical biology. Here, we study the evolution of cooperation in a model where individuals are characterized by phenotypic properties that are visible to others. The population is well mixed in the sense that everyone is equally likely to interact with everyone else, but the behavioral strategies can depend on distance in phenotype space. We study the interaction of cooperators and defectors. In our model, cooperators cooperate with those who are similar and defect otherwise. Defectors always defect. Individuals mutate to nearby phenotypes, which generates a random walk of the population in phenotype space. Our analysis brings together ideas from coalescence theory and evolutionary game dynamics. We obtain a precise condition for natural selection to favor cooperators over defectors. Cooperation is favored when the phenotypic mutation rate is large and the strategy mutation rate is small. In the optimal case for cooperators, in a one-dimensional phenotype space and for large population size, the critical benefit-to-cost ratio is given by . b/c = 1 + 2 / square root of 3. We also derive the fundamental condition for any two-strategy symmetric game and consider high-dimensional phenotype spaces.

http://www.pnas.org/content/106/21/8597

Paper Diagnostics


March/April 2009
TR10: Paper Diagnostics
George Whitesides has created a cheap, easy-to-use diagnostic test out of paper. 

By Kristina Grifantini


Diagnostic tools that are cheap to make, simple to use, and rugged enough for rural areas could save thousands of lives in poor parts of the world. To make such devices, Harvard University professor George Whitesides is coupling advanced microfluidics with one of humankind's oldest technologies: paper. The result is a versatile, disposable test that can check a tiny amount of urine or blood for evidence of infectious diseases or chronic conditions.

The finished devices are squares of paper roughly the size of postage stamps. The edge of a square is dipped into a urine sample or pressed against a drop of blood, and the liquid moves through channels into testing wells. Depending on the chemicals present, different reactions occur in the wells, turning the paper blue, red, yellow, or green. A reference key is used to interpret the results. 



Color change: Paper tests, such as those shown here, could make it possible to diagnose a range of diseases quickly and cheaply. A small drop of liquid, such as blood or urine, wicks in through the corner or back of the paper and passes through channels to special testing zones. Substances in these zones react with specific chemicals in the sample to indicate different conditions; results show up as varying colors. These tests are small, simple, and inexpensive. 


Credit: Bruce Peterson 

The squares take advantage of paper's natural ability to rapidly soak up liquid­s, thus circumventing the need for pumps and other mechanical components common in microfluidic devices. The first step in building the devices is to creat­e tiny channels, about a millimete­r in width, that direct the fluid to the test wells. Whiteside­s and his coworkers soak the paper with a light-­sensitive photo­resist; ultraviolet light causes polymers in the photoresist to cross-link and harden, creating long, waterproof walls wherever the light hits it. The researchers can even create the desired channels and wells by simply drawing on the paper with a black marker and laying it in sunlight. "What we do is structure the flow of fluid in a sheet, taking advantage of the fact that if the paper is the right kind, fluid wicks and hence pulls itself along the channels," says Whiteside­s. Each well is then brushed with a different solution that reacts with specific molecules in blood or urine to trigger a color change.

Paper is ­easily incinerated, making it easy to safely dispose of used tests. And while paper-based diagnostics (such as pregnancy tests) already exist, Whitesides­'s device has an important advantage: a single square can perform many reactions, giving it the potential to diagnose a range of conditions. Meanwhile, its small size means that blood tests require only a tiny sample, allowing a user to simply prick a finger. 

Currently, Whitesides is developing a test to diagnose liver failure, which is indicated by elevated levels of certain enzymes in blood. In countries with advanced health care, people who take certain medications undergo regular blood tests to screen for liver problems that the drugs can cause. But people without consistent access to health care do not have that luxury; a paper-based test could give them the same safety margin. ­Whitesides also wants to develop tests for infectious diseases such as tuberculosis.

To disseminate the technology, ­Whitesides cofounded the nonprofit Diagnostics for All in Brookline, MA, in 2007. It plans to deploy the liver function tests in an African country around the end of this year. The team hopes that eventually, people with little medical training can administer the tests and photograph the results with a cell phone. Whitesides envisions a center where technicians and doctors can evaluate the images and send back treatment recommendations. 

"This is one of the most deployable devices I have seen," says Albert Folch, an associate professor of bioengineering at the University of Washington, who works with microfluidics. "What is so incredibly clever is that they were able to create photoresist structures embedded inside paper. At the same time, the porosity of the paper acts as the cheapest pump on the planet."

Recently, the Harvard researchers have made the paper chips into a three-­dimensional diagnostic device by layering them with punctured pieces of waterproof tape. A drop of liquid can move across channels and into wells on the first sheet, diffuse down through the holes in the tape, and react in test wells on the second paper layer. The ability to perform many more tests and even carry out two-step reactions with a single sample will enable the device to detect diseases (like malaria or HIV) that require more complicated assays, such as those that use antibodies. Results appear after five minutes to half an hour, depending on the test.

The researchers hope the advanced version of the test can eventually be mass produced using the same printing tech­nology that churns out newspapers. Cost for the materials should be three to five cents. At that price, says Folch, the tests "will have a big impact on health care in areas where transportation and energy access is difficult."

http://www.technologyreview.com/biomedicine/22113/