更改侦听器而不提交表单 [英] Change listener without submitting the form

查看:87
本文介绍了更改侦听器而不提交表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列表框,我想捕捉选择的变化,以便根据它填充另一个.我已经尝试过以下方式:

I've got a list box and I want to catch change in selection in order to fill an other one according to it. I've tried in the following way:

<h:selectOneMenu id="comunitaValle" value="#{struttura.nomeComunitaDiValle}" 
     onchange="submit()" valueChangeListener="#{struttura.getComuniInComunita}">
<f:selectItems value="#{struttura.comunitaValleList}" />
</h:selectOneMenu>

工作正常,但是在此页面中还有其他参数标记为

It works fine, but the fact that in this page there are other parameters marked as

required="true"

当提交表单时,我收到我的错误消息,说明已设置这些字段.我该如何避免提交整个表单,以免发生这种情况,并且仍然在2个列表框中具有正确的行为?

and when the form is submitted I get my error messages controlling that those field has been set. How can I avoid to submit the entire form to avoid this to happen and still have the correct behaviour on the 2 list boxes?

根据 https://stackoverflow,我已经找到了一种解决方案(不知道这是否是最好的解决方案) .com/a/4802483/2492962 :

<h:selectOneMenu id="comunitaValle" value="#{struttura.nomeComunitaDiValle}" 
      valueChangeListener="#{struttura.getComuniInComunita}" immediate="true">
<a4j:support event="onchange" reRender="cap"/>
<f:selectItems value="#{struttura.comunitaValleList}" />
</h:selectOneMenu>

可以吗? JBoss显示警告消息:

Can it be fine? JBoss shows a warning message:

INFO  [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.

但是刷新似乎很好.

推荐答案

根据

这篇关于更改侦听器而不提交表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆