Version 4.10.0

hirondelle.web4j.ui.tag
Class HighlightCurrentPage

Object
  extended by SimpleTagSupport
      extended by hirondelle.web4j.ui.tag.TagHelper
          extended by hirondelle.web4j.ui.tag.HighlightCurrentPage
All Implemented Interfaces:
JspTag, SimpleTag

public class HighlightCurrentPage
extends TagHelper

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.do
 
then 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

HighlightCurrentPage

public HighlightCurrentPage()
Method Detail

setStyleClass

public final void setStyleClass(String aCascadingStyleSheetClassName)
Name of the Cascading Style Sheet class used for highlighting text related to the current page (optional).

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.

Parameters:
aCascadingStyleSheetClassName - satisfies Util.textHasContent(String).

setUseTitle

public final void setUseTitle(Boolean aUseTitle)
Use the TTitle request parameter passed to this page.

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).


getEmittedText

protected final String getEmittedText(String aOriginalBody)
Alter any links in the tag body which refer to the current page.

See examples in the class comment.

Specified by:
getEmittedText in class TagHelper
Parameters:
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.
Returns:
the text to display in the resulting web page.

isSelfLinkingByHref

protected boolean isSelfLinkingByHref(String aCurrentURI,
                                      String aHrefTarget)
Determine if self-linking is present, using the current URI and the link's HREF target.

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.


isSelfLinkingByTitle

protected boolean isSelfLinkingByTitle(String aLinkText,
                                       String aTTitle)
Determine if self-linking is present, using the link text and the TTitle request parameter.

Overridable default implementation that checks if the trimmed aLinkText (the body of the <A> tag) and aTTitle are the same.


Version 4.10.0

Copyright Hirondelle Systems. Published October 19, 2013 - User Guide - All Docs.