我有以下代码,它提供了一个带有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>
答案 0 :(得分:0)
在radiobutton中,您在事件处理程序中提交= true。 getComponent(&#34; radioValue&#34;)。值可能是错误的,你需要getComponent(&#34; radioValue&#34;)。getSubmittedValue()
我有