javaspringspring-mvcmanaged-bean

Error Rendering View[null] after ManagedBean method call


I have a jsf page linked to a ManagedBean using Spring with JSF.

The page has a button, which calls a method on the bean to update one/multiple rows in the database.

The button code is :

 <t:div>
    <t:commandButton 
        style="margin-top: 21px; -webkit-margin-before: 23px;"
        value="#{text['label.report.resubmit']}" 
        action="#{filteredReportList.resubmitSelected}" />
 </t:div>

And the Bean code is

public String resubmitSelected() {
   return ("SUCCESS");
}

The database is updated successfully, and the method returns SUCCESS. However, the page then hits a NullPointerException and fails to load.

Apr 12, 2019 10:50:59 AM com.sun.facelets.FaceletViewHandler handleRenderException
SEVERE: Error Rendering View[null]
java.lang.NullPointerException
 at java.lang.StringBuffer.<init>(StringBuffer.java:139)
 at com.sun.facelets.FaceletViewHandler.getRenderedViewId(FaceletViewHandler.java:763)
 at com.sun.facelets.FaceletViewHandler.buildView(FaceletViewHandler.java:505)
 at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:567)
 at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:101)
 at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandler.java:221)
 at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:116)
 at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241)
 at javax.faces.webapp.FacesServlet.service(FacesServlet.java:199)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
 at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:75)
 at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:213)

I am stumped with what exactly is causing this - I have another button doing the same thing using the same code (with a slightly different database update) - without any error.

Am I missing something in the jsf configuration (application resources or something)

Thanks!

update:

when i remove the method functionality, and just try to return "SUCCESS", the exception is still thrown - so the error is not related to the Java method's function. I changed the method code to reflect this


Solution

  • In faces-config.xml there was no navigation-rule associated with the button. This meant that the application did not have any page to navigate to on a successful call.

    I added a navigation-rule and no longer see the nullpointer.

    <navigation-rule>
      <navigation-case>
         <from-action>#{filteredReportList.resubmitSelected}</from-action>
         <from-outcome>success</from-outcome>
         <to-view-id>/trades/search.xhtml</to-view-id>
         <redirect />
      </navigation-case>
    </navigation-rule>