ADF_FACES-30107: The view state of the page has expired. Load the page again.

Requirment- Resolving ADF_FACES-30107: The view state of the page has expired. Load the page again.
ugly error actually.- you don’t know what went wrong- and you will see a very long error message like
ADF_FACES-30107: The view state of the page has expired. Load the page again………………………………………………………………………..

What’s the problemFirst understand , why we get this error – The ViewExpiredException will be thrown whenever the javax.faces.STATE_SAVING_METHOD is set to server (default) and the enduser sends a HTTP POST request using or or some valueChangeEvent on a view, while the associated view state isn’t available in the session anymore. The view state is identified by a hidden input field javax.faces.ViewState of the . With the state saving method set to server, this contains only the view state ID which references a serialized view state in the session. So, when the session is expired for some reason (either timed out in server or client side, or the session cookie is not maintained anymore for some reason in browser, or by calling HttpSession#invalidate() in server), then the serialized view state is not available anymore in the session and the enduser will get this exception.With the state saving method set to client, the javax.faces.ViewState hidden input field contains instead the whole serialized view state, so the enduser won’t get a ViewExpiredException when the session expires.

In the oracle documentation this error states-

ADF_FACES-30107: The view state of the page has expired. Reload the page.
Cause: The UI state of the view has expired, either because the back button has been used too many times, too many page submissions have occurred on ther pages, or because of an underlying bug in the view code.
Action: The application using ADF should install an ADFc error handler for JSF ViewExpiredExceptions, or configure the org.apache.myfaces.trinidad.CLIENT_STATE_MAX_TOKENS web.xml parameter to a larger value.
Level: 2


Impact: Logging

How to resolve this – Find for the org.apache.myfaces.trinidad.CLIENT_STATE_MAX_TOKENS in web.xml as context parameter . If it not set as it happened to my application. Set this parameter and put value.Sometimes,it will not work for value for 15 to 20. I set it as 500.This mean , it can handle this much page submission for the pages.

Great.After reading this ,you resolved the error.

Happy coding with Vinay kumar in techartifact……

Don’t use managed bean , when you really don’t need it- Use Page Definition Variables in ADF

Requirement – to understand the concept of page variable for storing temporary page value.

Use Case- We have a check box and a table.on checking of checkbox we should show table otherwise we should not show the table.
Normally most of ADF developer will say– oh , its easy, they bind checkbox with managed bean and select the value of it and make visible true and false to table. But , in actual it impacts performance.You really don’t need a managed bean,Why you need to interact with model layer.You don’t need it.
You can create a page variable and store temporary page value.Most people don’t know about it or don’t know how to create it.Today we will discuss this.

i am assuming you have a HR schema and create a table and a checkbox.On checking of checkbox table should be visible.

Go to page definition file of page.Inside executable ,select variable and click insert inside variable like below

Now we will be creating binding for this variable.Click + on binding

Select attributValue and select variable as data source and attribute as Show Table, which we have created earlier.

Now our page defition file will look like this-

Select checkbox and bind value as #{bindings.ShowTable1.inputValue} and make autosubmit to true.
Go to table and put id of selectCheckbox to partial trigger of table.
Thats it .You have’nt used managed bean here. I think its more easy than this.Now run your page first it will look like this

Now Checked the checkbox

You are done.Now you know how to create page defition variable in page.Managed bean will not have less code.. 😀

Happy coding with Vinay Kumar in Techartifact ….