Reactive StringField on Gateway Settings

Hello Gurus,

Can someone guide me on overriding the EDIT mechanism in the Gateway Settings for my Module? What I want to achieve is the reactive Disabled StringField which is enabled by the click of a BooleanField only on EDIT. attached is the SS of what I am looking to achieve.

image

Regards

In a static block in your persistent record implementation, set your password field's stored editor to use the PasswordEditorSource, e.g:

static {
    PasswordE.getFormMeta().setEditorSource(PasswordEditorSource.getSharedInstance());
}
2 Likes

@PGriffith

How do I allocate Resources for this now? Instead of "Password" in those generated places, I want them to replace them with different name.

tried the below code all in vain.

MY_FIELD.getFormMeta().setEditorSource(PasswordEditorSource.getSharedInstance()).setFieldNameKey("MY_NAME");

image

You'll have to implement your own editor source, which itself implements a custom editor that distinguishes between the "new" and "edit" case for the record edit form:

    private static class ClientSecretEditorSource implements IEditorSource {

        private static final ClientSecretEditorSource INSTANCE = new ClientSecretEditorSource();

        @Override
        public Component newEditorComponent(String id,
                                            RecordEditMode editMode,
                                            SRecordInstance record,
                                            FormMeta formMeta) {
            if (editMode == RecordEditMode.EDIT) {
                return new ClientSecretChangeEditor(id, formMeta, editMode, record, false);
            } else {
                return new ClientSecretEditor(id, formMeta, editMode, record, false);
            }
        }

    }
    private static class ClientSecretChangeEditor extends PasswordChangeEditor {

        private ClientSecretChangeEditor(String id,
                                         FormMeta formMeta,
                                         RecordEditMode editMode,
                                         SRecordInstance record,
                                         boolean md5) {
            super(id, formMeta, editMode, record, md5);
        }

        @Override
        protected String getChangePasswordLabelKey() {
            return "OAuth2ClientSettingsRecord.ClientSecret.Change";
        }

        @Override
        protected String getChangePasswordDescKey() {
            return "OAuth2ClientSettingsRecord.ClientSecret.Change.Desc";
        }

        @Override
        protected String getPasswordLabel1Key() {
            return "OAuth2ClientSettingsRecord.ClientSecret.Name";
        }

        @Override
        protected String getPasswordLabel2Key() {
            return "OAuth2ClientSettingsRecord.ClientSecret.Name";
        }

        @Override
        protected String getReTypeDescKey() {
            return "OAuth2ClientSettingsRecord.ClientSecret.RetypeDescription";
        }

        @Override
        protected String getPasswordMismatchErrorKey() {
            return "OAuth2ClientSettingsRecord.ClientSecret.Mismatch";
        }

    }
1 Like

You'll have to build against the 8.1.24 (or later) version of the SDK for those methods on the PasswordChangeEditor to be available to override.

1 Like

Got it, appreciated. Thank you.

@PGriffith

I Don't see any methods to override those two (password1 and password2) validators in PasswordChangeEditor
image

Am I missing something here ? I am using 8.1.24 SDK

Regards.

You can't change those. They're hardcoded to the Wicket component IDs used in the PasswordChangeEditor; the validation errors that come up are coming from Wicket.

You'd have to recreate PasswordChangeEditor in its entirety to change those, rather than overriding.

1 Like