The Java Server Pages (JSPs) for a multisite application must be coded in a site-aware way. A key aspect of making pages site-aware involves changing the current site context so, for example, a certain area of a page on site A can display products from site B.
To change the site context on a portion of a page, you use the atg.droplet.multisite.SiteContextDroplet
. This servlet bean takes a site ID as an input parameter, changes the site context to the site with that site ID, and renders output using the new site context. It then restores the site context to what it was before the droplet was invoked, so the remainder of the page is rendered using the original site context.
In addition to SiteContextDroplet
, the atg.droplet.multisite
package includes a number of other servlet beans for building site-aware JSPs. These include:
GetSiteDroplet
– Given a site ID, returns the correspondingSite
object. Properties of the site can then be displayed or used in by other page code.SiteLinkDroplet
– Given a site ID and a path, generates a link to another site.SitesShareShareableDroplet
– Tests to see if a given shareable type is shared between the current site and one or more additional sites.SiteIdForItemDroplet
– Given a repository item, returns a site that the item is associated with (i.e., one of the sites in the item’ssiteIds
property). The actual site returned depends on the values of input parameters that are used to give relative weighting to the sites in thesiteIds
property.
Site Scope
In addition to the multisite-specific servlet beans mentioned above, several other servlet beans and form handlers have properties for determining the sites they apply to. The sites are specified using one of these properties:
siteIds
– an array of site IDssiteScope
– one of the following values:all
– applies to all sitescurrent
– applies to the current request’s sitea shareable type ID – applies to sites that share this shareable type with the current site; for example.,
atg.ShoppingCart
Only one of these properties should be set. If both are set, siteScope
is ignored. If neither property is set, the component is applied to all sites.
Servlet beans that have these properties also have siteIds
and siteScope
input parameters that can be used to override the property values on an individual page. Form handlers with these properties can override the configured values using hidden input fields.