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.
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.
Action Listeners
Controls extending {@link org.apache.click.control.AbstractControl} can use an action
listener event callback mechanism similar the java.awt.ActionListener callback.
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 setListener(Object, String)
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.
Examples of these two action listener styles are provided below:
public class ActionDemo extends Page {
// Uses listener style 1
@Bindable public ActionLink link = new ActionLink();
// Uses listener style 2
@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;
}
}
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.