blob: 3fd8542a1d998413d947891abffbfdaa9744be0e [file] [log] [blame]
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<body>
Provides renderable HTML controls. Controls implement the
{@link org.apache.click.Control} interface to perform server side request
processing. At the top level a Pages controls are processed by the
ClickServlet. Some controls can contain child controls which they will inturn
process. These container controls include Form, FieldSet, Panel and Table.
<p/>
Using these controls are similar to traditional Swing GUI programming. While these
controls do not provide a full Swing style MVC implementation, they provide a
simplified programming model and high performance.
<h3>Action Listeners</h3>
Controls extending {@link org.apache.click.control.AbstractControl} can use an action
listener event callback mechanism similar the <tt>java.awt.ActionListener</tt> callback.
<p/>
Click supports two styles of action listeners, the first is using the
{@link org.apache.click.ActionListener} interface which provides compile time safety.
The second is to register the action listener via the <tt>setListener(Object, String)</tt>
method where you specify the call back method via its name. This second style uses
less lines of code, but has no compile time safety.
<p/>
Examples of these two action listener styles are provided below:
<pre class="prettyprint">
public class ActionDemo extends Page {
// Uses listener style 1
&#064;Bindable public ActionLink link = new ActionLink();
// Uses listener style 2
&#064;Bindable public ActionButton button = new ActionButton();
public ActionDemo() {
// Verbose but provides compile time safety
link.setActionListener(new ActionListener() {
public boolean onAction(Control source) {
return onLinkClick(source);
}
});
// Succinct but typos will cause runtime errors
button.setListener(this, "onButtonClick");
}
// Event Handlers ---------------------------------------------------------
public boolean onLinkClick(Control source) {
..
return true;
}
public boolean onButtonClick() {
..
return true;
}
} </pre>
All call back listener methods must return a boolean value. If they return true
the further processing of other controls and page methods should continue.
Otherwise if they return false, then any further processing should be aborted.
By returning false you can effectively exit at this point and redirect or forward
to another page.
</body>