Problem with resetInput

Community Driven Extensions Project
Post Reply
raedkit
Posts: 12
Joined: 17 Oct 2012, 13:37

13 Nov 2012, 11:05

Hi all,

I have a problem with resetInput using p:selectOneMenu . The value of the selectOneMenu is reset to the default value but the selected item shown doesn't change. Here is an example (a part of my search form) :

Code: Select all

<p:selectOneMenu id="applicationUser"
						value="#{actionHistorySearchForm.applicationUser}"
						effect="fade">
						<f:selectItem itemLabel="Anyone" itemValue="" />
						<f:selectItems value="#{userRepository.list}" />
</p:selectOneMenu>

<p:commandButton id="reset" value="Reset" type="reset"
				icon="iconClearForm" update="filtersPanel" process="@this">
				<pe:resetInput
					for="applicationUser" />
</p:commandButton>
suppose that i have already choosen "User1" in the selectOneMenu and have clicked on the search button. Now, when i click on the reset button, the value is changed to the default value (because when i do another search the history of all the users is shown) but "User1" is still shown in the selectOneMenu. Any idea ?

User avatar
Oleg
Expert Member
Posts: 3803
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

13 Nov 2012, 14:57

Are you sure, you need pe:resetInput? I think you misunderstood this component. You don't have any validation for selectOneMenu. Right? What do you want to achieve with pe:resetInput?
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

raedkit
Posts: 12
Joined: 17 Oct 2012, 13:37

13 Nov 2012, 15:35

Oleg wrote:Are you sure, you need pe:resetInput? I think you misunderstood this component. You don't have any validation for selectOneMenu. Right? What do you want to achieve with pe:resetInput?
Ah ok, all i wanted is to reset the form's field to their default values. with pe:resetInput i was able to do that but for selectOneMenu the value was reset but the shown field is always the last selected one.

tandraschko
PrimeFaces Core Developer
Posts: 3607
Joined: 03 Dec 2010, 14:11
Location: Bavaria, DE
Contact:

13 Nov 2012, 15:55

I think resetValue() for UISelectOne does not work as you expected. This is not problem of resetInput. It just calls resetValue() for the given component.
Thomas Andraschko

PrimeFaces Developer | PrimeFaces Extensions Founder

Apache Member | PMC @ OpenWebBeans, DeltaSpike, MyFaces, BVal | Contributor @ TomEE

Blog: http://tandraschko.blogspot.de/
Twitter: https://twitter.com/TAndraschko

User avatar
Oleg
Expert Member
Posts: 3803
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

14 Nov 2012, 14:27

Reset of form fields works with a button with type="reset". But some PF components will not be reseted as expected because they are divs, etc. and not native controls.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

cagatay.civici
Prime
Posts: 18103
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

16 Nov 2012, 14:46

Yes, you have a misunderstanding and a misuse.

Button type with reset only resets html forms elements and do not submit the form.

pe:resetInput or p:resetInput, clear values of JSF components from viewstate on server side, so you need to the post the form.

raedkit
Posts: 12
Joined: 17 Oct 2012, 13:37

16 Nov 2012, 15:13

optimus.prime wrote:Yes, you have a misunderstanding and a misuse.

Button type with reset only resets html forms elements and do not submit the form.

pe:resetInput or p:resetInput, clear values of JSF components from viewstate on server side, so you need to the post the form.
well, in the example in the first post, the pe:resetInput or p:resetInput doesn't reset the p:selectOneMenu in the html form to the default value which is "Anyone" ...

cagatay.civici
Prime
Posts: 18103
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

16 Nov 2012, 15:27

Well, for that you need to do a forum search, discussed before.

Post Reply

Return to “Extensions”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests