2 * Copyright 2005-2010 the original author or authors.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.wamblee.wicket.behavior;
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;
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 not possible however 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.
35 * @author Erik Brakkee
38 public class PreselectionBehavior extends AbstractJQueryBehavior {
40 static final String PRESELECT_SCRIPT = "wamblee-preselect.js";
42 private static HeaderContributor PRESELECTION_BEHAVIOR = JavascriptPackageResource
43 .getHeaderContribution(PreselectionBehavior.class, PRESELECT_SCRIPT);
45 public PreselectionBehavior() {
46 super("preselectionSetup", new NamespaceBehavior(), PRESELECTION_BEHAVIOR);