开发者

How to call action when select noSelectionLabel?

开发者 https://www.devze.com 2023-04-10 00:17 出处:网络
I have this code above which works perfectly when i select some of the items on him... The a4j:support works fine and rerender my another field correctly...

I have this code above which works perfectly when i select some of the items on him... The a4j:support works fine and rerender my another field correctly... The problem is if i choose one item, and then i back to "n开发者_如何学GooSelectionLabel"... When i do this for some reason my a4j:support dont work, i dont get into my method "setarFormulario" and i dont rerender my another field...

<s:decorate template="layout/form.xhtml">
            <ui:define name="label">Evento:</ui:define>
            <h:selectOneMenu value="#{home.instance.evento}" required="true">
                <s:selectItems value="#{eventoService.obterTodos()}" var="evento" label="#{messages[evento.nome]}"  noSelectionLabel="#{messages['br.com.message.NoSelection']}" />
                <s:convertEntity  />
                <a4j:support event="onchange"  action="#{home.setarFormulario}" reRender="camposFormulario" ajaxSingle="true"  />
            </h:selectOneMenu>
        </s:decorate>

How can i get into my method even if i select the noSelectionLabel? Then my home.instance.evento must be null.. or something like this...


Yor field h:selectOneMenu is required then selecting noSelectionLabel value will cause a validation error and if you had validation error, then the action="#{home.setarFormulario}" would never be called.

As a workaround you can set to true the attribute hideNoSelectionLabel for your s:selectItems then the noSelectionLabel will be hidden when a value is selected


<h:message for="id of the selectonemenu component " ></h:message>

or

remove the required =true from the selectonemenu tag

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号