01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.wicket.extensions.wizard;
18:
19: import org.apache.wicket.markup.html.form.Button;
20: import org.apache.wicket.model.ResourceModel;
21:
22: /**
23: * Base class for buttons that work with {@link IWizard the wizard component}.
24: * It uses resource bundles to display the button label.
25: * <p>
26: * When wizard buttons are presses (and they pass validation if that is
27: * relevant), they pass control to {@link #onClick() their action method},
28: * which should do the real work.
29: * </p>
30: *
31: * @author Eelco Hillenius
32: */
33: public abstract class WizardButton extends Button {
34: /**
35: * The enclosing wizard.
36: */
37: private final IWizard wizard;
38:
39: /**
40: * Construct.
41: *
42: * @param id
43: * The component id
44: * @param wizard
45: * The wizard
46: * @param labelResourceKey
47: * The resource key of the button's label
48: */
49: public WizardButton(String id, IWizard wizard,
50: String labelResourceKey) {
51: super (id, new ResourceModel(labelResourceKey));
52: this .wizard = wizard;
53: }
54:
55: /**
56: * Gets the {@link IWizard}.
57: *
58: * @return The wizard
59: */
60: protected final IWizard getWizard() {
61: return wizard;
62: }
63:
64: /**
65: * Gets the {@link IWizardModel wizard model}.
66: *
67: * @return The wizard model
68: */
69: protected final IWizardModel getWizardModel() {
70: return getWizard().getWizardModel();
71: }
72:
73: /**
74: * Called when this button is clicked.
75: */
76: protected abstract void onClick();
77:
78: /**
79: * @see org.apache.wicket.markup.html.form.Button#onSubmit()
80: */
81: public final void onSubmit() {
82: onClick();
83: }
84: }
|