Skip to Content
avatar image
Former Member

Can you pass values from component.js to contribution.ztl?

Can I set the values of parameters in my component.js file (using the getter/setter functions) and then access values in the code of the contribution.ztl file?


contribution.xml (no defaultValue is set)

title="Selected Element" 
type="int" visible="false"/>


var that = this;

that._selectedElement = 0;

that.selectedElement = function(val) {
	if (val === undefined) {
		return that._selectedElement;
	} else {
		that._selectedElement = val;
		return this;

// var x is assigned int value



/* Returns the index of the selected item */
int getSelectedMember(){*
	return this.selectedElement;

Now when I use .getSelectedMember() in my script, I expect it to return the values I set in my component.js (var x). Instead, it always returns 0.

Is it possible to access parameter values set by component.js in the contribution.ztl code?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jan 25, 2017 at 04:18 PM

    Hi Nikolaus,

    This should be possible. However, remember that the contribution.ztl runs on the server and the component.js runs on the client. You might have to execute a firePropertiesChanged() call to send the property value to the server.



    Add comment
    10|10000 characters needed characters exceeded