Pablo
Pablo

Reputation: 3467

Show Richfaces Component on event selection

I would like to know how could I retrieve my jsf component value, when an event is executed. For example consider this component:

<rich:select id="selectEmpresa" 
    value="#{macroprocesoController.empresaSeleccionada}"
    converter="genericConverter" enableManualInput="true" onchange="if(!#{rich:component('selectEmpresa')}.getValue()) return false;">
    <f:selectItems value="#{selectItemsController.empresaItems}" />
    <a4j:ajax execute="@this" render="macroProcesosTable" event="selectitem" listener="#{macroprocesoController.empresaSelectedListener}"></a4j:ajax>
    <a4j:ajax execute="@this" render="macroProcesosTable" event="change" listener="#{macroprocesoController.empresaSelectedListener}"></a4j:ajax>
</rich:select>

What I want is to conditionally execute the a4j:ajax for the change event, so that when the component executes the selectitem event, and thus setting a value, the change event will be bypassed. However this is not working, any suggestions or a way to do what I need?

Upvotes: 0

Views: 3269

Answers (1)

BalusC
BalusC

Reputation: 1109570

onchange="if(!#{rich:component('selectEmpresa')}.getValue()) return false;"

This expression is evaluated when the view is rendered, not when the DOM event executes (check the generated HTML source to see it yourself). You'd need to use JavaScript instead to get the current value. The following should do:

onchange="if (!this.value) return false;"

or just

onchange="return !!value;"

Upvotes: 1

Related Questions