[英]Radio button positioned after text field with onChange loses the value selected
我有以下一段代码,显示一个带有onChange事件和一个单选按钮的文本字段。 当用户在文本字段中输入一个值,然后单击单选按钮字段时,他们在单选按钮中选择的值将丢失。
为了解决这个问题,我们添加了一个按钮,用户必须先单击该按钮,然后才能在单选按钮上选择自己的选择。
这不是一个很好的解决方法,我想摆脱它。 我如何进行这项工作,以便当他们退出文本字段并单击以下单选按钮时,他们在单选按钮中选择的值仍保持选中状态?
<xp:inputText id="shortAnswerCurrency" styleClass="short-answer form-control" value="#{compositeData.dataSource[compositeData.dataBinding]}" disableClientSideValidation="true">
<xp:this.rendered><![CDATA[#{javascript:compositeData.QuestionDoc.getItemValueString("qType") == "Currency"}]]></xp:this.rendered>
<xp:this.required><![CDATA[#{javascript:compositeData.QuestionDoc.getItemValueString("qRequire") == "Yes";}]]></xp:this.required>
<xp:this.validators>
<xp:validateRequired message="This question is required. Please enter a response."></xp:validateRequired>
</xp:this.validators>
<xp:this.converter>
<xp:convertNumber type="currency" integerOnly="false" currencySymbol="$" currencyCode="USD"></xp:convertNumber>
</xp:this.converter>
<xp:this.attrs>
<xp:attr name="placeholder" value="$"></xp:attr>
</xp:this.attrs>
<xp:eventHandler event="onchange" submit="true" refreshMode="partial" refreshId="myQuestions" disableValidators="true" onComplete="$('.datePickerDiv input').datepicker({format: 'MM dd, yyyy'});">
<xp:this.action><![CDATA[#{javascript:viewScope.put(compositeData.QuestionDoc.getItemValueString("qMapping"), getComponent("shortAnswerCurrency").value);}]]></xp:this.action>
</xp:eventHandler>
</xp:inputText>
<xp:button id="currencyButton" value="Enter" styleClass="btn btn-md btn-default">
<xp:this.rendered><![CDATA[#{javascript:compositeData.QuestionDoc.getItemValueString("qType") == "Currency"}]]></xp:this.rendered>
<xp:eventHandler event="onclick" submit="true" refreshMode="partial" refreshId="myQuestions" disableValidators="true">
<xp:this.action><![CDATA[#{javascript:viewScope.put(compositeData.QuestionDoc.getItemValueString("qMapping"), getComponent("shortAnswerCurrency").value);}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:radioGroup id="radioValue" value="#{compositeData.dataSource[compositeData.dataBinding]}" styleClass="long-radiolist" disableClientSideValidation="true">
<xp:this.rendered><![CDATA[#{javascript:compositeData.QuestionDoc.getItemValueString("qType") == "Radio"}]]></xp:this.rendered>
<xp:this.required><![CDATA[#{javascript:compositeData.QuestionDoc.getItemValueString("qRequire") == "Yes";}]]></xp:this.required>
<xp:this.validators>
<xp:validateRequired message="This question is required. Please select a response."></xp:validateRequired>
</xp:this.validators>
<xp:eventHandler event="onchange" submit="true" refreshMode="partial" refreshId="myQuestions" disableValidators="true" onComplete="$('.datePickerDiv input').datepicker({format: 'MM dd, yyyy'});">
<xp:this.action><![CDATA[#{javascript:viewScope.put(compositeData.QuestionDoc.getItemValueString("qMapping"), getComponent("radioValue").value);}]]></xp:this.action>
</xp:eventHandler>
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:compositeData.QuestionDoc.getItemValue("qValues")}]]></xp:this.value>
</xp:selectItems>
</xp:radioGroup>
在单选按钮中,您在事件处理程序中提交= true。 getComponent(“ radioValue”)。value可能是错误的,您需要getComponent(“ radioValue”)。getSubmittedValue()
我有
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.