CentraSite Documentation : Runtime Governance with CentraSite : Run-Time Governance Reference : Computed Runtime Actions : Writing Your Own Computed Runtime Action : Implementation Guidelines for Computed Runtime Action : Implementation for Computed Action UI
Implementation for Computed Action UI
src\com\softwareag\centrasite\bui\extension\client\runtime\action\MyComputedRuntimeActionWidget.java
public class MyComputedRuntimeActionWidget extends Composite {
private PolicyActionJSO policyActionJso = null;
private TextBox valueBox = null;
private static final String WARNING_CSS = "loginTextBoxErrorBorder";
 
public MyComputedRuntimeActionWidget(String policyActionJson) {
FlowPanel container = new FlowPanel();
initWidget(container);
 
policyActionJso = getPolicyActionJso(policyActionJson);
if (policyActionJso == null) {
Label helloLabel = new Label("The JSON content is empty");
container.add(helloLabel);
return;
}
 
//Render widgets
container.add(getParametersView(policyActionJso));
}
 
private Widget getParametersView(PolicyActionJSO policyActionJso) {
FlowPanel parametersContainer = new FlowPanel();
 
JsArray<ParameterJSO> parameters = policyActionJso.getParameters();
if (parameters == null) {
return parametersContainer;
}
 
for (int i = 0; i < parameters.length(); i++) {
parametersContainer.add(getParameterView(parameters.get(i)));
}
 
return parametersContainer;
}
private Widget getParameterView(ParameterJSO parameterJso) {
FlowPanel parameterContainer = new FlowPanel();
Label nameLabel = new Label(parameterJso.getName());
parameterContainer.add(nameLabel);
 
valueBox = new TextBox();
valueBox.setLayoutData(parameterJso.getId());
 
String[] values = parameterJso.getValues();
if (values != null && values.length > 0) {
valueBox.setValue(values[0]);
}
 
parameterContainer.add(valueBox);
return parameterContainer;
}
public static native PolicyActionJSO getPolicyActionJso(String json) /*-{
return eval('(' + json + ')');
}-*/;
public String getJson() {
JsArray<ParameterJSO> parameters = policyActionJso.getParameters();
ParameterJSO parameterJso = null;
if (parameters != null && parameters.length() > 0) {
parameterJso = parameters.get(0);
 
String[] values = {valueBox.getValue()};
parameterJso.setValues(values);
}
 
return policyActionJso.toJSON();
}
public boolean isValid() {
String value = valueBox.getValue();
boolean isValid = (value != null && !"".equals(value));
if (!isValid) {
valueBox.addStyleName(WARNING_CSS);
} else {
valueBox.removeStyleName(WARNING_CSS);
}
 
return isValid;
}
}
The MyComputedRuntimeActionWidget class extends the class Composite, which declares the basic rendering methods for the CentraSite Business user interface.
Implementations and Description
MyComputedRuntimeActionWidget(String policyActionJson)
Constructor dictates the user-defined rendering of the action's UI.
getPolicyActionJson
Returns the JSON object from the specified object.
String getJson()
Returns a JSON encoded string representing the action's parameters.
boolean isValid()
Enforces validation logic for the action's parameter values.
Copyright © Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback