Skip to Content
avatar image
Former Member

Creating a extension for Lumira Designer

I'm working on an SDK extension that passes an array to a component.js function. In debug mode the array has no data, when it should. Here is the function:

this.tableheader = function(value) {
	for (var int = 0; int < value.length; int++) {
		alert(value[int]);
	}
}

here is the contribution.xml property:

		<property
			id="tableheader"
			title="Table Header"
			type="Array"
			group="Display"/>

here is the contribution.ztl (I have tried both):

  void setHeader(Array value) {*
    this.tableheader = value;
  *}

  void setHeader(StringArray value) {*
    this.tableheader = value;
  *}

this is the error I get in eclipse:

TABLE_1.setHeader(test);" "java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 0

Chrome has the same error in debug.

I can change the property type to a string and it sends

value = '[","data","moredata","more","]'

Thanks for you help.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jan 04 at 09:47 AM

    Hi Justin,

    I didn't check your problem in detail yet but I'd like to share a thought that crossed my mind while reading your question. Usually the sdk properties values are passed to a specific javascript pattern on the js files to deal with updates (getter and setter in one function). It looks like this:

    this.tableheader = function(value) {
       if (value === undefined) {
    	return saveTableheader;
       }
       else {
    	saveTableheader = value;
       }
    };
    

    So in your case you would put your alerting code on the else block. The saveTableHeader variable needs to be defined globally on your js file to contain the passed values cross functions.

    Did you mean that the alert block promts the message you expect when changing the property type from array to string (or StringArray)?

    Kind regards

    Martin

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Justin,

      I was trying to introduce you to the pattern how the DesignStudio framework invokes functions during the SDK component's lifecycle.

      During the first call the value of the function is undefined, therefore the first if clause should handle the "getter" part. I realized that by using a global variable which then keeps the current value of that property. The second call is the "setter" part, where the value argument of the function contains the value coming from the designer.

      Your example above is mixing update code with property value handling. After every property change the framework method "afterUpdate" or "afterDesignStudioUpdate" (depending on which sdk handler you use) is being called. Your logic should be handled there.

      It might be worth to have a look at the SDK examples from SAP. They have a good set of implementation variations and patterns in there.

      Kind regards

      Martin