HtmlSelectOneRadio单击两次以触发Valuechangeevent侦听器

时间:2012-03-22 14:43:55

标签: jsf richfaces radio-button valuechangelistener

我正在尝试动态创建一个有三个选项的单选按钮的表单。使用单选按钮显示选项,但问题是仅在单击按钮两次时才触发ValueChangeEvent。

我的XHTML是:

 <h:column>

<h:selectOneRadio id="UserTypeOption" value="#{userRegistrationBean.businessInfo.userType}"
valueChangeListener="#{userRegistrationBean.generateDynamicFormFields}">
<a4j:ajax event="valueChange" render="supplementQuestionForm1"/>
<f:selectItems id="USERTYPE" value="#{userRegistrationBean.userTypeList}"/>
</h:selectOneRadio>
</h:column>

Java代码段是:

private static org.ajax4jsf.component.behavior.AjaxBehavior    
ajaxBehavior=(org.ajax4jsf.component.behavior.AjaxBehavior
) FacesContext.getCurrentInstance().getApplication().createBehavior(
org.ajax4jsf.component.behavior.AjaxBehavior.BEHAVIOR_ID);
static
{ Collection<String> renders = new ArrayList<String>();
ajaxBehavior.addAjaxBehaviorListener(userRegistrationBean.getValueChangeListener());
renders.add("supplementQuestionForm1");
ajaxBehavior.setRender(renders);}

HtmlSelectOneRadio radio= (HtmlSelectOneRadio) FacesContext.getCurrentInstance().getApplication().createComponent(HtmlSelectOneRadio.COMPONENT_TYPE);
ArrayList<SelectItem> radioBtnOptionsList = new ArrayList<SelectItem>();
radioBtnOptionsList.add(new SelectItem("TEST1","TEST1));
radioBtnOptionsList.add(new SelectItem("TEST2","TEST2));
radioBtnOptionsList.add(new SelectItem("TEST3","TEST3));

UISelectItems radioBtnOptions = (UISelectItems) FacesContext.getCurrentInstance().getApplication().createComponent(UISelectItems.COMPONENT_TYPE);
radioBtnOptions.setValue(radioBtnOptionsList);
radio.addClientBehavior("valueChange", ajaxBehavior);
radio.getChildren().add(radioBtnOptions);

请注意为什么只在第二次点击后才会触发valurchange事件。谢谢,GB

我正在RAD 8中的Websphere 7上运行RF 4.2,JSF 2。

0 个答案:

没有答案