Given a valid site ID, the servlet bean GetSiteDroplet returns a site
object—an implementation of interface atg.multisite.Site
—which encapsulates a site configuration. The output
parameter enables access to that site’s properties. If you supply null for the site ID, GetSiteDroplet returns the current site.
The following JSP code uses GetSiteDroplet to obtain the site mySite
’s configuration. The output parameter site
provides access to all site configuration properties. In this example, the code obtains the site’s closingDate
property and compares it to the current date to determine whether the site is active:
<%-- Get a site's configuration and look at its closingDate property --%> <%@ taglib uri="http://www.atg.com/taglibs/daf/dspjspTaglib1_0" prefix="dsp" %> <%@ page import="java.util.Date;"%> <dsp:page> <dsp:droplet name="/atg/dynamo/droplet/multisite/GetSiteDroplet"> <dsp:param name="siteId" value="mySite"/> <dsp:oparam name="output"> <dsp:getvalueof var="closeDate" param="site.closingDate" vartype="java.util.Date"> <c:choose> <c:when test="${System.currentTimeMillis() < closeDate.getTimeInMillis()}"> Site is still active </c:when> <c:otherwise> Site is no longer active </c:otherwise> </c:choose> </dsp:oparam> </dsp:droplet> </dsp:page>
Getting the Current Site
You can obtain the current site and its configuration through the request-scoped Nucleus component /atg/multisite/Site
. For example, you can modify the previous example and obtain the current site’s closingDate
property as follows:
<%-- Get the current site configuration and look at its closingDate property --%> <%@ taglib uri="http://www.atg.com/taglibs/daf/dspjspTaglib1_0" prefix="dsp" %> <%@ page import="java.util.Date;"%> <dsp:page> <droplet bean="/atg/dynamo/droplet/ComponentExists"> <oparam name="true"> <dsp:tomap bean="/atg/multisite/Site.id" var="siteID"/> <dsp:getvalueof var="closeDate" param="siteID.closingDate" vartype="java.util.Date"> <c:choose> <c:when test="${System.currentTimeMillis() < closeDate.getTimeInMillis()}"> Site is still active </c:when> <c:otherwise> Site is no longer active </c:otherwise> </c:choose> </oparam> <oparam name="false">SiteContextManager not found</oparam> </droplet> </dsp:page>