This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSF and the fly likes Help with the State Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Help with the State " Watch "Help with the State " New topic
Author

Help with the State

bash bashtoko
Greenhorn

Joined: Jan 20, 2011
Posts: 14

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 ..
Rui Azevedo
Greenhorn

Joined: May 30, 2010
Posts: 20
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

Joined: Jan 20, 2011
Posts: 14


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

Joined: May 30, 2010
Posts: 20
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

Joined: Jan 20, 2011
Posts: 14


Thanks a lot !
bash bashtoko
Greenhorn

Joined: Jan 20, 2011
Posts: 14


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

Joined: May 30, 2010
Posts: 20
I've never done it myself. But maybe you can find some pointers here and here.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with the State
 
Similar Threads
2 jtables not working between frames
Simple EL code is not working
Table Model data not getting updated after JTable looses focus
Please Help.Is it not possible in Struts to map indexed element ?
How to refresh the table ?