是否可以通过自定义控件上的属性定义来定义一些SSJS?
例如,要测试,我在一个名为onClickCode的自定义控件上有一个属性定义。在上述自定义控件中,我有一个单选按钮,在onClick / onChange事件中,我尝试编写CompositeData.onClickCode。这似乎在页面加载时执行,而不是在onClick事件上执行。
传递属性定义的代码是:
((time[0] - '0') * 600) + ((time[1] - '0') * 60) + ((time[3] - '0') * 10) + (time[4] - '0')
该自定义控件中单选按钮上的代码为:
<xc:ccQuestionInterimRadiosYesNo required="true"
dataSource="#{document1}" fieldName="Q1"
helpText="Please select an answer"
placeholder="Enter any further details here..."
questionHeader="primary" questionTextNJD="QuestionTextNJD">
<xc:this.radioOptions><![CDATA[#{javascript:return ['Yes', 'No'];}]]></xc:this.radioOptions>
<xc:this.questionText><![CDATA[${javascript:"Ready for section 2?"}]]></xc:this.questionText>
<xc:this.onClickCode><![CDATA[#{javascript:'print("Hello")'}]]></xc:this.onClickCode>
</xc:ccQuestionInterimRadiosYesNo>
更新:
页面上的自定义控件通过:
<!-- RADIO BUTTON GROUP -->
<xp:radioGroup
loaded="${!empty compositeData.placeholder}"
value="#{compositeData.dataSource[compositeData.fieldName]}"
required="${compositeData.required}" layout="lineDirection">
<xp:this.validators>
<xp:validateRequired
message="#{javascript:compositeData.helpText}">
</xp:validateRequired>
</xp:this.validators>
<xp:this.id><![CDATA[${javascript:"radioGroup"+compositeData.fieldName}]]></xp:this.id>
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:compositeData.radioOptions}]]></xp:this.value>
</xp:selectItems>
<xp:eventHandler event="onchange"
submit="true" refreshMode="complete">
<xp:this.action><![CDATA[#{javascript:compositeData.onClickCode}]]></xp:this.action>
</xp:eventHandler></xp:radioGroup>
自定义控件中单选按钮的onChange事件的代码:
onClickCode="#{javascript:test1}"
包含代码的脚本是我主题的一部分:
if (compositeData.onClickCode) {
compositeData.onClickCode.call();
}
该脚本中的代码为:
<script src="/StdServerScripts.jss" clientSide="false"></script>