Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| pr_methods:validatesettings [2023/04/04 07:06] – removed - external edit (Unknown date) 127.0.0.1 | pr_methods:validatesettings [2025/06/12 04:00] (current) – Change to AwareIM aware_support3 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | {{tag> | ||
| + | ====validateSettings (Properties, | ||
| + | <code java> | ||
| + | throws Exception</ | ||
| + | |||
| + | This method is called when changes to the business object (which include changes to the channels) are committed. The editor is supposed to validate the settings and throw the exception with the appropriate message if the settings are invalid. The validation should happen during editing as well, however, this method may be useful when the editor was never invoked by the user in the first place so that the default settings are committed. The default settings for the channel, however, may not be complete and need validation. | ||
| + | |||
| + | ===Parameters=== | ||
| + | |'' | ||
| + | |'' | ||
| + | |||
| + | ===Throws=== | ||
| + | The exception if channel settings are invalid. | ||
| + | |||
| + | <callout type=" | ||
| + | |||
| + | Below is an example of the Channel Settings Editor that edits the settings of the E-mail channel: | ||
| + | |||
| + | <code java> | ||
| + | { | ||
| + | public EmailSettingsEditor() | ||
| + | {} | ||
| + | public PropertiesstartEditing (int intelligenceType, | ||
| + | throws Exception | ||
| + | { | ||
| + | StringhostServer =null; | ||
| + | StringfromAddress=null; | ||
| + | StringuserName=null, | ||
| + | if (initialSettings!=null) | ||
| + | { | ||
| + | hostServer =initialSettings.getProperty (MAIL_HOST); | ||
| + | fromAddress=initialSettings.getProperty (MAIL_FROM_ADDRESS); | ||
| + | userName =initialSettings.getProperty (CHANNEL_SETTINGS_USER_NAME); | ||
| + | password =initialSettings.getProperty (CHANNEL_SETTINGS_PASSWORD); | ||
| + | } | ||
| + | EmailSettingsDlgdlg=null; | ||
| + | if (parent instanceof Frame) | ||
| + | { | ||
| + | dlg=new EmailSettingsDlg((Frame)parent, | ||
| + | } | ||
| + | else if (parent instanceof Dialog) | ||
| + | { | ||
| + | dlg= new EmailSettingsDlg((Dialog)parent, | ||
| + | } | ||
| + | dlg.show(); | ||
| + | if (dlg.getReturnStatus()!=EmailSettingsDlg.RET_OK) | ||
| + | return null ; | ||
| + | Propertiesprops=new Properties(); | ||
| + | props.setProperty(MAIL_HOST, | ||
| + | props.setProperty(MAIL_FROM_ADDRESS, | ||
| + | props.setProperty(CHANNEL_SETTINGS_USER_NAME, | ||
| + | props.setProperty(CHANNEL_SETTINGS_PASSWORD, | ||
| + | return props; | ||
| + | } | ||
| + | public void validateSettings(Propertiessettings, | ||
| + | throws Exception | ||
| + | { | ||
| + | StringhostServer = null ; | ||
| + | StringfromAddress= null ; | ||
| + | if (settings!= null ) | ||
| + | { | ||
| + | hostServer =settings.getProperty(MAIL_HOST); | ||
| + | fromAddress=settings.getProperty(MAIL_FROM_ADDRESS); | ||
| + | } | ||
| + | if (hostServer== null ||hostServer.length()==0) | ||
| + | throw new Exception(" | ||
| + | if (fromAddress== null ||fromAddress.length()==0) | ||
| + | throw new Exception(" | ||
| + | } | ||
| + | }</ | ||