|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ibm.websphere.personalization.RuleTrigger com.ibm.websphere.personalization.ContentSpot
public class ContentSpot
The ContentSpot is the main access point to the Personalization runtime. ContentSpots are instantiated to represent a place where a rule is executed. Invoking a ContentSpot will execute rule(s) mapped to that ContentSpot. You may also execute a rule by its name directly.
Multiple calls to the same instance of this class will return the
same results.
Setting the request into the Content Spot
Callers to this class should first set the request into
the ContentSpot. Setting the request through one of the
setRequest(...)
methods is the way in which
Personalization receives the input to the rule.
The request object passed to this class may be an instance of
javax.portlet.PortletRequest
org.apache.jetspeed.portlet.PortletRequest
javax.servlet.http.HttpServletRequest
com.ibm.websphere.personalization.PznRequestObjectInterface
When executing rules in a JSP or JSP tag inside a Portlet container,
callers should pass the portletRequest
variable from the JSP
rather than passing the request
variable whenever possible.
With rare exception upon which callers should not depend,
the request must be set into the ContentSpot
(either through a constructor or by explicitly calling Specifying what rule or content spot to executesetRequest
)
prior to any other methods being called on this class.
The contentSpotName, contentSpotUuid, ruleName, and ruleUuid for
which there exist setter methods are used to identify what rule
or content spot should be executed when this Content Spot object is triggered.
These names and uuids correspond to the paths and unique identifers of
items created in the Personalization Navigator portlet.
Executing generated content spots
Content Spots classes may also be generated using wizards in Rational tooling. Generated Content Spots extend RuleTrigger directly, and do not make use of this class. The generated classes have the advantage that they have strongly types methods for returning content, and you do not have to set an identifier for the content spot or rule to be executed.
Using this class has the advantage that your code can be more agile, taking a content spot or rule path as a parameter to some mehod you create. Using this class also allows you to define new Content Spots without generating a single class for each Content Spot.
When executing a generated Content Spot, the Content Spot object should still
exist in the Personalization Navigator. In the case of generated spots, the
value of contentSpotName is simply implied by the display name given to the
Conent Spot in the Rational wizard. If the display name is "/PznDemo/GeneralNewsSpot",
then the Content Spot will execute as if you had called ExamplessetContentSpotName("/PznDemo/GeneralNewsSpt")
on this object. If the display name is simply "GeneralNewsSpot", then the
Content Spot will execute as if you had called setContentSpotName("GeneralNewsSpot")
on this class. In this case, the Content Spot object in the
Personalization Navigator to be executed will be one located directly in the root.
To execute a Content Spot called "GeneralNewsSpot" in a folder called "PznDemo" in a JSP in Portal, the following series of calls would be issued.
ContentSpot contentSpot = new ContentSpot(); contentSpot.setRequest(portletRequest); contentSpot.setContentSpotName("/PznDemo/GeneralNewsSpot"); Object[] content = contentSpot.getRuleContent();
If this was done outside of Portal, portletRequest
would instead be simply
request
or some object implementing PznRequestObjectInterface.
To execute a Rule called "Get General News About Sports" in a folder called "FrontPage" which is in a folder called "Pzndemo", the following series of calls would be issued.
ContentSpot contentSpot = new ContentSpot(); contentSpot.setRequest(portletRequest); contentSpot.setRuleName("/PznDemo/FrontPage/Get General News About Sports"); Object[] content = contentSpot.getRuleContent();
After either of these series of invocations, you may need to iterate over the results and cast to your own resource class.
for (int i=0; i<content.length; i++) { GeneralNews nextContent = (GeneralNews) content[i]; /// do something with the nextContent object ... }
PznRequestObjectInterface
,
Serialized FormField Summary |
---|
Fields inherited from class com.ibm.websphere.personalization.RuleTrigger |
---|
additionalQuery, asOfDate, audit, campaignName, CAMPAIGNS_FINDER, categorizationOrder, content, contentSpotUuid, defaultRuleExit, displayName, includeRuntimeResultsInPreview, limit, name, req, requestContext, resourceCollectionName, ruleExit, ruleJSON, ruleMapping, ruleMappingsList, ruleName, ruleUuid, scopeId, showErrors, startIndex, useCascadingCampaigns |
Constructor Summary | |
---|---|
ContentSpot()
Constructs an object to execute a rule. |
|
ContentSpot(java.lang.String contentSpotName)
Constructs an object to execute a rule. |
|
ContentSpot(java.lang.String contentSpotName,
java.lang.Object request)
Contructs an object to execute a rule. |
Method Summary | |
---|---|
Query |
getAdditionalQueryParameters()
Returns the query to be joined with the query of the rule run by this content spot. |
java.lang.String |
getContentSpotName()
Returns the path to the Content Spot. |
java.lang.Object[] |
getRuleContent()
Executes the rule and returns the results. |
java.lang.Object |
getRuleContent(int i)
Executes the rule and returns the ith result |
void |
setAdditionalQueryParameters(Query query)
Joins an additional query with the query of the rule run by this content spot. |
void |
setContentSpotName(java.lang.String contentSpotName)
Sets which Content Spot to execute. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ContentSpot()
setRequest
and one of the methods to set the Content Spot
name or uuid or rule name or uuid before triggering or trying to get results.
public ContentSpot(java.lang.String contentSpotName)
setRequest
before triggering or trying to get results.
contentSpotName
- The name of the content spot to be executed.
The contentSpotName is the path to the Content Spot in the Personalization Navigatorrequest
- The input to the rules.
This object must be an HttpServletRequest, PortletRequest,
or implementation of com.ibm.websphere.personalization.PznRequestObjectInterfacepublic ContentSpot(java.lang.String contentSpotName, java.lang.Object request)
contentSpotName
- The name of the Content Spot to be executed.
The contentSpotName is the path to the Content Spot in the Personalization Navigatorrequest
- The input to the rules.
This object must be an HttpServletRequest, PortletRequest,
or implementation of com.ibm.websphere.personalization.PznRequestObjectInterfaceMethod Detail |
---|
public java.lang.String getContentSpotName()
getContentSpotName
in class RuleTrigger
public void setContentSpotName(java.lang.String contentSpotName)
setContentSpotName
in class RuleTrigger
contentSpotName
- The name of the Content spot executed or to be executed.
The contentSpotName is the path to the Content Spot in the Personalization Navigatorpublic Query getAdditionalQueryParameters()
public void setAdditionalQueryParameters(Query query)
query
- The query to be joined with the query of the rule run by this content spotpublic java.lang.Object[] getRuleContent() throws java.lang.Throwable
java.lang.Throwable
public java.lang.Object getRuleContent(int i) throws java.lang.ArrayIndexOutOfBoundsException, java.lang.Throwable
i
- The index (index 0 based) of the result to return
java.lang.ArrayIndexOutOfBoundsException
- Throws an exception if there are no
results or less than i results.
java.lang.Throwable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |