XPages get Value selected from combo box

别等时光非礼了梦想. 提交于 2019-12-11 07:18:57

问题


I want to display the selected value from the comboBox into a label.

<xp:label id="label4">

    <xp:this.value><![CDATA[#{javascript:var componenta = Contr.getItemValueString("txt_tipcontractcv");

if (componenta == "")
{ return "void";}

if (componenta !="")
{ return "My value is "+componenta}}]]></xp:this.value>
</xp:label>

The label is on a panel, and I did a partial refresh to the respective panel. My comboBox is binded to a data element.

label4 is always void. Why? Thank you,

Florin


回答1:


I changed code into:

var componenta = getComponent("combo").getValue();

if ((componenta == null) || (null == componenta))
{ return "void";}

else if ((componenta != null) || (null != componenta))
{ return "My value is "+componenta}  

and now it returns : My value is It seems that componenta is an empty string. Why?




回答2:


Try Contr.getValue("txt_tipcontractcv") (assuming that Contr is your datasource).




回答3:


The reason is the value selected is not sent to the server. Could you give us the code for combobox, and panel with label. It will give us clear idea for the cause

  1. Are you using partial execution mode?
  2. Is combo box bind to data source value="Contr.txt_tipcontractcv"?

You may also code the label as below, if that suits

<xp:label id="label4" value="Contr.txt_tipcontractcv" />


来源:https://stackoverflow.com/questions/25719873/xpages-get-value-selected-from-combo-box

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!