ComboBox的onChange事件没有触发。

huangapple go评论50阅读模式
英文:

ComboBox onChange event does not fire

问题

I cannot seem to get the onChange event to fire in the xp:comboBox. The djComboBox works fine, but I have other issues with that which are not relevant here.

在xp:comboBox中,我似乎无法触发onChange事件。djComboBox可以正常工作,但这里不涉及与其相关的其他问题。

There is no issue with events such as onBlur

对于像onBlur这样的事件没有问题

These two snippets show the problem, I am probably missing something obvious, but any help is appreciated.

这两个代码片段显示了问题,我可能遗漏了一些显而易见的东西,但我会感激任何帮助。

<xp:comboBox id="comboBox1" style="width:130.0px"
    value="#{viewScope.xpcombo}" disableClientSideValidation="true" immediate="true">
    <xp:selectItem itemLabel="" id="selectItem3"></xp:selectItem>
    <xp:selectItem itemLabel="Cease" itemValue="Cease"
        id="selectItem1"></xp:selectItem>
    <xp:eventHandler event="onChange" submit="true"
        refreshMode="full" id="eventHandler1" disableValidators="true">
    </xp:eventHandler>
</xp:comboBox>

<xp:text id="computedField1">
    <xp:this.value><![CDATA[#{javascript:var req = getComponent("comboBox1").getValue();
     if( req == "Cease") {return "Some cease text frome combBox1";}
    }]]></xp:this.value>
</xp:text>
<xe:djComboBox id="djComboBox" style="width:130.0px"
                    value="#{viewScope.djcombo}" immediate="true">

                    <xp:selectItem itemLabel="" id="selectItem5">
                    </xp:selectItem>
                    <xp:selectItem itemLabel="Cease"
                        itemValue="Cease" id="selectItem6">
                    </xp:selectItem>

                    <xp:eventHandler event="onChange" submit="true" refreshMode="full" 
                        id="eventHandler2"  disableValidators="true">
                    </xp:eventHandler>
</xe:djComboBox>

<xp:text id="computedField2">
    <xp:this.value><![CDATA[#{javascript:var req = getComponent("djComboBox").getValue();
    if( req == "Cease") {
    return "Some cease text frome djCombBox";}
    }]]></xp:this.value>
</xp:text>
英文:

I cannot seem to get the onChange event to fire in the xp:comboBox. The djComboBox works fine, but I have other issues with that which are not relevant here.

There is no issue with events such as onBlur

These two snippets show the problem, I am probably missing something obvious, but any help is appreciated.

&lt;xp:comboBox id=&quot;comboBox1&quot; style=&quot;width:130.0px&quot;
	value=&quot;#{viewScope.xpcombo}&quot; disableClientSideValidation=&quot;true&quot; immediate=&quot;true&quot;&gt;
	&lt;xp:selectItem itemLabel=&quot;&quot; id=&quot;selectItem3&quot;&gt;&lt;/xp:selectItem&gt;
	&lt;xp:selectItem itemLabel=&quot;Cease&quot; itemValue=&quot;Cease&quot;
		id=&quot;selectItem1&quot;&gt;
	&lt;/xp:selectItem&gt;
	&lt;xp:eventHandler event=&quot;onChange&quot; submit=&quot;true&quot;
		refreshMode=&quot;full&quot; id=&quot;eventHandler1&quot; disableValidators=&quot;true&quot;&gt;
	&lt;/xp:eventHandler&gt;
&lt;/xp:comboBox&gt;
				&lt;xp:text id=&quot;computedField1&quot;&gt;
					&lt;xp:this.value&gt;&lt;![CDATA[#{javascript:var req = getComponent(&quot;comboBox1&quot;).getValue();
 if( req == &quot;Cease&quot;) {return &quot;Some cease text frome combBox1&quot;;}
}]]&gt;&lt;/xp:this.value&gt;
				&lt;/xp:text&gt;
				
				

&lt;xe:djComboBox id=&quot;djComboBox&quot; style=&quot;width:130.0px&quot;
					value=&quot;#{viewScope.djcombo}&quot; immediate=&quot;true&quot;&gt;

					&lt;xp:selectItem itemLabel=&quot;&quot; id=&quot;selectItem5&quot;&gt;
					&lt;/xp:selectItem&gt;
					&lt;xp:selectItem itemLabel=&quot;Cease&quot;
						itemValue=&quot;Cease&quot; id=&quot;selectItem6&quot;&gt;
					&lt;/xp:selectItem&gt;
					
					&lt;xp:eventHandler event=&quot;onChange&quot; submit=&quot;true&quot; refreshMode=&quot;full&quot; 
						id=&quot;eventHandler2&quot;  disableValidators=&quot;true&quot;&gt;
					&lt;/xp:eventHandler&gt;
					&lt;/xe:djComboBox&gt;
		
				
				&lt;xp:text id=&quot;computedField2&quot;&gt;
					&lt;xp:this.value&gt;&lt;![CDATA[#{javascript:var req = getComponent(&quot;djComboBox&quot;).getValue();
if( req == &quot;Cease&quot;) {
return &quot;Some cease text frome djCombBox&quot;;}
}]]&gt;&lt;/xp:this.value&gt;
				&lt;/xp:text&gt;

答案1

得分: 0

你应该检查数据源而不是组件(使用 getComponent)。所以例如尝试:viewScope.xpcombo == "Cease"

英文:

You should check the data source instead of the component (using getComponent). So try for example: viewScope.xpcombo == &quot;Cease&quot;

huangapple
  • 本文由 发表于 2023年4月19日 19:04:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76053747.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定