views:

244

answers:

1

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!

+1  A: 

Finally, after hours of tracing, I realized that this is a bug in the myfaces 2.0.0 implementation. Using a recent 2.0.1 snapshot, it works.

For more information, please have a look at the issue in the apache tracker: https://issues.apache.org/jira/browse/MYFACES-2675

MRalwasser