PrimeFaces Ajax Reset Inputs Not Working for ViewScoped Bean #1877
-
By backing bean is ViewScoped. Within a dialog, I have one field, a Clear and an Add button. The Clear button performs an ajax reset input. If I enter a new value in the 'Title' field and click Add, I am unable to reset this field with my Clear button. To reproduce
What is the gap in my understanding of scopes and how can I clear the fields correctly? PrimeFaces v. 13.0.8 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Fixed reproducer: @TheMightyE it is your misunderstanding. If you look at the Showcase: https://www.primefaces.org/showcase/ui/misc/resetInput.xhtml?jfwid=53569 the beans are Because you are using so if you want this behavior with a ViewScoped bean I suggest your Clear button add .. <p:ajax update="panel" resetValues="true" listener="#{libraryBean.reset}" /> public void reset() {
enteredTitle = "";
} |
Beta Was this translation helpful? Give feedback.
Fixed reproducer:
discussion-1877.zip
@TheMightyE it is your misunderstanding. If you look at the Showcase: https://www.primefaces.org/showcase/ui/misc/resetInput.xhtml?jfwid=53569 the beans are
@RequestScoped
so they are cleared on every request what is beingreset
is the state of the JSF tree components for ERROR state etc.Because you are using
@ViewScoped
it is resetting the value and state when you press clear however its resetting it to the value stored in your backing bean which is@ViewScoped
and has a value where@RequestScoped
does not.so if you want this behavior with a ViewScoped bean I suggest your Clear button add ..