java.lang.Object
com.semanticcms.core.servlet.PageRefResolver
Helper utilities for resolving PageRefs.
-
Method Summary
Modifier and TypeMethodDescriptionstatic PageRef
getCurrentPageRef
(ServletContext servletContext, HttpServletRequest request) Finds the path to the current page.static PageRef
getCurrentPageRef
(ServletContext servletContext, HttpServletRequest request, boolean requireBook) Finds the path to the current page, optionally returningnull
when the current page is not in a book.static PageRef
getPageRef
(String book, String path) Gets a PageRef in the current page context.static PageRef
getPageRef
(ServletContext servletContext, HttpServletRequest request, String book, String path) Resolves a PageRef.
-
Method Details
-
getCurrentPageRef
public static PageRef getCurrentPageRef(ServletContext servletContext, HttpServletRequest request) throws ServletException Finds the path to the current page. The current page must be in a Book.- Throws:
ServletException
- See Also:
-
getCurrentPageRef
public static PageRef getCurrentPageRef(ServletContext servletContext, HttpServletRequest request, boolean requireBook) throws ServletException Finds the path to the current page, optionally returningnull
when the current page is not in a book.- Parameters:
requireBook
- affects the behavior when the current page is not in a book. Whentrue
, aServletException
is thrown. Whenfalse
,null
is returned.- Throws:
ServletException
- See Also:
-
getPageRef
public static PageRef getPageRef(ServletContext servletContext, HttpServletRequest request, String book, String path) throws ServletException, MalformedURLException Resolves a PageRef. When book is not provided, path may be book-relative path, which will be interpreted relative to the current page.Resolves the bookName to use. If the provided book is null, uses the book of the current page. Otherwise, uses the provided book name.
- Parameters:
book
- empty string is treated same as nullpath
- required non-empty- Throws:
ServletException
- If no book provided and the current page is not within a book's content.MalformedURLException
- See Also:
-
getPageRef
public static PageRef getPageRef(String book, String path) throws ServletException, MalformedURLException Gets a PageRef in the current page context.- Throws:
ServletException
MalformedURLException
- See Also:
-