001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.ui.client.login; 029 030import com.google.gwt.core.client.Scheduler; 031import com.google.gwt.core.client.Scheduler.RepeatingCommand; 032import com.google.gwt.dom.client.Element; 033import com.vaadin.v7.client.ui.VTextField; 034 035/** 036 * Abstract superclass for the user name and password fields of the login dialog.<p> 037 * 038 * Since these fields may be pre-filled by the browser password manager and not by the server side 039 * component, they require some special handling.<p> 040 */ 041public class A_CmsLoginField extends VTextField { 042 043 /** True if the intial call to updateFieldContent has already occured. */ 044 private boolean m_initialUpdateCalled; 045 046 /** 047 * Creates a new instance based on an existing dom input element.<p> 048 * 049 * @param element the input element to use for the widget 050 */ 051 protected A_CmsLoginField(Element element) { 052 053 super(element); 054 } 055 056 /** 057 * @see com.vaadin.client.ui.VTextField#updateFieldContent(java.lang.String) 058 * 059 * We have to override this method to prevent its value being overwritten by Vaadin and to make 060 * sure that the real value is sent to the server. 061 */ 062 @Override 063 public void updateFieldContent(String text) { 064 065 if (!m_initialUpdateCalled) { 066 m_initialUpdateCalled = true; 067 if ("".equals(text)) { 068 valueChange(false); 069 Scheduler.get().scheduleFixedDelay(new RepeatingCommand() { 070 071 public boolean execute() { 072 073 if (isAttached()) { 074 valueChange(false); 075 return true; 076 } else { 077 return false; 078 } 079 } 080 }, 100); 081 return; 082 } 083 084 } 085 super.updateFieldContent(text); 086 } 087 088}