Search code examples
jsfjsf-2eljsf-2.2

Ignore JSF action method's return value


I have a simple JSF form that almost doesn't need any Java code, it's just this:

<p:inputText required="true" value="#{newThing1}" />
<p:inputText required="true" value="#{newThing2}" />
<p:commandButton value="Add" action="#{bean.map.put(newThing1, newThing2)}" />

The map is some java.util.Map implementation. This almost works, with one problem: the Map#put returns the previous value associated with given key - and JSF tries to interpret this value as an outcome. Is there any way to circumvent this, so JSF would ignore this value? I guess I could create an EL function for the sole purpose of swallowing this value. But is there a better way?


Solution

  • Use actionListener instead of action.