PropertyDefinition through code

736
4
Jump to solution
03-09-2020 09:36 PM
MurugesaPandian
New Contributor II

I am trying to create the property definition and wanted to add the drop down list in the definition form. Text box and radio UI working as expected.

But I am trying to use the property definition with displayOption, dependsOn along with allowed values parameter for dropdown box, its rendering correctly but not able to read the value from the dropdown through getValue or getValueAsString.

Could you please help me more details on displayOption and depends On parameter on propertydefinition class?

Thanks,

Murugesa Pandian

0 Kudos
1 Solution

Accepted Solutions
Stefan_Jung
Esri Contributor

Hi Murugesa Pandian‌,

if you check the PropertyDefinition class in the api you will find a method called setDependsOn, this method can be used to define the dependency.

Have a look at the "sample-adapter-properties". This is one of the examples that comes with the GeoEvent installation (samples\adapters\sample-adapter-properties) and shows how to work with allowed values and dependencies.

A few lines of code of the SampleInboundAdapterDefinition:

PropertyDefinition purpleShadeProperty = new PropertyDefinition(PURPLE_SHADE_PROPERTY, PropertyType.String, "Grape", "${sample.gep.sample-adapter-properties.ADPATER_IN_PURPLE_SHAPE_LBL}", "${sample.gep.sample-adapter-properties.ADPATER_IN_PURPLE_SHAPE_DESC}", false, false, purpleShadeAllowedValues);
 // Then set it's dependency.
 purpleShadeProperty.setDependsOn(FAVORITE_COLOR_PROPERTY + "=Purple");
 propertyDefinitions.put(PURPLE_SHADE_PROPERTY, purpleShadeProperty);

Best,

Stefan

View solution in original post

4 Replies
Stefan_Jung
Esri Contributor

Hi Murugesa Pandian‌,

I did not had any problems working with dependsOn or getting the value of a dropdown list. 

I can show you a simple example how I realized the Property Configuration. In this case databaseType will be a dropdown list with three values. Only if the selected value is SQLServer the other property will be shown:

<propertyDefinition propertyName="databaseType" label="${...PARAMETER_DATABASE_TYPE_LABEL}" description="${...PARAMETER_DATABASE_TYPE_DESC}" 
	propertyType="String" mandatory="true" readOnly="false" defaultValue="PostgreSQL">
	<allowedValues>
		<value label="${...PARAMETER_DATABASE_TYPE_OPTION_POSTGRESQL}">PostgreSQL</value>
		<value label="${...PARAMETER_DATABASE_TYPE_OPTION_SQLSERVER}">SQLServer</value>
		<value label="${...PARAMETER_DATABASE_TYPE_OPTION_ORACLE}">Oracle</value>                
	</allowedValues>
</propertyDefinition>

<propertyDefinition propertyName="...somePropertyForSQLServer" label="${...SOME_LABEL}" 
	description="${...SOME_DESC}"
	propertyType="String" defaultValue="" mandatory="false" readOnly="false" dependsOn="databaseType=SQLServer">
</propertyDefinition>

To get the selected value of the databaseType this works fine for me:

if (hasProperty("databaseType")) { 
  ..
  ... = getProperty("databaseType").getValue().toString(); 
  ..
}‍‍‍‍

Are you defining the properties by XML or by Java Code? 

If my snippets does not help you, it would be the best if you provide an example that does not work like expected.

Best,

Stefan

MurugesaPandian
New Contributor II

Stefan,

Thank you very much for your time to reply/

Yes I I am developing the properties and GeoEventDefinition in java code instead of XML, Still no sign of getting the correct value for depends on , I don't see anywhere more about the "dependsOn" property and its accepted value in the api documents.

Could you please tell me how you managed to get the details of the value datbaseType=SQL Server

dependsOn="databaseType=SQLServer"

Any how my allowed values are just Value1 and Value 2 in drop down list and its not depend anyother sources.
Thank you again for your time.

0 Kudos
Stefan_Jung
Esri Contributor

Hi Murugesa Pandian‌,

if you check the PropertyDefinition class in the api you will find a method called setDependsOn, this method can be used to define the dependency.

Have a look at the "sample-adapter-properties". This is one of the examples that comes with the GeoEvent installation (samples\adapters\sample-adapter-properties) and shows how to work with allowed values and dependencies.

A few lines of code of the SampleInboundAdapterDefinition:

PropertyDefinition purpleShadeProperty = new PropertyDefinition(PURPLE_SHADE_PROPERTY, PropertyType.String, "Grape", "${sample.gep.sample-adapter-properties.ADPATER_IN_PURPLE_SHAPE_LBL}", "${sample.gep.sample-adapter-properties.ADPATER_IN_PURPLE_SHAPE_DESC}", false, false, purpleShadeAllowedValues);
 // Then set it's dependency.
 purpleShadeProperty.setDependsOn(FAVORITE_COLOR_PROPERTY + "=Purple");
 propertyDefinitions.put(PURPLE_SHADE_PROPERTY, purpleShadeProperty);

Best,

Stefan

MurugesaPandian
New Contributor II

Thanks Stefan,

appreciate for your time and effort, Yes I have found the sample code snippet in the "GeoEventDeveloperGuide", 27th page on the  document which is part of sdk.
Fnally got resolved this simple UI property

0 Kudos