- java.lang.Object
-
- com.semanticcms.core.servlet.View
-
- All Implemented Interfaces:
Comparable<View>
public abstract class View extends Object implements Comparable<View>
A site may provide multiple views of the data. Except the default content view, views will typically show something about the current page and all of its children.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
View.Group
View groupings, in order.
-
Field Summary
Fields Modifier and Type Field Description protected static String
TITLE_SEPARATOR
The separator used between segments of the title.
-
Constructor Summary
Constructors Constructor Description View()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
compareTo(View o)
Orders by group, display, then name.void
configureResources(ServletContext servletContext, HttpServletRequest req, HttpServletResponse resp, Theme theme, Page page, Registry requestRegistry)
Configures the request-scope web resources that this view uses.abstract <__ extends FlowContent<__>>
voiddoView(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, __ flow, Page page)
Renders the view.boolean
equals(Object obj)
Two views with the same name are considered equal.abstract boolean
getAllowRobots(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Page page)
Gets whether robots are allowed to access this view to the given page.boolean
getAppliesGlobally()
Checks if a view applies in global navigation context.Set<Author>
getAuthors(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Page page)
Gets the author(s) for the view on the given page.String
getCanonicalUrl(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Page page)
Gets the canonical URL for the given page in this view.Copyright
getCopyright(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Page page)
Gets the copyright information for the view on the given page.abstract String
getDescription(Page page)
Gets the description for this view of the given page ornull
for none.abstract String
getDisplay()
Gets the display name for this view.abstract View.Group
getGroup()
Gets the grouping for this view.abstract String
getKeywords(Page page)
Gets the keywords for this view of the given page ornull
for none.ReadableInstant
getLastModified(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Page page)
Gets the effective last modified time, if known, for the given page in this view.String
getLinkCssClass(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response)
Gets the CSS class to use for the main navigation link to this view.String
getLinkId()
Gets an id to use for the main navigation link to this view.Map<String,List<String>>
getLinkParams(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Page page)
Gets the optional additional parameter to a view link.Collection<Link>
getLinks(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Page page)
Gets an optional set of additional links to include for this view in the order they should be added.abstract String
getName()
Gets the unique name of this view.Map<String,String>
getScripts()
Gets any per-view scripts, when have the same name as globally registered scripts, must have matching src.String
getTitle(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Page page)
Gets the page title for the view on the given page.int
hashCode()
Consistent with equals, hashCode based on name.boolean
isApplicable(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Page page)
Checks if a view is applicable the given request and page.boolean
isDefault()
Checks if this is the default view.String
toString()
-
-
-
Field Detail
-
TITLE_SEPARATOR
protected static final String TITLE_SEPARATOR
The separator used between segments of the title. Should this be provided by the template?- See Also:
- Constant Field Values
-
-
Method Detail
-
compareTo
public int compareTo(View o)
Orders by group, display, then name.- Specified by:
compareTo
in interfaceComparable<View>
-
equals
public boolean equals(Object obj)
Two views with the same name are considered equal.
-
hashCode
public int hashCode()
Consistent with equals, hashCode based on name.
-
toString
public String toString()
- Overrides:
toString
in classObject
- See Also:
getDisplay()
-
getGroup
public abstract View.Group getGroup()
Gets the grouping for this view.
-
getDisplay
public abstract String getDisplay()
Gets the display name for this view.
-
getName
public abstract String getName()
Gets the unique name of this view.
-
isDefault
public final boolean isDefault()
Checks if this is the default view.
-
getAppliesGlobally
public boolean getAppliesGlobally()
Checks if a view applies in global navigation context.Implementation Note:
returnstrue
by default
-
isApplicable
public boolean isApplicable(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Page page) throws ServletException, IOException
Checks if a view is applicable the given request and page. For correct determination, the page must have been captured atCaptureLevel.META
level or higher.TODO: Store the captureLevel in effect when a page is captured, and confirm that here and other places where certain capture levels are required for correct behavior. Could also automatically re-capture at a higher level instead of throwing an exception.
Implementation Note:
returnstrue
by default- Throws:
ServletException
IOException
-
getLinkId
public String getLinkId()
Gets an id to use for the main navigation link to this view.Implementation Note:
returnsnull
by default- Returns:
- the ID or null for none
-
getLinkCssClass
public String getLinkCssClass(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response)
Gets the CSS class to use for the main navigation link to this view.Implementation Note:
returnsnull
by default- Returns:
- the CSS class or null for none
-
getLinkParams
public Map<String,List<String>> getLinkParams(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Page page)
Gets the optional additional parameter to a view link.Implementation Note:
returns empty map by default
-
getCanonicalUrl
public String getCanonicalUrl(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Page page) throws ServletException, IOException
Gets the canonical URL for the given page in this view. Can not get canonical URLs for missing books. This might be called even when a page is not applicable to this view, such as when browing to an empty TODO list. By default,link parameters
are not added.This URL is absolute and has already been response encoded.
-
getLastModified
public ReadableInstant getLastModified(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Page page) throws ServletException, IOException
Gets the effective last modified time, if known, for the given page in this view. This is used for things such as sitemaps.Implementation Note:
This default implementation returnsnull
indicating not applicable to this view.- Returns:
- The effective last modified time or
null
if unknown or not applicable. - Throws:
ServletException
IOException
-
getCopyright
public Copyright getCopyright(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Page page) throws ServletException, IOException
Gets the copyright information for the view on the given page.
-
getAuthors
public Set<Author> getAuthors(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Page page) throws ServletException, IOException
Gets the author(s) for the view on the given page.
-
getTitle
public String getTitle(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Page page)
Gets the page title for the view on the given page.Defaults to: "view.display - page.title[ - page.pageRef.book.title]"
-
getDescription
public abstract String getDescription(Page page)
Gets the description for this view of the given page ornull
for none.
-
getKeywords
public abstract String getKeywords(Page page)
Gets the keywords for this view of the given page ornull
for none.
-
configureResources
public void configureResources(ServletContext servletContext, HttpServletRequest req, HttpServletResponse resp, Theme theme, Page page, Registry requestRegistry)
Configures the request-scope web resources that this view uses.Implementers should call
super.configureResources(…)
as a matter of convention, despite this default implementation doing nothing.
-
getLinks
public Collection<Link> getLinks(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Page page) throws ServletException, IOException
Gets an optional set of additional links to include for this view in the order they should be added.Please note, that any links to stylesheets here are never optimized. Please prefer
configureResources(javax.servlet.ServletContext, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, com.semanticcms.core.servlet.Theme, com.semanticcms.core.model.Page, com.aoapps.web.resources.registry.Registry)
.
-
getScripts
public Map<String,String> getScripts()
Gets any per-view scripts, when have the same name as globally registered scripts, must have matching src.Implementation Note:
returns empty map by default- See Also:
SemanticCMS.getScripts()
-
getAllowRobots
public abstract boolean getAllowRobots(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, Page page) throws ServletException, IOException
Gets whether robots are allowed to access this view to the given page. When true will include both "noindex, nofollow" in the head and put "nofollow" on links to this view.- Throws:
ServletException
IOException
-
doView
public abstract <__ extends FlowContent<__>> void doView(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, __ flow, Page page) throws ServletException, IOException, SkipPageException
Renders the view. This is called by the template to fill-out the main content area.TODO: Is SkipPageException acceptable at the view rendering stage?
-
-