HATS 7.5.1 Web API Reference

Publicly accessible methods not documented here are for IBM internal use only and may change in a future release of the product.

com.ibm.hats.transform
Class RenderingRulesEngine

java.lang.Object
  extended by com.ibm.hats.transform.AbstractRenderingRulesEngine
      extended by com.ibm.hats.transform.RenderingRulesEngine
All Implemented Interfaces:
IRenderingRulesEngine

public class RenderingRulesEngine
extends com.ibm.hats.transform.AbstractRenderingRulesEngine

RenderingRulesEngine is the core functional class for Global Rules within HATS. This engine is constructed in an Apply Transformation action. The engine then processes the HostScreen using its set of RenderingRules, generating a list of MatchingElements. The engine is then passed around as a context attributes to the various Widgets. Widgets can grab the engine from the context attributes and check it against ComponentElements before they are rendered, and if they find a match, they can have the engine render the output and return it as a String.

Example of Widget Usage:

 for (int i = 0; i < componentElements.length; i++) {
     InputComponentElement ice = (InputComponentElement) componentElements[i];
     //create and render the html input field's caption
     HTMLWidgetUtilities.renderCaption(ice.getCaption(), factory, buffer);
     //determine if a rendering rule applies to this input field, and if so render the rule output
           String ruleOutput = RenderingRulesEngine.processMatchingElement(ice,contextAttributes);
     if(ruleOutput!=null) buffer.append(ruleOutput);
     else { //create the html input field from the input component element, then render it
                   TextInputElement input = factory.createTextInput(ice);
                   input.render(buffer);
     }
           //insert a line break
     buffer.append("<br>");
 }
 

See Also:
Widget, RenderingRule, RenderingRuleSet

Field Summary
static String CLASS_NAME
           
 
Fields inherited from class com.ibm.hats.transform.AbstractRenderingRulesEngine
elementsFound
 
Constructor Summary
RenderingRulesEngine(IRenderingRuleSet ruleSet, HsrScreen hostScreen, BlockScreenRegion region, ContextAttributes contextAttributes)
          Class constructor for RenderingRulesEngine.
RenderingRulesEngine(IRenderingRuleSet ruleSet, HsrScreen hostScreen, BlockScreenRegion region, ContextAttributes contextAttributes, int screenId)
           
 
Method Summary
 RenderingItem[] getRenderingItemsFromRenderingRule(IRenderingRule rule, Object ref)
           
static IRenderingRulesEngine getRenderingRulesEngine(javax.servlet.http.HttpServletRequest req)
          Pulls an instance of the RenderingRulesEngine from the request.
static IRenderingRulesEngine getRenderingRulesEngine(IRequest req)
          Pulls an instance of the RenderingRulesEngine from the request.
static String processMatchingElement(ComponentElement ce, ContextAttributes contextAttributes)
          Attempts to see if a given ComponentElement was matched by any rendering rules, and if so, return the fragment content as a string.
 String processPatternMatchElement(IRenderingRule rr, PatternMatchComponentElement pmce, ContextAttributes contextAttributes)
          Renders output for a RenderingRule match by doing a JSP include of the referenced transformation fragment.
 String processPatternMatchElement(com.ibm.hats.transform.MatchingElement me, ContextAttributes contextAttributes)
          Attempts to see if a given ComponentElement was matched by any rendering rules, and if so, return the fragment content as a string.
static void setRenderingRulesEngine(javax.servlet.http.HttpServletRequest req, IRenderingRulesEngine rre)
          Deprecated. - use setRenderingRulesEngine(IRequest req, IRenderingRulesEngine rre)
static void setRenderingRulesEngine(IRequest req, IRenderingRulesEngine renderingRuleEngine)
          Puts an instance of the RenderingRulesEngine in the request.
 
Methods inherited from class com.ibm.hats.transform.AbstractRenderingRulesEngine
getApplyRenderingRules, getMatchingComponentElement, getMatchingElement, getMatchingRenderingRule, getNumElementsFound, newInstance, newInstance, preProcessHostTransformation, processScreen, processScreen, setApplyRenderingRules
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_NAME

public static final String CLASS_NAME
See Also:
Constant Field Values
Constructor Detail

RenderingRulesEngine

public RenderingRulesEngine(IRenderingRuleSet ruleSet,
                            HsrScreen hostScreen,
                            BlockScreenRegion region,
                            ContextAttributes contextAttributes)
Class constructor for RenderingRulesEngine. Applies RenderingRules in the specified RenderingRuleSet to the specified HostScreen, populating a list of MatchingElements.

Parameters:
ruleSet - RenderingRules to apply
hostScreen - HostScreen to search for patterns on
region - not currently used
contextAttributes - not currently used

RenderingRulesEngine

public RenderingRulesEngine(IRenderingRuleSet ruleSet,
                            HsrScreen hostScreen,
                            BlockScreenRegion region,
                            ContextAttributes contextAttributes,
                            int screenId)
Method Detail

processPatternMatchElement

public String processPatternMatchElement(IRenderingRule rr,
                                         PatternMatchComponentElement pmce,
                                         ContextAttributes contextAttributes)
Renders output for a RenderingRule match by doing a JSP include of the referenced transformation fragment. Passes information about the matched field through the request to the Transformation Fragment.

Specified by:
processPatternMatchElement in class com.ibm.hats.transform.AbstractRenderingRulesEngine
Parameters:
rr - matched rule
pmce - element which matched
contextAttributes - contains the request and page context needed for JSP inclusion
Returns:
content from the Transformation Fragment

processPatternMatchElement

public String processPatternMatchElement(com.ibm.hats.transform.MatchingElement me,
                                         ContextAttributes contextAttributes)
Description copied from interface: IRenderingRulesEngine
Attempts to see if a given ComponentElement was matched by any rendering rules, and if so, return the fragment content as a string. This method must be overridden by its consumer in order for Widgets to exploit global rules.

Specified by:
processPatternMatchElement in interface IRenderingRulesEngine
Overrides:
processPatternMatchElement in class com.ibm.hats.transform.AbstractRenderingRulesEngine
Parameters:
me - matching element to match against
contextAttributes - context attribute information (see class ContextAttributes for more detail)
Returns:
content from the Transformation Fragment

getRenderingItemsFromRenderingRule

public RenderingItem[] getRenderingItemsFromRenderingRule(IRenderingRule rule,
                                                          Object ref)
Specified by:
getRenderingItemsFromRenderingRule in class com.ibm.hats.transform.AbstractRenderingRulesEngine

processMatchingElement

public static String processMatchingElement(ComponentElement ce,
                                            ContextAttributes contextAttributes)
Attempts to see if a given ComponentElement was matched by any rendering rules, and if so, return the fragment content as a string. This method should be used by Widgets which want to exploit global rules.

Parameters:
ce - The ComponentElement to match on.
contextAttributes - Useful information about the environment.
Returns:
Returns the content of the fragment, or null if not supposed to apply rendering rules or if there was no match.
See Also:
RenderingRulesEngine, RenderingRulesEngine.processPatternMatchElement(IRenderingRule, PatternMatchComponentElement, ContextAttributes)

getRenderingRulesEngine

public static IRenderingRulesEngine getRenderingRulesEngine(javax.servlet.http.HttpServletRequest req)
Pulls an instance of the RenderingRulesEngine from the request.

Parameters:
req - The HttpServletRequest object.
Returns:
Returns an instance of the RenderingRulesEngine from the request.

getRenderingRulesEngine

public static IRenderingRulesEngine getRenderingRulesEngine(IRequest req)
Pulls an instance of the RenderingRulesEngine from the request.

Parameters:
req -
Returns:
The RenderingRulesEngine found in the request.

setRenderingRulesEngine

public static void setRenderingRulesEngine(javax.servlet.http.HttpServletRequest req,
                                           IRenderingRulesEngine rre)
Deprecated. - use setRenderingRulesEngine(IRequest req, IRenderingRulesEngine rre)

Puts an instance of the RenderingRulesEngine in the request.

Parameters:
req -
rre -

setRenderingRulesEngine

public static void setRenderingRulesEngine(IRequest req,
                                           IRenderingRulesEngine renderingRuleEngine)
Puts an instance of the RenderingRulesEngine in the request.

Parameters:
req -
renderingRuleEngine -

HATS 7.5.1 (201005110649)