JSF 1.2- >2.0 :viewId parameter for save view stat

2019-02-27 03:09发布

问题:

We are migrating our JSF 1.2 project to JSF 2.0 and using a command button in a JSP page .Clicking command button get a reponse from external system and display response.

While clicking this command button we are getting blank page with below execption

During debug I found that we are getting a success response but its not able to find original page as it lost state view ID

[8/13/13 11:01:30:538 CDT] 000000e0 webapp        E com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [Servlet Error]-[Faces Servlet]: java.lang.NullPointerException: viewId parameter for  save view state is null
    at org.ajax4jsf.application.AjaxStateHolder.saveState(AjaxStateHolder.java:155)
    at org.ajax4jsf.application.AjaxStateManager.saveStateInSession(AjaxStateManager.java:523)
    at org.ajax4jsf.application.AjaxStateManager.buildViewState(AjaxStateManager.java:503)
    at org.ajax4jsf.application.AjaxStateManager.saveView(AjaxStateManager.java:462)
    at org.apache.myfaces.shared_impl.view.JspViewDeclarationLanguageBase.renderView(JspViewDeclarationLanguageBase.java:206)
    at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:263)
    at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:59)
    at org.apache.myfaces.tomahawk.application.ResourceViewHandlerWrapper.renderView(ResourceViewHandlerWrapper.java:169)
    at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
    at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)

Is there any specific config required in web.xml to save view state ?

回答1:

The presence of Ajax4jsf 1.x specific org.ajax4jsf.* classes in the stacktrace tells that you're still using Ajax4jsf for JSF 1.x.

This is not compatible with JSF 2.x. You must remove all Ajax4jsf 1.x related JAR files and registrations in web.xml. You need to use JSF's own <f:ajax> facilities instead, or to upgrade to RichFaces 4.x which bundles a newer, JSF 2.0 compatible, version of <a4j:xxx> tags. Note that this in turn requires Facelets instead of JSP. So you have to migrate from JSP to Facelets as well.

See also:

  • Migrating JSF 1.1 with Ajax4jsf 1.x to JSF 2
  • Migrating from JSF 1.2 to JSF 2.0
  • a4j:support tag not found using JSF 2