Addition of tooltip behavior.
[utils] / wicket / components / src / main / java / org / wamblee / wicket / behavior / PreselectionBehavior.java
1 /*
2  * Copyright 2005-2010 the original author or authors.
3  * 
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  * 
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  * 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.wamblee.wicket.behavior;
17
18 import org.apache.wicket.Component;
19 import org.apache.wicket.Page;
20 import org.apache.wicket.behavior.HeaderContributor;
21 import org.apache.wicket.markup.html.IHeaderResponse;
22 import org.apache.wicket.markup.html.JavascriptPackageResource;
23 import org.wamblee.wicket.jquery.JQueryHeaderContributor;
24 import org.wamblee.wicket.jquery.AbstractJQueryBehavior;
25
26 /**
27  * Preselection behavior that preselects unaltered text in forms. When applied
28  * to a certain component, the behavior is valid for all children of the
29  * component. Therefore, it is possible to attach this behavior to any component,
30  * well as to a form or even individual fields in a form. It is also possible to apply this
31  * behavior to a page. The behavior applies
32  * to text input fields and textareas. Upon focus, the text in the field is
33  * selected if it it still identical to the default value.
34  * 
35  * @author Erik Brakkee
36  * 
37  */
38 public class PreselectionBehavior extends AbstractJQueryBehavior {
39
40     private static final String READY_FUNCTION = "org.wamblee.preselectionSetup";
41
42     static final String PRESELECT_SCRIPT = "wamblee-preselect.js";
43
44     private static HeaderContributor PRESELECTION_BEHAVIOR = JavascriptPackageResource
45         .getHeaderContribution(PreselectionBehavior.class, PRESELECT_SCRIPT);
46
47     public PreselectionBehavior() {
48         super(READY_FUNCTION, new SupportBehavior(), PRESELECTION_BEHAVIOR);
49     }
50 }