0

Hi I have the following jsf component

<h:inputTextarea id="in"
     value="#{mycontroller.myvalue}"
     title="sometitle"
     readonly="false"
     required="true"
     rows="10"
     styleClass="myclass"
     immediate="false"
     label="somelabel"
     rendered="true" >
<f:ajax event="inputChange" />
</h:inputTextarea>

Whenever a change occurs in inputTextarea the function mycontroller.setMyValue is called that sets the attribute "myvalue" to the corresponding value. However, the setMyValue is not called whenever myvalue="" (empty String), i.e. the content of the text area is deleted. This has as a result the myValue to have an older value whenever mycontroller calls the getMyValue.

However if required="false" then even if myvalue is an empty string the setMyValue is called.

I've tried to change the event in the ajax from inputChange to blur...but nothing happened. I have the same behaviour.

Any ideas how to fix this?

Thanks

Symeon Mattes
  • 1,169
  • 16
  • 40
  • An 'empty' value is a non-present value, making the '`required="true"`' check fire and JSF not setting the value in the backingbean. So it behaves exactly as you tell it to. See #3 in https://stackoverflow.com/questions/2118656/commandbutton-commandlink-ajax-action-listener-method-not-invoked-or-input-value. The basic solution is setting required to false, so I fail to actually see the problem. – Kukeltje Dec 24 '18 at 12:53
  • I need both the validation in the form and the value being able to be set as empty string. – Symeon Mattes Dec 24 '18 at 19:23

0 Answers0