Return-Path: X-Original-To: apmail-click-commits-archive@www.apache.org Delivered-To: apmail-click-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 06D15DA2C for ; Mon, 24 Sep 2012 13:42:41 +0000 (UTC) Received: (qmail 8972 invoked by uid 500); 24 Sep 2012 13:42:41 -0000 Delivered-To: apmail-click-commits-archive@click.apache.org Received: (qmail 8959 invoked by uid 500); 24 Sep 2012 13:42:40 -0000 Mailing-List: contact commits-help@click.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: click-dev@click.apache.org Delivered-To: mailing list commits@click.apache.org Received: (qmail 8950 invoked by uid 99); 24 Sep 2012 13:42:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Sep 2012 13:42:40 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Sep 2012 13:42:39 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 107F823889BF; Mon, 24 Sep 2012 13:41:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1389370 - /click/trunk/click/framework/src/org/apache/click/control/TextArea.java Date: Mon, 24 Sep 2012 13:41:56 -0000 To: commits@click.apache.org From: medgar@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120924134157.107F823889BF@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: medgar Date: Mon Sep 24 13:41:56 2012 New Revision: 1389370 URL: http://svn.apache.org/viewvc?rev=1389370&view=rev Log: CLK-794 Modified: click/trunk/click/framework/src/org/apache/click/control/TextArea.java Modified: click/trunk/click/framework/src/org/apache/click/control/TextArea.java URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/control/TextArea.java?rev=1389370&r1=1389369&r2=1389370&view=diff ============================================================================== --- click/trunk/click/framework/src/org/apache/click/control/TextArea.java (original) +++ click/trunk/click/framework/src/org/apache/click/control/TextArea.java Mon Sep 24 13:41:56 2012 @@ -98,6 +98,9 @@ public class TextArea extends Field { */ protected int minLength = 0; + /** The field HTML5 placeholder attribute. */ + protected String placeholder; + /** The number of text area rows. The default number of rows is three. */ protected int rows = 3; @@ -283,6 +286,36 @@ public class TextArea extends Field { } /** + * Return the textarea field HTML5 placeholder attribute. + *

+ * If the placeholder value is null, this method will attempt to find a + * localized placeholder message in the parent messages using the key: + *

+ * getName() + ".placeholder" + *
+ * If not found then the message will be looked up in the + * /click-control.properties file using the same key. If still + * not found the placeholder will be left as null and will not be rendered. + * + * @return the textarea field HTML5 placeholder attribute + */ + public String getPlaceholder() { + if (placeholder == null) { + placeholder = getMessage(getName() + ".placeholder"); + } + return placeholder; + } + + /** + * Set the textarea field HTML5 placeholder attribute. + * + * @param value the textarea field HTML5 placeholder attribute. + */ + public void setPlaceholder(String value) { + this.placeholder = value; + } + + /** * Return the number of text area rows. * * @return the number of text area rows @@ -342,9 +375,21 @@ public class TextArea extends Field { if (getTabIndex() > 0) { buffer.appendAttribute("tabindex", getTabIndex()); } + if (getMaxLength() > 0) { + buffer.appendAttribute("maxlength", getMaxLength()); + } + if (getFocus()) { + buffer.appendAttribute("autofocus", "autofocus"); + } appendAttributes(buffer); + if (!hasAttribute("placeholder")) { + if (getPlaceholder() != null) { + buffer.appendAttribute("placeholder", getPlaceholder()); + } + } + if (isDisabled()) { buffer.appendAttributeDisabled(); }