Bosco
Bosco

Reputation: 4052

Simple jsf2.0 application : javax.faces.application.ViewExpiredException View could not be restored

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.

Upvotes: 1

Views: 1822

Answers (1)

BalusC
BalusC

Reputation: 1108632

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:

Upvotes: 2

Related Questions