public class IlrPropertyEditorRenderer
extends ilog.rules.webc.jsf.renderers.IlrBaseRenderer
implements java.io.Serializable
IlrPropertyEditorRenderer is the base class for rendering the
HTML representation of a property in the Decision Center web client.
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:
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.
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.
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
ComplexExpression |
static java.lang.String |
EMPTY_VALUE_NOT_VALID |
static java.lang.String |
INVALID_CHARACTER |
static java.lang.String |
INVALID_VALUE |
| Constructor and Description |
|---|
IlrPropertyEditorRenderer() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
convert(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
java.lang.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 |
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 java.lang.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 java.lang.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 java.lang.Object |
throwEmptyValueError(org.eclipse.emf.ecore.EStructuralFeature feature) |
protected java.lang.Object |
throwInvalidCharacterError(org.eclipse.emf.ecore.EStructuralFeature feature,
java.lang.String value,
ilog.rules.res.model.IlrFormatException e) |
protected java.lang.Object |
throwInvalidValueError(org.eclipse.emf.ecore.EStructuralFeature feature,
java.lang.String value) |
public static final java.lang.String INVALID_VALUE
public static final java.lang.String EMPTY_VALUE_NOT_VALID
public static final java.lang.String INVALID_CHARACTER
protected java.lang.String ComplexExpression
public void decode(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent 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.
decode in class javax.faces.render.Renderercontext - The component.component - The context.protected java.lang.String getValue(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
org.eclipse.emf.ecore.EStructuralFeature 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.context - The context.component - The component.property - The property.public java.lang.Object convert(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
java.lang.String value)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentExceptionprotected java.lang.Object throwEmptyValueError(org.eclipse.emf.ecore.EStructuralFeature feature)
protected java.lang.Object throwInvalidValueError(org.eclipse.emf.ecore.EStructuralFeature feature,
java.lang.String value)
protected java.lang.Object throwInvalidCharacterError(org.eclipse.emf.ecore.EStructuralFeature feature,
java.lang.String value,
ilog.rules.res.model.IlrFormatException e)
protected java.lang.String getId(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
org.eclipse.emf.ecore.EStructuralFeature property)
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.context - The context.component - The component.property - The property.public void encodeBegin(javax.faces.context.FacesContext facesContext,
javax.faces.component.UIComponent component)
throws java.io.IOException
encodeBegin in class javax.faces.render.Rendererjava.io.IOException - if there is a problem writing to a stream.facesContext - The context.component - The component.public void encodeChildren(javax.faces.context.FacesContext facesContext,
javax.faces.component.UIComponent component)
throws java.io.IOException
encodeChildren in class javax.faces.render.Rendererjava.io.IOException - if there is a problem writing to a stream.facesContext - The context.component - The component.public void encodeEnd(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component)
throws java.io.IOException
encodeEnd in class javax.faces.render.Rendererjava.io.IOException - if there is a problem writing to a stream.context - The context.component - The component.public void encodeAsViewer(javax.faces.context.FacesContext facesContext,
javax.faces.component.UIComponent component)
throws java.io.IOException,
IlrApplicationException
java.io.IOException - if there is a problem writing to a stream.IlrApplicationException - if there is a business exception on
the server.facesContext - The context to use.component - The component.protected void encodeValue(javax.faces.context.FacesContext facesContext,
javax.faces.component.UIComponent component)
throws java.io.IOException,
IlrApplicationException
encodeAsViewer(javax.faces.context.FacesContext, javax.faces.component.UIComponent) .java.io.IOExceptionIlrApplicationExceptionfacesContext - component - public void encodeAsEditor(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component)
throws java.io.IOException,
IlrApplicationException
java.io.IOExceptionIlrApplicationExceptioncontext - component - public void encodeValueField(javax.faces.context.FacesContext context,
javax.faces.component.UIComponent component,
boolean checkPermission)
throws java.io.IOException,
IlrApplicationException
encodeAsEditor(javax.faces.context.FacesContext, javax.faces.component.UIComponent) .java.io.IOExceptionIlrApplicationExceptioncontext - component - checkPermission - protected IlxWTextField createTextField(IlrPropertyEditor editor, javax.faces.context.FacesContext context)
© Copyright IBM Corp. 1987, 2017