Problems clearing InputText in JSF Datatable

I am trying to reset some text input fields inside a data table using the cancel button. The problem that I am facing is that if I try to cancel it, but there are validation errors, this does not allow me to do this, because it first performs the verification, finds and displays an error and displays an error before it can re-register yourself.

The obvious solution is to set "immediate = true" to the button. This eliminates the problem and allows me to cancel without checking, but the fields themselves are not set to their original values. This is because the components themselves never return data from a BECAUSE beans backup for an immediate value of true.

This is very well explained in this article: http://wiki.apache.org/myfaces/ClearInputComponents

The article presents many solutions, but none of them work for me.

  • I need to stay on one page, so changing the view is not an option.
  • I cannot reset the values ​​of ALL input fields on the page, because I want only the "line" that I canceled to be reset
  • I cannot bind components to any of the input fields because, because they are in a datable state, the binding attribute of the input field itself cannot refer to the variable 'var'. For example, the following β€œbinding” attribute is illegal and gives me an error:

    <ice: dataTable id = "poolSharesTbl" var = "node" value = "# {poolSharesManager.nodeModel}" ... & L; ice: column> <ice: inputText binding = "# {node.inputTextBinding}" ...

This may be due to "var" only in the query area.

Anyway, does anyone have any ideas on how to make this work?

+4
source share
2 answers

It hurts with JSF. You have very little control over the validation. It is best to use JavaScript to reset values. This is done in only a few lines (or in oneliner with jQuery ) instead of tens to hundreds that you would do to bypass this jsfish path.

+4
source

In any case, I ended up using a workaround that took about 50 lines of code, more or less, to manually check and convert the input text values ​​(which are the default lines) to integer. I had a bad javascript experience with JSF (Woodstock library), so I'm afraid to re-enter it on Wednesday;)

0
source

Source: https://habr.com/ru/post/1302090/


All Articles