public interface PreviewContext extends Context
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ACTIVITY_DATA_PARAM_SERIALIZED_PREVIEW_CONTEXT
The activity data containing the serialized version of the preview context.
|
static java.lang.String |
CONTEXT_NAME
The name that uniquely identifies this context in the CTXDATA table.
|
static java.lang.String |
COPYRIGHT
IBM copyright notice field.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getProperty(java.lang.String key)
Returns the property value based on the specified property name.
|
java.util.Iterator |
getPropertyNames()
Returns an Iterator of property names currently contained in the preview context.
|
java.sql.Timestamp |
getTimestamp()
Returns the appropriate timestamp to the caller to use when performing an operation.
|
void |
setProperty(java.lang.String key,
java.lang.String value)
Sets a property to associate with preview.
|
void |
setTimestamp(java.sql.Timestamp time)
Sets the time to be used by the session.
|
void |
setTimestamp(java.sql.Timestamp time,
boolean isStatic)
Sets the time to be used by the session.
|
copyContext, getActivityToken, getContextName, validate
static final java.lang.String COPYRIGHT
static final java.lang.String CONTEXT_NAME
static final java.lang.String ACTIVITY_DATA_PARAM_SERIALIZED_PREVIEW_CONTEXT
java.sql.Timestamp getTimestamp()
void setTimestamp(java.sql.Timestamp time)
time
- The new time of the session.void setTimestamp(java.sql.Timestamp time, boolean isStatic)
An example of using this method follows:
// get the Command Context CommandContext cContext = getCommandContext(); //get the preview context from command context (Can also use ContextHelper) PreviewContext previewCtxt = (com.ibm.commerce.context.preview.PreviewContext); cContext.getContext(PreviewContext.CONTEXT_NAME); // Set the values from the graphical user interface page in the Preview Context if (previewStartTime != null) { previewCtxt.setTimestamp(previewStartTime, isStatic); }
time
- The new time of the session.isStatic
- Whether the time should be static. If the time is static, then this time will always be
returned.void setProperty(java.lang.String key, java.lang.String value)
An example of using this method follows:
//Set campaign specific property - inventory evaluation mechanism previewCtxt.setProperty(PreviewConstants.PREVIEW_INVENTORY, inventoryValue.toString());
key
- The property name.value
- The property value.java.lang.String getProperty(java.lang.String key)
*[comments] Gets type of inventory evaluation method. If the evaluation is based on real inventory this method *will return INVENTORY_EVAL_REAL.If the evaluation is faked and inventory constraint evaluated to true *then this method will return INVENTORY_EVAL_TRUE. If the evaluation is faked and inventory constraint *evaluated to false then this method will return INVENTORY_EVAL_FALSE. *@return Inventory evaluation type *[/comments]
protected Integer getInventoryEvalType() { PreviewContext previewCtxt; try { previewCtxt = (PreviewContext) getCommandContext().getContext(KEY_PREVIEWCONTEXT); } catch (Exception e) { previewCtxt = null; } if (previewCtxt != null) { String prvInvValue = (String) previewCtxt.getProperty(PreviewConstants.PREVIEW_INVENTORY); if(prvInvValue==null){ return PreviewConstants.INVENTORY_EVAL_REAL; }else{ return new Integer(prvInvValue); } } else { return PreviewConstants.INVENTORY_EVAL_REAL; } }
key
- The property name.java.util.Iterator getPropertyNames()