• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help with the State

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

Hello all,

I am new to JSF .. I have a question...


I have an input text
<h:inputText .... >
and

<h:commandButton ...

I fill in the input text , then I click the command button in order to fill in a table with the result that I bring from the database ...

now the Backing bean I am using is set to "Request" scope ...

the first time I click the action, the table gets populated with the data..

but If I click any where else in the page to refresh it .. the values of the table are lost ...

I know that my question is a silly one ... but please help ...

I tried changing the scope to "Session" and it worked ... but isnt that consuming memory .. it will stay saved in memory ...

is there another way , please explain to me ... I feel that I am missing something ...

appreciate your help any1

thanks in advance ..
 
Greenhorn
Posts: 20
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You lose your values because a request scoped bean is destroyed and reconstructed with each request. Maybe view scope solves your problems, it stays alive as long as you stay on a page.
 
bash bashtoko
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Thanks for the help ... I get it now..

and if I want the values to be preserved over 2 pages, should I use session or what ??
 
Rui Azevedo
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For multiple pages, if you are using CDI, conversation scope is probably the most appropriate. Otherwise, you can go with session scope or define a custom scope of your own, but that is not so trivial.
 
bash bashtoko
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Thanks a lot !
 
bash bashtoko
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I hope that I dont disturb you ...

I couldnt find on the net how to create a custom Managed bean scope

can you tell me how ?

Thanks.
 
Rui Azevedo
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've never done it myself. But maybe you can find some pointers here and here.
 
reply
    Bookmark Topic Watch Topic
  • New Topic