01: /*
02: * $Id: AjaxTabbedPanel.java 463910 2006-10-14 10:52:50Z knopp $ $Revision: 463910 $ $Date: 2006-10-14 12:52:50 +0200 (Sat, 14 Oct 2006) $
03: *
04: * ==============================================================================
05: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
06: * use this file except in compliance with the License. You may obtain a copy of
07: * 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, WITHOUT
13: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14: * License for the specific language governing permissions and limitations under
15: * the License.
16: */
17: package wicket.extensions.ajax.markup.html.tabs;
18:
19: import java.util.List;
20:
21: import wicket.ajax.AjaxRequestTarget;
22: import wicket.ajax.markup.html.AjaxFallbackLink;
23: import wicket.extensions.markup.html.tabs.TabbedPanel;
24: import wicket.markup.html.WebMarkupContainer;
25:
26: /**
27: * Ajaxified version of the tabbed panel. Uses AjaxFallbackLink instead of
28: * regular wicket links so it can update itself inplace.
29: *
30: * @author Igor Vaynberg (ivaynberg)
31: *
32: */
33: public class AjaxTabbedPanel extends TabbedPanel {
34: private static final long serialVersionUID = 1L;
35:
36: /**
37: * Constructor
38: *
39: * @param id
40: * @param tabs
41: */
42: public AjaxTabbedPanel(String id, List tabs) {
43: super (id, tabs);
44: setOutputMarkupId(true);
45:
46: setVersioned(false);
47: }
48:
49: protected WebMarkupContainer newLink(String linkId, final int index) {
50: return new AjaxFallbackLink(linkId) {
51:
52: private static final long serialVersionUID = 1L;
53:
54: public void onClick(AjaxRequestTarget target) {
55: setSelectedTab(index);
56: if (target != null) {
57: target.addComponent(AjaxTabbedPanel.this );
58: }
59: onAjaxUpdate(target);
60: }
61:
62: };
63: }
64:
65: /**
66: * A template method that lets users add additional behavior when ajax
67: * update occurs. This method is called after the current tab has been set
68: * so access to it can be obtained via {@link #getSelectedTab()}.
69: * <p>
70: * <strong>Note</strong> Since an {@link AjaxFallbackLink} is used to back
71: * the ajax update the <code>target</code> argument can be null when the client
72: * browser does not support ajax and the fallback mode is used. See
73: * {@link AjaxFallbackLink} for details.
74: *
75: * @param target
76: * ajax target used to update this component
77: */
78: protected void onAjaxUpdate(AjaxRequestTarget target) {
79: }
80:
81: }
|