I'm creating an interactive automation script to change a password and I'm trying to get the validation to work. When the ValidationState is set to Invalid, the text boxes do not appear invalid (I'd expect a red border, and perhaps a tooltip with the ValidationText). I am also wondering why the ValidationText property is never displayed.
Below is the core of my script code, am I implementing this correctly?
UI of my script:
// Create the dialog box
UIBuilder uib = new UIBuilder();
// Configure the dialog box
uib.RequireResponse = true;
uib.RowDefs = "a;a;a;a;a;a";
uib.ColumnDefs = "a;a";
UIBlockDefinition pwdText = new UIBlockDefinition();
pwdText.Type = UIBlockType.StaticText;
pwdText.Text = "Enter the new Cassandra password:";
pwdText.Height = 20;
pwdText.Row = 0;
pwdText.Column = 0;
uib.AppendBlock(pwdText);
UIBlockDefinition pwd = new UIBlockDefinition();
pwd.Type = UIBlockType.PasswordBox;
pwd.Height = 25;
pwd.Width = 150;
pwd.Row = 1;
pwd.Column = 0;
pwd.WantsOnChange = true;
pwd.DestVar = nameof(pwd);
pwd.IsRequired = true;
pwd.ValidationState = UIValidationState.Invalid;
pwd.ValidationText = "Passwords do not match 1";
uib.AppendBlock(pwd);
UIBlockDefinition repeatPwdText = new UIBlockDefinition();
repeatPwdText.Type = UIBlockType.StaticText;
repeatPwdText.Text = "Repeat the new Cassandra password:";
repeatPwdText.Height = 20;
repeatPwdText.Row = 2;
repeatPwdText.Column = 0;
uib.AppendBlock(repeatPwdText);
UIBlockDefinition pwdRepeat = new UIBlockDefinition();
pwdRepeat.Type = UIBlockType.PasswordBox;
pwdRepeat.Height = 25;
pwdRepeat.Width = 150;
pwdRepeat.Row = 3;
pwdRepeat.Column = 0;
pwdRepeat.ValidationText = "Passwords do not match";
pwdRepeat.ValidationState = UIValidationState.Invalid;
pwdRepeat.WantsOnChange = true;
pwdRepeat.DestVar = nameof(pwdRepeat);
pwdRepeat.IsRequired = true;
uib.AppendBlock(pwdRepeat);
UIBlockDefinition changePwdButton = new UIBlockDefinition();
changePwdButton.Type = UIBlockType.Button;
changePwdButton.Text = "Change Password";
changePwdButton.Height = 20;
changePwdButton.Width = 150;
changePwdButton.Row = 4;
changePwdButton.Column = 0;
uib.AppendBlock(changePwdButton);
UIBlockDefinition validationState = new UIBlockDefinition();
validationState.Type = UIBlockType.StaticText;
validationState.Text = "Validation State is: ";
validationState.Height = 20;
validationState.Row = 5;
validationState.Column = 0;
uib.AppendBlock(validationState);UIResults uir = null;
bool isValid = false;
do
{
// Display the dialog box
uir = engine.ShowUI(uib);
if (uir == null)
{
isValid = false;
continue;
}
string pwdValue = uir.GetString(nameof(pwd));
string pwdRepeatValue = uir.GetString(nameof(pwdRepeat));// Reset the values the user entered
pwdRepeat.InitialValue = pwdRepeatValue;
pwd.InitialValue = pwdValue;// Actual validation code
isValid = !string.IsNullOrWhiteSpace(pwdValue) && pwdValue.Length > 6 && pwdValue == pwdRepeatValue;
pwd.ValidationState = isValid ? UIValidationState.Valid : UIValidationState.Invalid;
pwdRepeat.ValidationState = isValid ? UIValidationState.Valid : UIValidationState.Invalid;
validationState.Text = "Validation State is: " + pwdRepeat.ValidationState;
} while (!isValid);
Some further digging revealed that the Validation feature (RN 25183) was only implemented in the DataMiner dashboards (RN 25253), not in Cube. A new software feature task (task id 182417) was created to implement this in Cube as well. For now, my script will work around this limitation by setting the validation text in a "StaticText" UI block instead.