Ignore JSF action method's return value

Viewed 116

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?

1 Answers

Use actionListener instead of action.

Related