org.apache.wiki.url
Interface URLConstructor

All Known Implementing Classes:
DefaultURLConstructor, ShortURLConstructor, ShortViewURLConstructor

public interface URLConstructor

Provides an interface through which JSPWiki constructs URLs. JSPWiki calls the methods of this interface whenever an URL that points to any JSPWiki internals is required. For example, if you need to find an URL to the editor page for page "TextFormattingRules", you would call makeURL( WikiContext.EDIT, "TextFormattingRules", false, null );

Since:
2.2

Method Summary
 String getForwardPage(javax.servlet.http.HttpServletRequest request)
          Returns information which JSP page should continue handling this type of request.
 void initialize(WikiEngine engine, Properties properties)
          Initializes.
 String makeURL(String context, String name, boolean absolute, String parameters)
          Constructs the URL with a bunch of parameters.
 String parsePage(String context, javax.servlet.http.HttpServletRequest request, String encoding)
          Should parse the "page" parameter from the actual request.
 

Method Detail

initialize

void initialize(WikiEngine engine,
                Properties properties)
Initializes. Note that the engine is not fully initialized at this point, so don't do anything fancy here - use lazy init, if you have to.

Parameters:
engine - The WikiEngine that this URLConstructor belongs to
properties - Properties used to initialize

makeURL

String makeURL(String context,
               String name,
               boolean absolute,
               String parameters)
Constructs the URL with a bunch of parameters.

Parameters:
context - The request context (@see WikiContext) that you want the URL for
name - The page name (or in case of WikiContext.NONE, the auxiliary JSP page or resource you want to point at. This must be URL encoded. Null is NOT safe.
absolute - True, if you need an absolute URL. False, if both relative and absolute URLs are fine.
parameters - An URL parameter string (these must be URL-encoded, and separated with &)
Returns:
An URL pointing to the resource. Must never return null - throw an InternalWikiException if something goes wrong.

parsePage

String parsePage(String context,
                 javax.servlet.http.HttpServletRequest request,
                 String encoding)
                 throws IOException
Should parse the "page" parameter from the actual request. This is essentially the reverse of makeURL() - whenever a request constructed by calls to makeURL() is passed to this routine, it MUST be able to parse the resource name (WikiPage, Attachment, other resource) from the request.

Parameters:
context - In which request context the request was made (this should help in parsing)
request - The HTTP request that was used when coming here
encoding - The encoding with which the request was made (UTF-8 or ISO-8859-1).
Returns:
This method must return the name of the resource.
Throws:
IOException - If parsing failes

getForwardPage

String getForwardPage(javax.servlet.http.HttpServletRequest request)
Returns information which JSP page should continue handling this type of request.

Parameters:
request - The HTTP Request that was used to end up in this page.
Returns:
"Wiki.jsp", "PageInfo.jsp", etc. Just return the name, JSPWiki will figure out the page.


Copyright © {inceptionYear}-2014 The Apache Software Foundation. All rights reserved.