itextsharp barcode vb.net How to Build and Install a Custom ViewHandler in Java

Generation Data Matrix in Java How to Build and Install a Custom ViewHandler

How to Build and Install a Custom ViewHandler
Data Matrix 2d Barcode Printer In Java
Using Barcode generation for Java Control to generate, create Data Matrix ECC200 image in Java applications.
Scanning ECC200 In Java
Using Barcode decoder for Java Control to read, scan read, scan image in Java applications.
This section shows how to build a simple ViewHandler This ViewHandler will not actually perform any of the view functions itself Instead, it delegates all of its functionality to the default ViewHandler This approach makes it easy to illustrate the steps required to create a custom ViewHandler It also gives you a skeleton that you can use to develop your own ViewHandler As with many things in the Java EE platform, a custom ViewHandler is declared using XML The ViewHandler is declared within the <application> element of the faces-config xml file There must be, at most, one ViewHandler declaration in this element because there is only one ViewHandler per Faces application instance As you will see in 18, the ordering of elements in the faces-configxml file is important If the <application> element is present, it must be the first child element of the <faces-config> element, as shown next
Barcode Generator In Java
Using Barcode printer for Java Control to generate, create barcode image in Java applications.
Read Bar Code In Java
Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications.
<faces-config> <application> <view-handler>comjsfcomprefvtlibutil TrainerViewHandler</view-handler> </application> <!-- the rest of the faces-config content -->
DataMatrix Drawer In C#.NET
Using Barcode drawer for .NET framework Control to generate, create DataMatrix image in .NET applications.
Making Data Matrix 2d Barcode In .NET Framework
Using Barcode maker for ASP.NET Control to generate, create Data Matrix image in ASP.NET applications.
There are two approaches to providing a custom ViewHandler to JSF, known as decoration and replacement These concepts are explained next
ECC200 Generator In Visual Studio .NET
Using Barcode generator for Visual Studio .NET Control to generate, create Data Matrix ECC200 image in .NET applications.
Data Matrix 2d Barcode Creator In Visual Basic .NET
Using Barcode printer for .NET Control to generate, create DataMatrix image in Visual Studio .NET applications.
13:
Make UPC Symbol In Java
Using Barcode printer for Java Control to generate, create GTIN - 12 image in Java applications.
Making Data Matrix In Java
Using Barcode printer for Java Control to generate, create Data Matrix 2d barcode image in Java applications.
A l t e r n a t e V i e w D e s c r i p t i o n Te c h n o l o g y a n d F a c e l e t s
Creating EAN128 In Java
Using Barcode encoder for Java Control to generate, create UCC-128 image in Java applications.
Generate Code 128 Code Set A In Java
Using Barcode generator for Java Control to generate, create Code 128A image in Java applications.
PART II
Making USS ITF 2/5 In Java
Using Barcode printer for Java Control to generate, create 2/5 Interleaved image in Java applications.
Read Data Matrix 2d Barcode In VB.NET
Using Barcode recognizer for Visual Studio .NET Control to read, scan read, scan image in Visual Studio .NET applications.
FIGURE 13-3 The relationship between ViewHandler and StateManager
Draw Code39 In Java
Using Barcode printer for Android Control to generate, create Code 39 Full ASCII image in Android applications.
Bar Code Generation In None
Using Barcode drawer for Software Control to generate, create barcode image in Software applications.
Part II:
Create GS1 128 In None
Using Barcode generator for Font Control to generate, create UCC-128 image in Font applications.
Encode UPC A In VS .NET
Using Barcode maker for .NET framework Control to generate, create UPC Code image in Visual Studio .NET applications.
Extending JavaServer Faces
UCC - 12 Drawer In VB.NET
Using Barcode printer for .NET framework Control to generate, create USS-128 image in VS .NET applications.
Generate Code 128C In Objective-C
Using Barcode drawer for iPad Control to generate, create Code 128B image in iPad applications.
Using Decoration for the Custom ViewHandler
As you learned in 12, many of the replaceable components in Faces allow the user to extend the existing implementation using the decorator design pattern To recap this concept, the decorator design pattern enables a developer to override as much or as little functionality of an existing object as desired The Faces specification requires the JSF runtime to guarantee that a custom ViewHandler declared in the faces-configxml file be passed the default ViewHandler in its constructor when the JSF runtime is starting up The following example shows how this is done in Faces 11
import javaxfacesapplicationViewHandler; public class TrainerViewHandler extends ViewHandler { private final ViewHandler parent; public TrainerViewHandler(ViewHandler parent) { thisparent = parent; } public Locale calculateLocale(FacesContext context) { return thisparentcalculateLocale(context); } public String calculateRenderKitId(FacesContext context) { return thisparentcalculateRenderKitId(context); } public UIViewRoot createView(FacesContext context, String viewId) { return thisparentcreateView(context, viewId); } public String getActionURL(FacesContext context, String viewId) { return thisparentgetActionURL(context, viewId); } public String getResourceURL(FacesContext context, String path) { return thisparentgetResourceURL(context, path); } public void renderView(FacesContext context, UIViewRoot viewToRender) throws IOException, FacesException { thisparentrenderView(context, viewToRender); } public void restoreView(FacesContext context, String viewId) { thisparentrestoreView(context, viewId); } public void writeState(FacesContext context) throws IOException { thisparentwriteState(context); } }
13:
A l t e r n a t e V i e w D e s c r i p t i o n Te c h n o l o g y a n d F a c e l e t s
This ViewHandler does nothing itself Instead, it simply delegates to the previous implementation for all methods However, you can adapt this skeleton to create your own ViewHandler by implementing one or more of the methods The important thing to observe about the preceding code is that it has a constructor that takes one argument, the existing ViewHandler Observe that there are eight public methods defined on ViewHandler In practice, a custom ViewHandler may delegate to the previous implementation for most of those methods The methods for which delegation is not practical are covered in the section later in this chapter titled The Design, Architecture, and Implementation of Facelets To clarify how the decorator pattern is implemented, let s examine how the JSF runtime handles the processing of the preceding faces-configxml file with the custom ViewHandler declaration
PART II
How the JSF Runtime Implements the Decorator Pattern
Figure 13-4 shows the steps taken by the JSF runtime to implement the decorator pattern Before the JSF runtime loads any faces-configxml files from the user, the runtime initializes its own set of default implementations for all the replaceable objects, including ViewHandler For this discussion, we ll refer to the default ViewHandler as DefaultViewHandler During startup, whenever the JSF implementation comes across a faces-configxml file with a <view-handler> element, it inspects that class for a public constructor that takes one argument of type ViewHandler In this case, the TrainerViewHandler does have such a constructor The JSF runtime invokes the constructor and passes DefaultViewHandler as the argument Because TrainerViewHandler wants to leverage the DefaultViewHandler instance to do the work of all the methods, it keeps a reference to DefaultViewHandler in an instance variable The JSF runtime replaces its reference to DefaultViewHandler with a reference to the new TrainerViewHandler As far as the runtime knows, DefaultViewHandler no longer exists In other words, the custom ViewHandler may choose to observe the decorator pattern or not If it doesn t keep a reference to the DefaultViewHandler, the custom ViewHandler is said to replace the DefaultViewHandler rather than decorate it Another way for a custom ViewHandler to handle replacement is to offer only a public no-argument constructor In this case, the JSF runtime will simply use that constructor to make the new instance and replace the DefaultViewHandler This process continues as the faces-configxml files are loaded until all startup processing is complete
Copyright © OnBarcode.com . All rights reserved.