我有一个下拉列表,我想用它来选择用户想要工作的省份(是的,我在加拿大!)。
我很难弄清楚如何获取点击的值,因为我想将该值放在会话范围变量中。
下拉列表的代码现在以这种方式构建:
<xe:this.bannerUtilityLinks>
<xe:basicContainerNode
submitValue="provinceSwitch">
<xe:this.children>
<xe:basicLeafNode label="Québec"></xe:basicLeafNode>
<xe:basicLeafNode label="Ontario"
submitValue="Ontario">
</xe:basicLeafNode>
<xe:basicLeafNode label="Maritimes"
submitValue="Maritimes">
</xe:basicLeafNode>
<xe:basicLeafNode label="West"
submitValue="West">
</xe:basicLeafNode>
</xe:this.children>
<xe:this.label><![CDATA[#{javascript:if(!!sessionScope.province) {
sessionScope.province;
} else {
"Province";
}}]]></xe:this.label>
</xe:basicContainerNode>
<xe:basicLeafNode submitValue="langSwitch"
styleClass="lotusFirst">
<xe:this.label>
<![CDATA[#{javascript:if(!!sessionScope.lang) {
if(sessionScope.lang=="FR") {
return "English";
} else {
return "Français";
}
} else {
return "English";
}}]]>
</xe:this.label>
</xe:basicLeafNode>
<xe:this.bannerUtilityLinks>
我已经定义了一个eventHandler,用于选择语言:
<xp:eventHandler event="onItemClick" submit="false"
refreshMode="partial" refreshId="PanelAll">
<xe:this.action><![CDATA[#{javascript:var submittedValue=context.getSubmittedValue();
if(submittedValue=="langSwitch") {
if(!!sessionScope.lang) {
if(sessionScope.lang=="FR") {
sessionScope.lang = "EN";
} else {
sessionScope.lang = "FR";
}
} else {
//since the default is FR, the first time it is clicked means we want to go to English
sessionScope.lang = "EN";
}
return;
}}]]>
</xe:this.action>
</xp:eventHandler>
如何从下拉列表中获取所选项目值并对其进行操作?我需要设置会话范围变量并进行完全(或部分)刷新。
谢谢:)
答案 0 :(得分:2)
您必须向您已经拥有的onItemClick添加代码,因为该事件会为应用布局执行所有onclick事件。