diff --git a/beehive-netui-tags/src/main/java/org/apache/beehive/netui/tags/html/HtmlBaseTag.java b/beehive-netui-tags/src/main/java/org/apache/beehive/netui/tags/html/HtmlBaseTag.java index f563064..446d0e0 100644 --- a/beehive-netui-tags/src/main/java/org/apache/beehive/netui/tags/html/HtmlBaseTag.java +++ b/beehive-netui-tags/src/main/java/org/apache/beehive/netui/tags/html/HtmlBaseTag.java @@ -86,6 +86,72 @@ abstract public class HtmlBaseTag extends AbstractClassicTag tsh.styleClass = styleClass; } + /** + * Set the ID of the tag. + * @param id the tagId. A value is required. + * @jsptagref.attributedescription

String value. Sets the id (or name) attribute of the rendered HTML tag. + * Note that the real id attribute rendered in the browser may be + * changed by the application container (for example, Portal containers may change + * the rendered id value to ensure the uniqueness of + * id's on the page). In this case, the real id rendered + * in the browser may be looked up + * through the JavaScript function lookupIdByTagId( tagId, tag ). + * + *

For example, assume that some tag's tagId attribute is set to foo. + * + *

    <netui:textBox tagId="foo" />
+ * + *

Then the following JavaScript function will return the real id attribute rendered in the browser: + * + *

    lookupIdByTagId( "foo", this )
+ * + *

To get a <netui:form> element and all of its children elements in JavaScript, use + * the same JavaScript function lookupIdByTagId( tagId, tag ). For example, + * assume that there is a <netui:form> whose + * tagId attribute is set to bar. + * + *

    <netui:form tagId="bar" >
+ * + *

Then the following JavaScript function will return the <netui:form> element + * and its children (packaged as an array). + * + *

    document[lookupIdByTagId( "bar", this )]
+ * + *

To retreive the value entered into a <netui:textBox> within the <netui:form> tag, use the following + * JavaScript expression. + * + *

    document[lookupIdByTagId("bar", this)][lookupIdByTagId("foo", this)].value
+ * + *

The second parameter ensures that the JavaScript function + * begins its search within the correct Portlet scope. Pass the + * JavaScript keyword this as the second parameter. + * @jsptagref.databindable false + * @jsptagref.attributesyntaxvalue string_tagId + * @netui:attribute required="false" rtexprvalue="true" + * description="String value. Sets the id (or name) attribute of the rendered HTML tag. " + */ + public void setId(String id) + { + super.setId(id); + try { + setTagId(id); + } catch (JspException e) { + e.printStackTrace(); + } + } + + /** + * Return the ID of the tag. The id may be rewritten by the container (such + * as a portal) to make sure it is unique. JavaScript may lookup the actual id + * of the element by looking it up in the netui_names table written + * into the HTML. + * @return the tagId. + */ + public String getId() + { + return getTagId(); + } + /** * Set the ID of the tag. * @param tagId the tagId. A value is required.