You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by pb...@apache.org on 2007/06/29 06:10:55 UTC
svn commit: r551789 - in /struts/struts1/trunk/taglib/src/main:
java/org/apache/struts/taglib/html/OptionTag.java
resources/META-INF/tld/struts-html.tld
Author: pbenedict
Date: Thu Jun 28 21:10:55 2007
New Revision: 551789
URL: http://svn.apache.org/viewvc?view=rev&rev=551789
Log:
STR-2072: Add title and titleKey
Modified:
struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/html/OptionTag.java
struts/struts1/trunk/taglib/src/main/resources/META-INF/tld/struts-html.tld
Modified: struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/html/OptionTag.java
URL: http://svn.apache.org/viewvc/struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/html/OptionTag.java?view=diff&rev=551789&r1=551788&r2=551789
==============================================================================
--- struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/html/OptionTag.java (original)
+++ struts/struts1/trunk/taglib/src/main/java/org/apache/struts/taglib/html/OptionTag.java Thu Jun 28 21:10:55 2007
@@ -107,6 +107,16 @@
private String dir = null;
/**
+ * The advisory title of this element.
+ */
+ private String title = null;
+
+ /**
+ * The message resources key of the advisory title.
+ */
+ private String titleKey = null;
+
+ /**
* The server value for this option, also used to match against the
* current property value to determine whether this option should be
* marked as selected.
@@ -229,6 +239,42 @@
this.dir = dir;
}
+ /**
+ * Returns the advisory title attribute.
+ *
+ * @since Struts 1.4
+ */
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ * Sets the advisory title attribute.
+ *
+ * @since Struts 1.4
+ */
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ /**
+ * Returns the message resources key of the advisory title.
+ *
+ * @since Struts 1.4
+ */
+ public String getTitleKey() {
+ return titleKey;
+ }
+
+ /**
+ * Sets the message resources key of the advisory title.
+ *
+ * @since Struts 1.4
+ */
+ public void setTitleKey(String titleKey) {
+ this.titleKey = titleKey;
+ }
+
// --------------------------------------------------------- Public Methods
/**
@@ -332,6 +378,12 @@
results.append("\"");
}
+ if (title != null || titleKey != null) {
+ results.append(" title=\"");
+ results.append(message(title, titleKey));
+ results.append("\"");
+ }
+
results.append(">");
results.append(text());
@@ -376,10 +428,42 @@
style = null;
styleClass = null;
text = null;
+ title = null;
+ titleKey = null;
value = null;
}
// ------------------------------------------------------ Protected Methods
+
+ /**
+ * Return the text specified by the literal value or the message resources
+ * key, if any; otherwise return <code>null</code>.
+ *
+ * @param literal Literal text value or <code>null</code>
+ * @param key Message resources key or <code>null</code>
+ * @throws JspException if both arguments are non-null
+ */
+ protected String message(String literal, String key)
+ throws JspException {
+ if (literal != null) {
+ if (key != null) {
+ JspException e =
+ new JspException(messages.getMessage("common.both"));
+
+ TagUtils.getInstance().saveException(pageContext, e);
+ throw e;
+ } else {
+ return (literal);
+ }
+ } else {
+ if (key != null) {
+ return TagUtils.getInstance().message(pageContext, getBundle(),
+ getLocale(), key);
+ } else {
+ return null;
+ }
+ }
+ }
/**
* Return the text to be displayed to the user for this option (if any).
Modified: struts/struts1/trunk/taglib/src/main/resources/META-INF/tld/struts-html.tld
URL: http://svn.apache.org/viewvc/struts/struts1/trunk/taglib/src/main/resources/META-INF/tld/struts-html.tld?view=diff&rev=551789&r1=551788&r2=551789
==============================================================================
--- struts/struts1/trunk/taglib/src/main/resources/META-INF/tld/struts-html.tld (original)
+++ struts/struts1/trunk/taglib/src/main/resources/META-INF/tld/struts-html.tld Thu Jun 28 21:10:55 2007
@@ -5973,6 +5973,31 @@
</description>
</attribute>
<attribute>
+ <name>title</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <description>
+ <![CDATA[
+ <p>The advisory title for this element.</p>
+ <dl><dt><b>Since:</b></dt>
+ <dd>Struts 1.4</dd></dl>
+ ]]>
+ </description>
+ </attribute>
+ <attribute>
+ <name>titleKey</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <description>
+ <![CDATA[
+ <p>The message resources key for the advisory title
+ for this element.</p>
+ <dl><dt><b>Since:</b></dt>
+ <dd>Struts 1.4</dd></dl>
+ ]]>
+ </description>
+ </attribute>
+ <attribute>
<name>value</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>