|
BEA NetUI tags and APIs are included for backward compatibility only. For new applications, use the Beehive tags and APIs. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.servlet.jsp.tagext.TagSupport javax.servlet.jsp.tagext.BodyTagSupport com.bea.wlw.netui.tags.AbstractBaseTag com.bea.wlw.netui.tags.html.Anchor
public class Anchor
Generates a hyperlink to a specified URI. Also adds support for URL re-writing and JavaScript-based form submission. An anchor must have one of five attributes to correctly create the hyperlink:
Attribute Descriptions | |||
---|---|---|---|
Attribute | Required | Runtime Expression Evaluation | Data Bindable |
accessKey | No | No | No |
Define the keyboard navigation key for the element. | |||
action | No | No | Read Only |
An action invoked by clicking the link. | |||
formSubmit | No | No | No |
True if clicking this link should submit its enclosing form . | |||
forward | No | No | No |
The logical forward name from which to retrieve the hyperlink URI. | |||
href | No | No | Read Only |
A URL destination to go to. | |||
id | No | No | No |
id is deprecated, use tagId. The id attribute of the generated Anchor. You should use the tagId which will encode the id correctly for containers such as the Portal which needs to rewrite id's to make them unique. | |||
linkName | No | No | No |
An internal place in the page to move to. | |||
location | No | No | No |
Location within the URI to visit | |||
page | No | No | No |
page is deprecated The module-relative page URL to which this hyperlink will be rendered. | |||
tagId | No | No | No |
The id of this anchor. The real id written to the HTML stream may be changed by the container (Portal),
but may be looked up with the 'tagId' value through the JavaScript method getNetuiTagName( tag, tagId ) method written by the <netui:html> tag. | |||
target | No | No | No |
The window target |
Form
,
Serialized FormIn this sample, clicking on this anchor submits the form data and invokes the method
submitForm
.
<netui:form action="formSubmit"> Firstname: <netui:textBox dataSource="{actionForm.firstname}"/> Lastname: <netui:textBox dataSource="{actionForm.lastname}"/> <netui:anchor formSubmit="true">Submit</netui:anchor> </netui:form>
If the formSubmit
attribute is set to true
and no
onClick
attribute is set, the following JavaScript function will be written to the HTML page.
This JavaScript function will be referenced by the onclick
attribute of the generated anchor tag.
function anchor_submit_form(netuiName, newAction) { for (var i=0; i<document.forms.length; i++) { if (document.forms[i].id == netuiName) { document.forms[i].method = "POST"; document.forms[i].action = newAction; document.forms[i].submit(); } } }
The JavaScript function will be invoked by the generated HTML anchor tag as follows:
<a href="/WebApp/tagSamples/anchor/formSubmit.do" onClick='anchor_submit_form("Netui_Form_0","/WebApp/tagSamples/anchor/formSubmit.do");return false;'>Submit</a>
Custom JavaScript Functions
It is possible to write a custom onClick
JavaScript event handler that would
do additional work, for example form validation, and still POST the form correctly. To
accomplish this, add the custom JavaScript method to the page:
function SubmitFromAnchor() { // implement custom logic here for(var i=0; i<document.forms.length; i++) { // submit to the action /aWebapp/formPost.do if (document.forms[i].action == "/aWebapp/formPost.do") { document.forms[i].method="POST"; document.forms[i].action="/aWebapp/formPost.do"; document.forms[i].submit(); } } }Then reference the JavaScript method from the <netui:anchor> tag:
<netui:anchor formSubmit="true" onClick="SubmitFromAnchor(); return false;">Submit</netui:anchor>
The <netui:anchor> tag generates a link to another document or invokes an action method in the Controller file. The <netui:anchor> tag also supports JavaScript-based form submission and URL re-writing.
An anchor must have one of five attributes to correctly create the hyperlink:
action
- the action method invoked by clicking the hyperlinkforward
- the forward to redirect tohref
- the URL to go tolinkName
- an internal place in the page to move topage
- the module-relative page URL to which this hyperlink will be rendered
Field Summary | |
---|---|
protected AnchorTag.State |
_state
|
static String |
HREF
|
protected String |
id
|
Fields inherited from class com.bea.wlw.netui.tags.AbstractBaseTag |
---|
ATTR_GENERAL, ATTR_GENERAL_EXPRESSION, ATTR_JAVASCRIPT, ATTR_STYLE, JAVASCRIPT_STATUS, NETUI_UNIQUE_CNT |
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport |
---|
bodyContent |
Fields inherited from class javax.servlet.jsp.tagext.TagSupport |
---|
pageContext |
Fields inherited from interface com.bea.wlw.netui.tags.html.HtmlConstants |
---|
ACCEPT, ACCESSKEY, ACTION, ALIGN, ALINK, ALT, ANCHOR, BACKGROUND, BASE, BGCOLOR, BODY, BORDER, BR, CAPTION, CELLPADDING, CELLSPACING, CHAR, CHAROFF, CHARSET, CHECKED, CLASS, COLS, COORDS, DIR, DISABLED, DIV, ENCTYPE, FOR, FORM, FORM_GET, FORM_POST, FRAME, HEIGHT, HREFLANG, HSPACE, HTML, ID, IMAGE, INPUT, INPUT_BUTTON, INPUT_CHECKBOX, INPUT_FILE, INPUT_HIDDEN, INPUT_IMAGE, INPUT_PASSWORD, INPUT_RADIO, INPUT_RESET, INPUT_SUBMIT, INPUT_TEXT, ISMAP, LABEL, LANG, LINK, LONGDESC, MAXLENGTH, METHOD, NAME, ONBLUR, ONCHANGE, ONCLICK, ONDBLCLICK, ONFOCUS, ONKEYDOWN, ONKEYPRESS, ONKEYUP, ONLOAD, ONMOUSEDOWN, ONMOUSEMOVE, ONMOUSEOUT, ONMOUSEOVER, ONMOUSEUP, ONRESET, ONSELECT, ONSUBMIT, ONUNLOAD, OPTION, READONLY, REL, REV, ROWS, RULES, SELECT, SHAPE, SIZE, SPAN, SRC, STYLE, SUMMARY, TABINDEX, TABLE, TARGET, TD, TEXT, TEXTAREA, TITLE, TR, TYPE, USEMAP, VALIGN, VALUE, VLINK, VSPACE, WIDTH |
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag |
---|
EVAL_BODY_BUFFERED, EVAL_BODY_TAG |
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag |
---|
EVAL_BODY_AGAIN |
Fields inherited from interface javax.servlet.jsp.tagext.Tag |
---|
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE |
Constructor Summary | |
---|---|
Anchor()
|
Method Summary | |
---|---|
void |
addParameter(String name,
Object value)
Adds a URL parameter to the generated hyperlink. |
protected String |
calculateURL(String forward,
String href,
String page,
String location)
Return the complete URL to which this hyperlink will direct the user. |
protected boolean |
createAnchorBeginTag(weblogic.utils.UnsyncStringBuffer results,
weblogic.utils.UnsyncStringBuffer script,
TagRenderingBase trb,
boolean encodeAction)
This method will take all of the internal variables and create an anchor. |
int |
doAfterBody()
Save the body content of the Anchor. |
int |
doEndTag()
Render the hyperlink. |
int |
doStartTag()
Prepare the hyperlink for rendering |
String |
getAccessKey()
Gets the accessKey attribute value. |
String |
getAction()
Return the action of the Anchor. |
protected String |
getFormAction()
|
protected String |
getFormActionURL()
|
boolean |
getFormSubmit()
Return the formSubmit indicator. |
String |
getForward()
Return the forward name of the Anchor. |
String |
getHref()
Return the href of the Anchor. |
String |
getId()
Return the ID associated with this tag. |
String |
getLinkName()
Return the link name of the Anchor. |
String |
getLocation()
Returns the anchor to be added to the end of the generated hyperlink. |
String |
getOnBlur()
Gets the onBlur javascript event. |
String |
getOnClick()
Gets the onClick javascript event. |
String |
getOnDblClick()
Gets the onDblClick javascript event. |
String |
getOnFocus()
Gets the onFocus javascript event. |
String |
getOnKeyDown()
Gets the onKeyDown javascript event. |
String |
getOnKeyPress()
Gets the onKeyPress javascript event. |
String |
getOnKeyUp()
Gets the onKeyUp javascript event. |
String |
getOnMouseDown()
Gets the onMouseDown javascript event. |
String |
getOnMouseMove()
Gets the onMouseMove javascript event. |
String |
getOnMouseOut()
Gets the onMouseOut javascript event. |
String |
getOnMouseOver()
Gets the onMouseOver javascript event. |
String |
getOnMouseUp()
Gets the onMouseUp javascript event. |
String |
getPage()
Returns the module-relative page URL to which this hyperlink will be rendered. |
protected String |
getRealFormName()
This will get the real name of the form. |
String |
getStyle()
Gets the style of the rendered html tag. |
String |
getStyleClass()
Gets the style class of the rendered html tag. |
String |
getTabindex()
Gets the tabIndex of the rendered html tag. |
String |
getTagId()
Return the ID of the tag. |
String |
getTagName()
Returns the name of the Tag. |
String |
getTarget()
Returns the window target. |
protected void |
localRelease()
Release any acquired resources. |
void |
setAccessKey(String accessKey)
Sets the accessKey attribute value. |
void |
setAction(String action)
Set the name of the action for the Anchor. |
void |
setAttribute(String name,
String value)
Set an attribute value. |
void |
setFormSubmit(boolean formSubmit)
Sets the formSubmit indicator. |
void |
setForward(String forward)
Sets the forward name of the Anchor. |
void |
setHref(String href)
Sets the href of the Anchor. |
void |
setId(String id)
Set the ID attribute of the tag. |
void |
setLinkName(String linkName)
Sets the link name of the Anchor. |
void |
setLocation(String location)
Sets the anchor to be added to the end of the generated hyperlink. |
void |
setOnBlur(String onblur)
Sets the onBlur javascript event. |
void |
setOnClick(String onclick)
Sets the onClick javascript event. |
void |
setOnDblClick(String ondblclick)
Sets the onDblClick javascript event. |
void |
setOnFocus(String onfocus)
Sets the onFocus javascript event. |
void |
setOnKeyDown(String onkeydown)
Sets the onKeyDown javascript event. |
void |
setOnKeyPress(String onkeypress)
Sets the onKeyPress javascript event. |
void |
setOnKeyUp(String onkeyup)
Sets the onKeyUp javascript event. |
void |
setOnMouseDown(String onmousedown)
Sets the onMouseDown javascript event. |
void |
setOnMouseMove(String onmousemove)
Sets the onMouseMove javascript event. |
void |
setOnMouseOut(String onmouseout)
Sets the onMouseOut javascript event. |
void |
setOnMouseOver(String onmouseover)
Sets the onMouseOver javascript event. |
void |
setOnMouseUp(String onmouseup)
Sets the onMouseUp javascript event. |
void |
setPage(String page)
Sets the module-relative page URL to which this hyperlink will be rendered. |
void |
setStyle(String style)
Sets the style of the rendered html tag. |
void |
setStyleClass(String styleClass)
Sets the style class of the rendered html tag. |
void |
setTabindex(String tabindex)
Sets the tabIndex of the rendered html tag. |
void |
setTagId(String tagId)
Set the ID of the tag. |
void |
setTarget(String target)
Sets the window target. |
protected String |
stripSlashes(String original)
|
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport |
---|
doInitBody, getBodyContent, getPreviousOut, setBodyContent |
Methods inherited from class javax.servlet.jsp.tagext.TagSupport |
---|
findAncestorWithClass, getParent, getValue, getValues, removeValue, setParent, setValue |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.servlet.jsp.tagext.Tag |
---|
getParent, setParent |
Field Detail |
---|
protected AnchorTag.State _state
protected String id
public static final String HREF
Constructor Detail |
---|
public Anchor()
Method Detail |
---|
public String getTagName()
getTagName
in class AbstractBaseTag
public void setAttribute(String name, String value) throws javax.servlet.jsp.JspException
name
represents
the name of the attribute.
The value
represents the value and may contain
a netui expression. This method may result in errors being generated.
This requires that the tag buffer its body and
write attributes in the end tag. For the anchor tag it is not legal to set
the id
, name
, or href
attributes with this method.
setAttribute
in interface IAttributeConsumer
name
- The name of the attribute. This value may not be null or the empty string.value
- The value of the attribute. This may contain a netui expression.
javax.servlet.jsp.JspException
- A JspException may be thrown if there is an error setting the attribute.public String getAction()
public void setAction(String action)
action
- - the name of the action to set for the Anchor.public boolean getFormSubmit()
public void setFormSubmit(boolean formSubmit)
formSubmit
- - whether or not the enclosing Form should be submitted.formSubmit
is set to true, and the <netui:anchor> tag
is within a <netui:form> tag,
then the form data will be submitted to the method named in the
<netui:form> tag's action
attribute.public String getForward()
public void setForward(String forward)
forward
- - the logical forward name from which to retrieve the hyperlink URI.public String getHref()
public void setHref(String href)
href
- - the hyperlink URI for the Anchor.public String getId()
getId
in class javax.servlet.jsp.tagext.TagSupport
public void setId(String id)
setId
in class javax.servlet.jsp.tagext.TagSupport
id
- - the ID.tagId
attribute instead.
The id attribute of the rendered HTML tag.public String getTagId()
netui_names
table written
into the HTML.
public void setTagId(String tagId)
tagId
- - the tagId.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 getNetuiTagName( 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:
getNetuiTagName( "foo", this )
To get a <netui:form> element and all of its children elements in JavaScript, use
the same JavaScript function getNetuiTagName( 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[getNetuiTagName( "bar", this )]
To retreive the value entered into a <netui:textBox> within the <netui:form> tag, use the following JavaScript expression.
document[getNetuiTagName("bar", this)][getNetuiTagName("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.
For detailed information on using the function
getNetuiTagName( tagId, tag )
see
Using JavaScript in Page Flow and Portal Applications.
public String getLinkName()
public void setLinkName(String linkName)
linkName
- - the link name for the Anchor.public String getLocation()
public void setLocation(String location)
location
- - the name of the location anchor.public String getPage()
public void setPage(String page)
page
- - the page URL.public String getTarget()
public String getAccessKey()
public void setAccessKey(String accessKey)
A, C, E, F, G,
H, V, left arrow, and right arrow
.
accessKey
- - the accessKey value.A, C, E, F, G,
H, V, left arrow, and right arrow
public void setTarget(String target)
target
- - the window target.public String getOnBlur()
public void setOnBlur(String onblur)
onblur
- - the onBlur event.public String getOnFocus()
public void setOnFocus(String onfocus)
onfocus
- - the onFocus event.public void addParameter(String name, Object value) throws javax.servlet.jsp.JspException
addParameter
in interface URLParams
name
- - the name of the parameter to be added.value
- - the value of the parameter to be added (a String or String[]).
javax.servlet.jsp.JspException
public int doStartTag() throws javax.servlet.jsp.JspException
doStartTag
in interface javax.servlet.jsp.tagext.Tag
doStartTag
in class javax.servlet.jsp.tagext.BodyTagSupport
javax.servlet.jsp.JspException
- if a JSP exception has occurredpublic int doAfterBody() throws javax.servlet.jsp.JspException
doAfterBody
in interface javax.servlet.jsp.tagext.IterationTag
doAfterBody
in class javax.servlet.jsp.tagext.BodyTagSupport
javax.servlet.jsp.JspException
- if a JSP exception has occurredpublic int doEndTag() throws javax.servlet.jsp.JspException
doEndTag
in interface javax.servlet.jsp.tagext.Tag
doEndTag
in class javax.servlet.jsp.tagext.BodyTagSupport
javax.servlet.jsp.JspException
- if a JSP exception has occurredprotected boolean createAnchorBeginTag(weblogic.utils.UnsyncStringBuffer results, weblogic.utils.UnsyncStringBuffer script, TagRenderingBase trb, boolean encodeAction) throws javax.servlet.jsp.JspException
javax.servlet.jsp.JspException
protected void localRelease()
localRelease
in class AbstractBaseTag
protected String calculateURL(String forward, String href, String page, String location) throws javax.servlet.jsp.JspException
javax.servlet.jsp.JspException
- if an exception is thrown calculating the valueprotected String getFormAction()
protected String getRealFormName()
protected String getFormActionURL()
protected String stripSlashes(String original)
public void setTabindex(String tabindex)
tabindex
- - the tab index.public String getTabindex()
public void setStyle(String style)
style
- - the html style.public String getStyle()
public void setStyleClass(String styleClass)
styleClass
- - the html style class.public String getStyleClass()
public String getOnClick()
public void setOnClick(String onclick)
onclick
- - the onClick event.public String getOnDblClick()
public void setOnDblClick(String ondblclick)
ondblclick
- - the onDblClick event.public String getOnKeyDown()
public void setOnKeyDown(String onkeydown)
onkeydown
- - the onKeyDown event.public String getOnKeyPress()
public void setOnKeyPress(String onkeypress)
onkeypress
- - the onKeyPress event.public String getOnKeyUp()
public void setOnKeyUp(String onkeyup)
onkeyup
- - the onKeyUp event.public String getOnMouseDown()
public void setOnMouseDown(String onmousedown)
onmousedown
- - the onMouseDown event.public String getOnMouseMove()
public void setOnMouseMove(String onmousemove)
onmousemove
- - the onMouseMove event.public String getOnMouseOut()
public void setOnMouseOut(String onmouseout)
onmouseout
- - the onMouseOut event.public String getOnMouseOver()
public void setOnMouseOver(String onmouseover)
onmouseover
- - the onMouseOver event.public String getOnMouseUp()
public void setOnMouseUp(String onmouseup)
onmouseup
- - the onMouseUp event.
|
BEA NetUI tags and APIs are included for backward compatibility only. For new applications, use the Beehive tags and APIs. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |