Hello community,
I am just learning JSF 2 and playing with simple custom components. Imagine an ajax enabled custom component with two inputText fields:
...
<h:body>
<composite:interface>
<composite:attribute name="domId" required="true" />
<composite:attribute name="value" required="true" />
</composite:interface>
<composite:implementation>
<h:inputText id="code" value="#{cc.attrs.value}">
<f:valueChangeListener binding="#{domBean}" >
</f:valueChangeListener>
<f:ajax event="valueChange" execute="@this"
render="name"/>
</h:inputText>
<h:inputText id="name" value="#{domBean.name}" disabled="true">
</h:inputText>
</composite:implementation>
...
The page with uses the component looks like the following:
...
<h:body>
<h:form>
<dom:domain domId="100" value="#{testCtrl.code}"/>
</h:form>
</h:body>
...
the interesting method in the class which defines the domBean looks like:
public void processValueChange(ValueChangeEvent event)
throws AbortProcessingException
{
String code = (String) event.getNewValue();
UIInput input= (UIInput) event.getSource();
name = resolveCode(code); //some magic transformation
if (name != null)
input.setValue(code); //just want to set the "entered" / "validated" text
}
I would expect that input.setValue(code) would set the inputText value, which is the deferred expression "#{cc.attrs.value}", which is linked to #{testCtrl.code} by the "parent" page. Unfortunately, testCtrl.code is never populated with the entered value.
What I am doing wrong?
Thank you!