0

I wrote a JSF2 custom tag extended UIInputclass:

<custom:param lang="fr" disabled="#{search.disabled}"
styleClass="#{search.styleClass}"
style="width: 95px"
value="#{search.value}" />

And I want to evaluate the value like this :

if (StringUtils.isNotEmpty((String) this.getSubmittedValue())) {
  if (valeur.getCode().equals(this.getSubmittedValue())) {
    writer.writeAttribute("selected", "selected", null);
  }
} else {
  if (valeur.getCode().equals(this.getValue())) {
    writer.writeAttribute("selected", "selected", null);
  }
}

Everything works fine but the setValue method of UIInput class is never call.

I overrided the setValuemethod of UIInput class with :

@Override
public void setValue(Object value) {
  if (((String)value).startsWith("#")) {
    getStateHelper().put(ParametrageTag.ATTRIBUT_VALUE, (String) value);
  } else {
    this.value = (String)value;
  }
}

I put a breakpoint but this method is never call. The value attibute is always null.

I don't understand what is wrong because all other attribute of my custom tag are correctly setted.

There is a special way to obtain the value attribute ?

Tarik
  • 4,961
  • 3
  • 36
  • 67
Anubis
  • 1
  • 2
  • did you tried to add a h:messages to your page? if there is some conversion / validation errors then JSF will skip the Update Model Phase – Tarik Feb 23 '15 at 22:58
  • There is a h:messages in my page. – Anubis Feb 25 '15 at 13:52
  • I don't think you even need to override the satValue method, could you test if your value isValid using `isValid()`? I think this Q&A would be very useful to you: http://stackoverflow.com/questions/10948831/difference-between-uiinputgetvalue-and-getlocalvalue-during-validation – Tarik Feb 25 '15 at 15:21
  • Thanks a lot. The link helped me. Everything works now. – Anubis Feb 25 '15 at 18:21

0 Answers0