- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
Download at in Java
Download at QR Encoder In Java Using Barcode printer for Java Control to generate, create QR Code image in Java applications. www.OnBarcode.comQR Code ISO/IEC18004 Scanner In Java Using Barcode decoder for Java Control to read, scan read, scan image in Java applications. www.OnBarcode.comPortlet Basics
Creating DataBar In Java Using Barcode printer for Java Control to generate, create GS1 DataBar Stacked image in Java applications. www.OnBarcode.comCreating Barcode In Java Using Barcode printer for Java Control to generate, create Barcode image in Java applications. www.OnBarcode.comimport javax.portlet.ActionRequest; import javax.portlet.ActionResponse; import javax.portlet.GenericPortlet; import javax.portlet.PortletException; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; public class AdvancedPortlet extends GenericPortlet { protected void doEdit( RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException { renderResponse.setContentType("text/html"); Writer writer = renderResponse.getWriter(); //get the existing parameters to use as defaults. String title = renderRequest.getParameter("title"); String contents = renderRequest.getParameter("contents"); if (title == null) { title = ""; } if (contents == null) { contents = ""; } writer.write("<H1>Portlet Settings</H1>"); writer.write("<FORM ACTION="); writer.write(renderResponse.createActionURL().toString()); writer.write(">"); writer.write( "Title: <INPUT TYPE=text NAME=title VALUE='" + title + "' SIZE=25>"); writer.write( "Contents: <INPUT TYPE=text NAME=contents VALUE= '" + contents + "' SIZE=25>"); EAN 128 Encoder In Java Using Barcode encoder for Java Control to generate, create GTIN - 128 image in Java applications. www.OnBarcode.comMatrix 2D Barcode Encoder In Java Using Barcode maker for Java Control to generate, create 2D Barcode image in Java applications. www.OnBarcode.comDownload at
USS Code 128 Creator In Java Using Barcode printer for Java Control to generate, create USS Code 128 image in Java applications. www.OnBarcode.comDrawing Delivery Point Barcode (DPBC) In Java Using Barcode creator for Java Control to generate, create USPS POSTal Numeric Encoding Technique Barcode image in Java applications. www.OnBarcode.com 2
Denso QR Bar Code Reader In Java Using Barcode scanner for Java Control to read, scan read, scan image in Java applications. www.OnBarcode.comGenerating QR Code In Java Using Barcode encoder for Java Control to generate, create QR Code 2d barcode image in Java applications. www.OnBarcode.comwriter.write("<P>"); writer.write("<INPUT TYPE=submit>"); writer.write("</FORM>"); } protected void doHelp( RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException { //return a helpful message renderResponse.setContentType("text/html"); Writer writer = renderResponse.getWriter(); writer.write( "This portlet allows you to change its content and title."); } protected void doView( RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException { renderResponse.setContentType("text/html"); Writer writer = renderResponse.getWriter(); String contents = renderRequest.getParameter("contents"); if (contents != null) { writer.write(contents); } else { //return the default contents writer.write("This is the default portlet contents. } writer.write("<p>"); writer.write( "<IMG SRC=" + renderResponse.encodeURL( renderRequest.getContextPath() + "/images/picture.jpg") + ">"); To change "); writer.write("this message, edit the portlet's settings."); PDF-417 2d Barcode Recognizer In Java Using Barcode scanner for Java Control to read, scan read, scan image in Java applications. www.OnBarcode.comDrawing Code 3/9 In None Using Barcode printer for Word Control to generate, create Code-39 image in Office Word applications. www.OnBarcode.comDownload at
UPCA Generation In None Using Barcode maker for Microsoft Excel Control to generate, create GTIN - 12 image in Excel applications. www.OnBarcode.comCreate GS1 DataBar Expanded In .NET Using Barcode encoder for .NET Control to generate, create GS1 DataBar Limited image in .NET framework applications. www.OnBarcode.comPortlet Basics
Scan Barcode In Visual C#.NET Using Barcode decoder for VS .NET Control to read, scan read, scan image in Visual Studio .NET applications. www.OnBarcode.comData Matrix 2d Barcode Encoder In VS .NET Using Barcode generator for VS .NET Control to generate, create Data Matrix 2d barcode image in Visual Studio .NET applications. www.OnBarcode.comwriter.write("<p>"); writer.write( "<IMG SRC=http://www.greenninja.com/images/teton1-small.jpg>"); } protected String getTitle(RenderRequest renderRequest) { String title = renderRequest.getParameter("title"); if (title != null) { return title; } //else return a default title, if we don't have one set yet. return "Advanced Portlet"; } public void processAction( ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, IOException { //check for parameters String title = actionRequest.getParameter("title"); if (title != null) { actionResponse.setRenderParameter("title", title); } String contents = actionRequest.getParameter("contents"); if (contents != null) { actionResponse.setRenderParameter("contents", contents); } } } PDF417 Reader In None Using Barcode decoder for Software Control to read, scan read, scan image in Software applications. www.OnBarcode.comRead USS Code 128 In Visual C# Using Barcode decoder for VS .NET Control to read, scan read, scan image in Visual Studio .NET applications. www.OnBarcode.comWeb.xml Deployment Descriptor
Encoding Code128 In .NET Using Barcode encoder for Visual Studio .NET Control to generate, create Code 128 image in VS .NET applications. www.OnBarcode.comPainting EAN / UCC - 13 In .NET Framework Using Barcode creation for VS .NET Control to generate, create EAN 128 image in Visual Studio .NET applications. www.OnBarcode.comOur web.xml deployment descriptor s format did not change from the first portlet, although we updated the display name and description: < xml version="1.0" encoding="UTF-8" > <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" Download at
2
"http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name>Advanced Portlet</display-name> <description>An advanced portlet.</description> </web-app> Packaging and Deploying
We packaged the advanced portlet the same way we packaged the first portlet. We also deployed the advanced portlet with the same deployment tool and command line, substituting our new WAR file s path. You will need to add the new portlet application to the portletentityregistry.xml file that we edited for the first portlet. With both portlet applications, it should look like this: < xml version="1.0" encoding="UTF-8" > <portlet-entity-registry> <application id="first"> <definition-id>first</definition-id> <portlet id="firstportlet"> <definition-id>first.FirstPortlet</definition-id> </portlet> </application> <application id="advanced"> <definition-id>advanced</definition-id> <portlet id="advancedportlet"> <definition-id>advanced.AdvancedPortlet</definition-id> </portlet> </application> </portlet-entity-registry> We also added the advanced portlet to the pageregistry.xml file. The portal will display the first portlet side by side with the advanced portlet: < xml version="1.0" > <portal> <fragment name="navigation" class="org.apache.pluto.portalImpl.aggregation.navigation.TabNavigation"> </fragment> <fragment name="first" type="page"> <navigation> <title>First Portlet</title> <description>...</description> Download at
Portlet Basics
</navigation> <fragment name="row" type="row"> <fragment name="col1" type="column"> <fragment name="p1" type="portlet"> <property name="portlet" value="first.firstportlet"/> </fragment> <fragment name="p2" type="portlet"> <property name="portlet" value="advanced.advancedportlet"/> </fragment> </fragment> </fragment> </fragment> </portal> After editing these files, we restarted Tomcat.
Running
When you reload the portal page, you will see the portlets running next to each other in the portal page. Figure 2-2 shows both portlets running in one portal page. Figure 2-2. The first portlet and the advanced portlet on the same portal page
Download at
2
Summary We have built two simple portlets and packaged them into portlet application archives for distribution. You can deploy either portlet application on any portal container that complies with the Portlet API 1.0 standard. We discussed the PortletRequest, PortletResponse, and GenericPortlet classes from the portlet API. We also covered several basic concepts for portlet development in this chapter. In the next chapter, we will discuss the life cycle of a portlet, including initialization, request handling, and destruction. Download at
The Portlet Life Cycle
AS WE VE SEEN IN earlier chapters, portlets are conceptually very similar to servlets. Like servlets, they can only operate within a container. Both have obligations that their design must satisfy to allow them to interact with their container, and both demand clearly specified behavior from their containers. The portlet s obligations are, broadly speaking, to provide implementations of specific methods, to respond appropriately when these are invoked by the container, and to handle error conditions gracefully. This chapter describes the container s interactions with a portlet, starting with its creation and concluding with its destruction. It also considers the constraints that are incumbent upon both the portlet and the container at each step in this life cycle.
|
|