|
Version 4.10.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object SimpleTagSupport hirondelle.web4j.ui.tag.TagHelper hirondelle.web4j.ui.tag.HighlightCurrentPage
public class HighlightCurrentPage
Suppress self-linking anchor tags (links), where a link has the current page as its destination.
Self-linking is usually considered to be poor style, since the user is simply led back to the current page.
Rendering links to the current page in a distinct manner has two benefits :
This tag provides two distinct techniques for identifying self-linking:
If these policies are inadequate, then isSelfLinkingByHref(String, String)
and
isSelfLinkingByTitle(String, String)
may be overridden as desired.
Example use case.
<w:highlightCurrentPage styleClass="highlight"> <a href='ShowHomePage.do'>Home</a> <a href='ShowSearch.do'>Search</a> <a href='ShowContact.do'>Contact</a> </w:highlightCurrentPage>If the current URI is
http://www.blah.com/fish/main/home/ShowHomePage.dothen the output of this tag will be
<span class="highlight">Home</span> <a href='ShowSearch.do'>Search</a> <a href='ShowContact.do'>Contact</a>If the styleClass attribute is not used, then the output would simply be :
Home <a href='ShowSearch.do'>Search</a> <a href='ShowContact.do'>Contact</a>
This final example uses the TTitle mechanism :
<w:highlightCurrentPage useTitle="true"> <a href='ShowHomePage.do'>Home</a> <a href='ShowSearch.do'>Search</a> <a href='ShowContact.do'>Contact</a> </w:highlightCurrentPage>For a page with TTitle parameter as 'Home', the output of this tag would be as above:
Home <a href='ShowSearch.do'>Search</a> <a href='ShowContact.do'>Contact</a>
Nuisance restriction : the href attribute must appear as the first attribute in the <A> tags.
Constructor Summary | |
---|---|
HighlightCurrentPage()
|
Method Summary | |
---|---|
protected String |
getEmittedText(String aOriginalBody)
Alter any links in the tag body which refer to the current page. |
protected boolean |
isSelfLinkingByHref(String aCurrentURI,
String aHrefTarget)
Determine if self-linking is present, using the current URI and the link's HREF target. |
protected boolean |
isSelfLinkingByTitle(String aLinkText,
String aTTitle)
Determine if self-linking is present, using the link text and the TTitle request parameter. |
void |
setStyleClass(String aCascadingStyleSheetClassName)
Name of the Cascading Style Sheet class used for highlighting text related to the current page (optional). |
void |
setUseTitle(Boolean aUseTitle)
Use the TTitle request parameter passed to this page. |
Methods inherited from class hirondelle.web4j.ui.tag.TagHelper |
---|
checkForContent, crossCheckAttributes, doTag, getPageContext, getPageName, getRequest, getResponse |
Methods inherited from class SimpleTagSupport |
---|
findAncestorWithClass, getJspBody, getJspContext, getParent, setJspBody, setJspContext, setParent |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HighlightCurrentPage()
Method Detail |
---|
public final void setStyleClass(String aCascadingStyleSheetClassName)
For example, the link text could be highlighted in yellow in order to make it stand out more clearly from the other links. If this attribute is not specified, then the link text is simply presented as is, with no special styling.
aCascadingStyleSheetClassName
- satisfies Util.textHasContent(String)
.public final void setUseTitle(Boolean aUseTitle)
Optional. Default is false. If set to true, then the default mechanism is overridden, and self-linking pages will be identified by comparing the link text to the page TTitle parameter. (The TTitle parameter is used in the WEB4J page templating mechanism).
protected final String getEmittedText(String aOriginalBody)
See examples in the class comment.
getEmittedText
in class TagHelper
aOriginalBody
- is the evaluated body of this tag. If there is no body, or
if the body is present but empty, then it is null.
protected boolean isSelfLinkingByHref(String aCurrentURI, String aHrefTarget)
Overridable default implementation that simply checks if aCurrentURI ends with
aHrefTarget. In addition, aCurrentURI is passed through EscapeChars.forHrefAmpersand(String)
before the comparison is made. This ensures the text will match a valid HREF attribute.
protected boolean isSelfLinkingByTitle(String aLinkText, String aTTitle)
Overridable default implementation that checks if the trimmed aLinkText (the body of the <A> tag) and aTTitle are the same.
|
Version 4.10.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |