blob: 99ace506d5d74094e3defcef365b818c5a89afff [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<!-- /*******************************************************************************
* Copyright (c) 2000, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/ -->
<link rel="stylesheet" type="text/css" href="../../org.eclipse.wst.doc.user/common.css" />
<title>Creating a new listener class</title>
</head>
<body id="twlstnwz"><a name="twlstnwz"><!-- --></a>
<h1 class="topictitle1">Creating a new listener class</h1>
<div><div class="skipspace"> <p> The Life-cycle Listener wizard enables you to create Java™ listener
classes for various J2EE listener types related to servlet context and session
events and attributes.</p>
<p>To create a listener class, do the following: </p>
</div>
<ol><li class="skipspace"><span>Open the Life-cycle Listener wizard. To do this, open the Web
perspective and from the Project Explorer, expand the project (that you have
created), and expand the deployment descriptor icon. Then right click on the <b>Listener</b> icon,
and select <span class="menucascade"><span class="uicontrol">New</span> &gt; <span class="uicontrol">Life-cycle Listener</span></span> from the pop-up menu.</span> The <span class="uicontrol">Create
Listener</span> wizard appears.</li>
<li class="skipspace"><span>Specify a listener class. To use an existing class, select the
appropriate check box and then use the <b>Browse</b> button to locate the
class. Otherwise, select <b>Next</b>.</span></li>
<li class="skipspace"><span>Supply the following information: </span> <ul><li>The folder where the listener class will be placed</li>
<li>The Java package that the class will belong to (it is added into a default
package if you do not specify one)</li>
<li>The class name of the listener. <div class="note"><span class="notetitle">Note: </span>You should place the listener in
the Java source
folder.</div>
</li>
<li>The superclass for the listener class. A listener created by this wizard
can have Object, or any class that has Object in its hierarchy, as its superclass.
Click <span class="uicontrol">Browse</span> to choose from the available superclasses.</li>
</ul>
</li>
<li class="skipspace"><span>Click <span class="uicontrol">Next</span>.</span></li>
<li class="skipspace"><span>Select a modifier to specify whether your listener classes are
public, abstract, or final. (Classes cannot be both abstract and final.)</span></li>
<li class="skipspace"><span>You can also add additional interfaces to implement in addition
to the default interfaces. Click <span><span class="uicontrol">Add</span></span> to open
the <span><span class="uicontrol">Interface Selection</span></span> dialog. In this dialog,
as you type the name of the interface that you are interested in adding in
the <span><span class="uicontrol">Choose interfaces</span></span> field, the list of available
interfaces listed in the <span><span class="uicontrol">Matching types</span></span> list
box updates dynamically to display only the interfaces that match the pattern.
Choose an interface to see the <span class="uicontrol">Qualifier</span> and click <span class="uicontrol">Add</span>.
Click <span class="uicontrol">OK</span> when you are finished.</span></li>
<li class="skipspace"><span>Choose which method stub you want to create. </span> The <span><span class="uicontrol">Inherited
abstract methods</span></span> and <span><span class="uicontrol">Constructors from superclass</span></span> options
add stubs for inherited abstract methods and superclass constructors that
must be implemented (unless you intend to create an abstract listener). One
method with the <span class="uicontrol">Inherited abstract methods</span> option must
be created for the class not to be abstract. </li>
<li class="skipspace"><span>Click <span class="uicontrol">Finish</span>.</span></li>
</ol>
<div class="skipspace"><p>The listener class that you created appears under the Listener
icon.</p>
</div>
</div>
<div><p><b class="relconceptshd">Related concepts</b><br />
<a href="ccwebxml.html" title="">The Web deployment descriptor editor</a><br />
</p>
</div>
</body>
</html>