Decision Center API

ilog.rules.teamserver.web.components.property.renderers
Class IlrPropertyEditorRenderer

java.lang.Object
  extended by javax.faces.render.Renderer
      extended by ilog.rules.webc.jsf.renderers.IlrBaseRenderer
          extended by ilog.rules.teamserver.web.components.property.renderers.IlrPropertyEditorRenderer
All Implemented Interfaces:
Serializable

public class IlrPropertyEditorRenderer
extends ilog.rules.webc.jsf.renderers.IlrBaseRenderer
implements Serializable

IlrPropertyEditorRenderer is the base class for rendering the HTML representation of a property in the Decision Center web client.

Overview

You can define custom property editors to be used in the Compose Wizard. You access this wizard from the Decision Center Compose tab.

To define a custom renderer:

  1. Implement a rendering class.
  2. Add a reference to the rendering class by positioning an annotation on the extension model.

You can customize the rule model extension files (.brmx and .brdx) directly in the XML files, or in the Rule Designer Rule Model Extension Editor. You can provide annotations that are specific to Decision Center in these extension files.

Code examples

The following code example shows a custom rendering class implementation:

 public class CustomRequirementPropertyRenderer extends
   IlrPropertyEditorRenderer {
 
   private static final long serialVersionUID = 1L;
   private static Logger log = Logger.getLogger(CustomRequirementPropertyRenderer.class.getName());
 
   public void encodeBegin(FacesContext facesContext, UIComponent component)
     throws IOException {
   }
 
   public void encodeChildren(FacesContext context, UIComponent component)
     throws IOException {
   }
 
   public void encodeValueField(FacesContext context, UIComponent component,
     boolean checkPermission) throws IOException,
     IlrApplicationException {
       log.log(Level.WARNING, "Start encodeValueField");
       IlrPropertyEditor editor = (IlrPropertyEditor) component;
       if (checkPermission && !editor.isPermissionGranted())
         super.encodeValueField(context, component, checkPermission);
       else {
         ResponseWriter writer = context.getResponseWriter();
         EStructuralFeature p = editor.getProperty();
         String key = component.getParent().getClientId(context) + "_" + //work around a jsf bug : sometimes 2 different components get the same generated id.
           component.getClientId(context) + "_" + p.getName();
         writer.write(\"<select name=\" + key + "\">\n");
         Object value = editor.getValue();
         List possibleValues = CustomDataProvider.getRequirements();
         for (int i = 0; i < possibleValues.size(); i++) {
           String s = (String) possibleValues.get(i);
           writer.write("<option");
           if (s.equals(value))
             writer.write(" selected");
           writer.write(" value=\"" + s + "\">\n");
           writer.write(" " + s);
           writer.write("</option>\n");
       }
     writer.write("</select>\n");
     }
   }
   
   static  class CustomDataProvider {
   
     static public List getRequirements() {
       ArrayList list = new ArrayList();
       list.add("Requirement 1");
       list.add("Requirement 2");
       list.add("Requirement 3");
       return list;
     }
   }
 }
 

The following example shows the configuration to be added to the configuration file in order to add the extended renderer to Decision Center.

 <render-kit>
  <renderer>
    <component-family>IlrPropertyEditor</component-family>
    <renderer-type>CustomRequirementPropertyRenderer</renderer-type>
    <renderer-class>serverextendedbrm.CustomRequirementPropertyRenderer</renderer-class>
  </renderer>
 </render-kit>
 

Note: these code examples are taken from the Rule model extensions for Decision Center sample.

See Also:
Serialized Form

Field Summary
protected  String ComplexExpression
           
static String EMPTY_VALUE_NOT_VALID
           
static String INVALID_CHARACTER
           
static String INVALID_VALUE
           
 
Constructor Summary
IlrPropertyEditorRenderer()
           
 
Method Summary
 Object convert(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, String value)
           
protected  IlxWTextField createTextField(IlrPropertyEditor editor, javax.faces.context.FacesContext context)
           
 void decode(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          This JSF method decodes a component.
 void encodeAsEditor(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Encodes the component in editing mode.
 void encodeAsQueryEditor(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Encodes the component in query mode.
 void encodeAsViewer(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component)
          Encodes the component in viewing mode.
 void encodeBegin(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component)
          Encodes the beginning of the component.
 void encodeChildren(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component)
          Encodes the children of a component.
 void encodeEnd(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Encodes the end of the component.
protected  void encodeValue(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component)
          Encodes the value of the property.
 void encodeValueField(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, boolean checkPermission)
          Encodes the value field.
protected  String getId(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, org.eclipse.emf.ecore.EStructuralFeature property)
          The value returned by getId is used in encodeValueField(FacesContext, UIComponent, boolean) to encode the input HTML tag that will hold the property value.
protected  String getValue(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, org.eclipse.emf.ecore.EStructuralFeature property)
          Override this method to return the new value for the element property.
protected  Object throwEmptyValueError(org.eclipse.emf.ecore.EStructuralFeature feature)
           
protected  Object throwInvalidCharacterError(org.eclipse.emf.ecore.EStructuralFeature feature, String value, ilog.rules.res.model.IlrFormatException e)
           
protected  Object throwInvalidValueError(org.eclipse.emf.ecore.EStructuralFeature feature, String value)
           
 
Methods inherited from class ilog.rules.webc.jsf.renderers.IlrBaseRenderer
convertClientId, displayButton, displayButton, encodeRecursive, getImagesDir, getImagesLocation, getMyForm
 
Methods inherited from class javax.faces.render.Renderer
getConvertedValue, getRendersChildren
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INVALID_VALUE

public static final String INVALID_VALUE
See Also:
Constant Field Values

EMPTY_VALUE_NOT_VALID

public static final String EMPTY_VALUE_NOT_VALID
See Also:
Constant Field Values

INVALID_CHARACTER

public static final String INVALID_CHARACTER
See Also:
Constant Field Values

ComplexExpression

protected String ComplexExpression
Constructor Detail

IlrPropertyEditorRenderer

public IlrPropertyEditorRenderer()
Method Detail

decode

public void decode(javax.faces.context.FacesContext context,
                   javax.faces.component.UIComponent component)
This JSF method decodes a component.

Do not to override this method, override getValue(javax.faces.context.FacesContext, javax.faces.component.UIComponent, org.eclipse.emf.ecore.EStructuralFeature) instead. This method is called in the default implementation of decode to set the value on an element.

Overrides:
decode in class javax.faces.render.Renderer
Parameters:
context - The component.
component - The context.

getValue

protected String getValue(javax.faces.context.FacesContext context,
                          javax.faces.component.UIComponent component,
                          org.eclipse.emf.ecore.EStructuralFeature property)
Override this method to return the new value for the element property.

This method is used in decode(javax.faces.context.FacesContext, javax.faces.component.UIComponent). This default implementation returns the value stored in the request parameter map for the key:

   component.getParent().getClientId(context) 
     + "_" + component.getClientId(context) 
     + "_" + property.getName()
  
See the JSF documentation for more information.

Parameters:
context - The context.
component - The component.
property - The property.
Returns:
The new value for the property of the element.

convert

public Object convert(javax.faces.context.FacesContext context,
                      javax.faces.component.UIComponent component,
                      String value)
               throws IllegalArgumentException
Throws:
IllegalArgumentException

throwEmptyValueError

protected Object throwEmptyValueError(org.eclipse.emf.ecore.EStructuralFeature feature)

throwInvalidValueError

protected Object throwInvalidValueError(org.eclipse.emf.ecore.EStructuralFeature feature,
                                        String value)

throwInvalidCharacterError

protected Object throwInvalidCharacterError(org.eclipse.emf.ecore.EStructuralFeature feature,
                                            String value,
                                            ilog.rules.res.model.IlrFormatException e)

getId

protected String getId(javax.faces.context.FacesContext context,
                       javax.faces.component.UIComponent component,
                       org.eclipse.emf.ecore.EStructuralFeature property)
The value returned by getId is used in encodeValueField(FacesContext, UIComponent, boolean) to encode the input HTML tag that will hold the property value. This value is then used in getValue(FacesContext, UIComponent, EStructuralFeature) to retrieve the value of this property.

Parameters:
context - The context.
component - The component.
property - The property.

encodeBegin

public void encodeBegin(javax.faces.context.FacesContext facesContext,
                        javax.faces.component.UIComponent component)
                 throws IOException
Encodes the beginning of the component. This default implementation does nothing.

Overrides:
encodeBegin in class javax.faces.render.Renderer
Throws:
IOException - if there is a problem writing to a stream.
Parameters:
facesContext - The context.
component - The component.

encodeChildren

public void encodeChildren(javax.faces.context.FacesContext facesContext,
                           javax.faces.component.UIComponent component)
                    throws IOException
Encodes the children of a component. This default implementation does nothing.

Overrides:
encodeChildren in class javax.faces.render.Renderer
Throws:
IOException - if there is a problem writing to a stream.
Parameters:
facesContext - The context.
component - The component.

encodeEnd

public void encodeEnd(javax.faces.context.FacesContext context,
                      javax.faces.component.UIComponent component)
               throws IOException
Encodes the end of the component. This default implementation encodes the whole component.

Overrides:
encodeEnd in class javax.faces.render.Renderer
Throws:
IOException - if there is a problem writing to a stream.
Parameters:
context - The context.
component - The component.

encodeAsViewer

public void encodeAsViewer(javax.faces.context.FacesContext facesContext,
                           javax.faces.component.UIComponent component)
                    throws IOException,
                           IlrApplicationException
Encodes the component in viewing mode. This method is used to display rule details.

Throws:
IOException - if there is a problem writing to a stream.
IlrApplicationException - if there is a business exception on the server.
Parameters:
facesContext - The context to use.
component - The component.

encodeValue

protected void encodeValue(javax.faces.context.FacesContext facesContext,
                           javax.faces.component.UIComponent component)
                    throws IOException,
                           IlrApplicationException
Encodes the value of the property. This method is called by encodeAsViewer(javax.faces.context.FacesContext, javax.faces.component.UIComponent) .

Throws:
IOException
IlrApplicationException
Parameters:
facesContext -
component -

encodeAsEditor

public void encodeAsEditor(javax.faces.context.FacesContext context,
                           javax.faces.component.UIComponent component)
                    throws IOException,
                           IlrApplicationException
Encodes the component in editing mode. This will typically be used when editing a rule.

Throws:
IOException
IlrApplicationException
Parameters:
context -
component -

encodeValueField

public void encodeValueField(javax.faces.context.FacesContext context,
                             javax.faces.component.UIComponent component,
                             boolean checkPermission)
                      throws IOException,
                             IlrApplicationException
Encodes the value field. This method is called by encodeAsEditor(javax.faces.context.FacesContext, javax.faces.component.UIComponent) .

Throws:
IOException
IlrApplicationException
Parameters:
context -
component -
checkPermission -

encodeAsQueryEditor

public void encodeAsQueryEditor(javax.faces.context.FacesContext context,
                                javax.faces.component.UIComponent component)
                         throws IOException,
                                IlrApplicationException
Encodes the component in query mode. This will typically be used when editing a query in the query form editor.

Throws:
IOException
IlrApplicationException
Parameters:
context -
component -

createTextField

protected IlxWTextField createTextField(IlrPropertyEditor editor,
                                        javax.faces.context.FacesContext context)

Decision Center API

© Copyright IBM Corp. 1987, 2013