wso2 governance registry 4.6 add attibute to a table with maxoccurs via api

137 Views Asked by At

I created a table with maxoccurs="unbounded" to set the operations of a service. The table has a input-text and a textarea.

<table name="Operations" columns="2" maxoccurs="unbounded">
    <subheading>
        <heading>Operation</heading>
        <heading>Description</heading>
    </subheading>
    <field type="text">
        <name>Operation</name>
    </field>
    <field type="text-area">
        <name>Description</name>
    </field>
</table>

I'm trying to add operations via API, but I can only achieve to set one operation. If in the loop I execute this, the registry only shows one item and the last operation:

service.addAttribute("operations_operation", "getSomething");
service.addAttribute("operations_description", "This is a description");

If I execute this code in a loop of 5 items, the registry creates 5 rows but no text in it:

service.addAttribute("operations", "getSomething");

Which is the way to add attributes of this type via API? Thanks!

1

There are 1 best solutions below

1
On

If you are trying to add attributes using API, you can use setAttributes operation as below:

String[] operations = {"getSomething","getSomething 1","getSomething 2"};
String[] descriptions = {"This is a description","This is a description 1","This is a description 2"};
service.setAttributes("operations_operation", operations);
service.setAttributes("operations_description", descriptions);

If you want to add a new attribute into existing attributes you can use addAttribute operation.