"Fossies" - the Fresh Open Source Software Archive

Member "apidocs/src-html/org/apache/tapestry5/corelib/mixins/OverrideFieldFocus.html" (9 Sep 2020, 5278 Bytes) of package /linux/www/apache-tapestry-5.6.1-apidocs.zip:


Caution: In this restricted "Fossies" environment the current HTML page may not be correctly presentated and may have some non-functional links. You can here alternatively try to browse the pure source code or just view or download the uninterpreted raw source code. If the rendering is insufficient you may try to find and view the page on the project site itself.

001// Licensed under the Apache License, Version 2.0 (the "License");
002// you may not use this file except in compliance with the License.
003// You may obtain a copy of the License at
004//
005//     http://www.apache.org/licenses/LICENSE-2.0
006//
007// Unless required by applicable law or agreed to in writing, software
008// distributed under the License is distributed on an "AS IS" BASIS,
009// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
010// See the License for the specific language governing permissions and
011// limitations under the License.
012
013package org.apache.tapestry5.corelib.mixins;
014
015import org.apache.tapestry5.Field;
016import org.apache.tapestry5.FieldFocusPriority;
017import org.apache.tapestry5.annotations.AfterRender;
018import org.apache.tapestry5.annotations.Environmental;
019import org.apache.tapestry5.annotations.InjectContainer;
020import org.apache.tapestry5.ioc.annotations.Inject;
021import org.apache.tapestry5.services.javascript.JavaScriptSupport;
022import org.slf4j.Logger;
023
024/**
025 * A mixin that let a {@link org.apache.tapestry5.Field} gain focus.
026 *
027 * This supersede {@link org.apache.tapestry5.corelib.mixins.FormFieldFocus} in 5.4
028 *
029 * @since 5.4
030 * @tapestrydoc
031 */
032public class OverrideFieldFocus
033{
034    @Inject
035    private Logger logger;
036
037    /**
038     * The outer Form
039     */
040    @InjectContainer
041    private Field container;
042
043    @Environmental
044    private JavaScriptSupport javascriptSupport;
045
046
047    @AfterRender
048    void focusField()
049    {
050        javascriptSupport.autofocus(FieldFocusPriority.OVERRIDE, container.getClientId());
051
052        logger.trace("Focus OVERRIDE done on field {}", container.getClientId());
053    }
054
055}