1

In a simple jsf2.0 application,I am getting this exception :javax.faces.application.ViewExpiredException View could not be restored.

In console I am getting following error: org.portletfaces.bridge.BridgeException: Must first call setPortletContext(PortletContext)

When I executed my application without useing Primefaces jar it worked properly. But after addind Primefaces jar I started getting this exception.

I am using Tomcat 7.2. EDIT: There are only 3 pages in the application and no backing bean.. A link on first page is invoking second page. But when I click on the link I am getting this error and the second page is not displayed. Cant understand the cause of the problem. Please help.

Bosco
  • 3,835
  • 6
  • 25
  • 33
  • If you're getting a ` ViewExpiredException` the view scoped backing bean has expired. Try refreshing the page. – siebz0r Aug 23 '12 at 11:10
  • Hi.. I have not yet created any baking bean. The application is so tiny that there are only 3 pages.. A link on first page is invoking second page. But when I click on the link I am getting this error and the second page is not getting displayed. – Bosco Aug 23 '12 at 11:18
  • Show us the relevant code. Without the code we cannot see what is wrong. – siebz0r Aug 23 '12 at 11:27
  • @siebz0r: The exception is not necessarily related to having a view scoped backing bean. See also http://stackoverflow.com/questions/3642919/javax-faces-application-viewexpiredexception-view-could-not-be-restored/3642969#3642969 – BalusC Aug 23 '12 at 11:56

1 Answers1

2

There are only 3 pages in the application and no backing bean.. A link on first page is invoking second page. But when I click on the link I am getting this error and the second page is not displayed.

That can happen if you're navigating by UICommand links/buttons. You should not navigate by POST links/buttons at all, but just by GET links/buttons.

Replace all those UICommand links/buttons which are incorrectly been used for page-to-page navigation by normal UIOutcomeTarget links/buttons. In other words, replace <h:commandButton> by <h:button>, <h:commandLink> and <p:commandLink> by <h:link> and <p:commandButton> by <p:button>.

I.e. do not use

<h:form>
    <p:commandButton value="Go to next page" action="nextpage" />
</h:form>

but instead use

<p:button value="Go to next page" outcome="nextpage" />

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555