The SiteURLManager can generate URLs from site IDs, typically on requests from Oracle ATG Web Commerce servlet beans such as SiteLinkDroplet (see the ATG Page Developer's Guide). Given a site ID and path, you can use this servlet bean to write page code that generates links to different sites and paths. To create these links, the SiteURLManager maintains a map keyed by site IDs that are paired with URLs.

URL Construction Rules

The SiteURLManager constructs URLs for a requested site according to the following rules:

URL construction varies depending on whether production site URLs conform to a domain-based or path-based convention (see Production Site URL Conventions). The following examples show how SiteLinkDroplet generates URLs according to these diferent conventions.

Production-Site URLs Use Path-Based Strategy

Target site’s production site URL: /foo

Current URL: http://domain.com/bar/dir/index.jsp

Input Path

New URL

""

http://domain.com/foo/dir/index.jsp

/

http://domain.com/foo

/path/help.jsp

http://domain.com/foo/path/help.jsp

path/help.jsp

http://domain.com/foo/dir/path/help.jsp

Production-Site URLs Use Domain-Based Strategy

Target site’s production site URL: /foo.com

Current URL: http://domain.com/dir/index.jsp

Input Path

New URL

""

http://foo.com/dir/index.jsp

/

http://foo.com

/path/help.jsp

http://foo.com/path/help.jsp

path/help.jsp

http://foo.com/dir/path/help.jsp

Sticky Site Parameters

A sticky site is specified through special URL query parameters pushSite and stickySite (see RequestParameterRuleFilter earlier in this chapter). Links that are generated on a preview server automatically include these query parameters through the SiteURLManager property autoAppendStickySiteParams. The generated link retains the root of the current site; the URL path is modified according to the URL Construction Rules described in the previous section.

Note: A preview server should always set its SiteURLManager property autoAppendStickySiteParams to true; changing this property to false can yield unpredictable results.

The following examples show how the SiteURLManager generates links, given a site ID of fbar and this current URL:

http://domain.com/root/path/index.jsp

Input Path

New URL

""

http://domain.com/root/path/index.jsp?
   pushSite=fbar&stickySite=setSite

/

http://domain.com/root/?
   pushSite=fbar&stickySite=setSite

/path/help.jsp

http://domain.com/root/path/help.jsp?
   pushSite=fbar&stickySite=setSite

path/help.jsp

http://domain.com/root/path/path/help.jsp?
   pushSite=fbar&stickySite=setSite

getProductionSiteBaseURL()

You can also obtain site URLs by calling SiteURLManager.getProductionSiteBaseURL(), which, given a DynamoHttpServletRequest and a site ID, returns an absolute URL based on the URL Construction Rules described earlier.

This method has the following signature:

public String getProductionSiteBaseURL(DynamoHttpServletRequest pRequest,
                                       String pSiteId,
                                       String pPath,
                                       String pQueryParams,
                                       String pProtocol,
                                       boolean pInInclude)

getProductionSiteBaseURL() takes the following optional parameters:

Parameter

Description

pPath

Path string to include in the returned URL.

pQueryParams

Query parameters to include in the returned URL.

pProtocol

The protocol to use—http or https—with domain names. If omitted, the protocol is set from the SiteURLManager property defaultProtocol.

pInInclude

A Boolean flag, specifies whether relative paths should use the URI of the included page.

Note: If a site ID contains unconventional characters—for example, hash (#) and plus (+)—you can enter them directly for the pSiteID parameter and the equivalent input parameter in Oracle ATG Web Commerce servlets. However, settings for the pPath parameter and query parameters must use URL encoding for non-alphanumeric characters—for example, %40 and %7E for at (@) and tilde (~) characters, respectively.

SiteBaseURLProcessors

When required to generate a URL, the SiteURLManager executes an array of SiteBaseURLProcessor components, specified through its siteBaseURLProcessors property. The Oracle ATG Web Commerce installation provides two processors:


Copyright © 1997, 2013 Oracle and/or its affiliates. All rights reserved. Legal Notices