Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

reset session scope managed-bean properties to default

 
Greenhorn
Posts: 21
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am looking for a solution to reset the properties of a session scope managed bean to the default values I specified in faces-config.xml (<managed-property>). I want to use this in a "reset to default" command button.

Any help would be appreciated!

Thank's and best regards
Klaus
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can't you just remove the session bean from scope. The next time it is referenced it will be recreated.
 
Franz van Betteraey
Greenhorn
Posts: 21
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for advice. Your solution resolved parts of my problem.

My problem is, that the action which should reset the bean properties is an action on the bean which I want to reset

<h:commandButton value="#{msg.reset}" action="#{invocation.reset}" immediate="true" />

The action-code



did reset the bean-properties but obviously not the components (values) which were bound to the properties. So I had to reset the components to (otherwise the old values were displayed afer render response).

The code



did it finally. Im not sure if this is the way to do it.

I am also a bit confused about the relationship between bean-property-values and component values and wether a change of the one side affects the other side. Changing the bean property in code does not necessarily also changes the components value seen on the jsp-Page. Any explanation on this topic would be helpfull for me.

Thanks anyway!

[ June 21, 2007: Message edited by: Klaus Classen ]
[ June 21, 2007: Message edited by: Klaus Classen ]
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Klaus,

I had the same problem a while ago.
It turned out that the answer is supersimple: Just reset the attributes you want to refresh.
Or am I missing out something?

Detailed solution here:
http://liferay-portlets.blogspot.com/2009/05/jsf-refresh-bean-and-get-different.html
 
reply
    Bookmark Topic Watch Topic
  • New Topic