You never told <f:ajax>
to render the current input component as well. Add @this
to the render
attribute.
<f:ajax ... render="@this otherComponent">
This must call the getter method and produce the desired HTML output. However, this will cause a new problem: passthrough attributes are ignored by Mojarra's ajax update script, see also line 1419 and forth of jsf.js
of Mojarra 2.2.4 when project stage is set to Development
(didn't check MyFaces on this one):
1419 } else if (d.nodeName.toLowerCase() === 'input') {
1420 // special case handling for 'input' elements
1421 // in order to not lose focus when updating,
1422 // input elements need to be added in place.
1423 parserElement = document.createElement('div');
1424 parserElement.innerHTML = html;
1425 newElement = parserElement.firstChild;
1426
1427 cloneAttributes(d, newElement);
1428 deleteNode(parserElement);
1429 }
So in order to keep input's focus (e.g. when triggered during keydown
), it's not replacing the entire input element with the ajax-rendered one, but only cloning its attributes. However, the cloneAttributes()
function only clones predefined HTML attributes such as id
, class
, etc, not custom ones and for sure not passthrough ones. To work around this, wrap the input element in a span and ajax-udpate it instead:
<h:panelGroup id="foo">
<h:inputText id="myComponent" value="#{myModel.value1}">
<f:passThroughAttributes value="#{myController.getAttributesFor("myComponent")}" />
<f:ajax execute="@this otherComponent"
listener="#{myController.doSomething}"
render="foo otherComponent" />
</h:inputText>
</h:panelGroup>