AnsweredAssumed Answered

Using browse.jsp to display content name on JSP

Question asked by vsoman84 on Jan 28, 2010
Latest reply on Apr 19, 2010 by cybermakoki
Hi All,
I am working on the page 'browse.jsp' to implement a customization of mine wherin in the "details" view, inclusion of checkboxes besides the document names and their checking and submission will result in thier display in a subsequent JSP.
Here is my code snippet from line no 411 of 'browse.jsp'
BeanForSendMultiple.java is my backing bean.

<%– Primary column for details view mode –%>
<a:column id="col10" primary="true" style="padding:2px;text-align:left" rendered="#{BrowseBean.browseViewMode == 'details'}">

<f:facet name="header">
<a:sortLink id="col10-sort" label="#{msg.name}" value="name" mode="case-insensitive" styleClass="header"/>
</f:facet>

<h:dataTable binding="#{BeanForSendMultiple.dataTable}"
                             value="#{BeanForSendMultiple.nameDetails}" var="loc">
                    <h:column>
                        <h:selectBooleanCheckbox value="#{loc.selected}"/>
                        <h:outputText value="#{loc.docContentName}"/>
                    </h:column>

                </h:dataTable>


<a:actionLink id="col10-act2" value="#{r.name}" href="#{r.url}" target="new" >
<f:param name="documentDetails" value="#{r.name}" />
</a:actionLink>
<r:lockIcon id="col10-lock" value="#{r.nodeRef}" align="absmiddle" />

<h:outputLabel id="col10-lang" value="#{r.lang}" styleClass="langCode" rendered="#{r.lang != null}" />

<r:nodeInfo id="col10-info" value="#{r.id}">
<h:graphicImage id="col10-img" url="/images/icons/popup.gif" styleClass="popupImage" width="16" height="16" />
</r:nodeInfo>

</a:column>
Here is my backing bean BeanForSendMultiple

public class BeanForSendMultiple {
    private List<NamesDetails> nameDetails;
    private String []documentDetails;
    private HtmlDataTable dataTable;
   
    private NamesDetails nameFurtherDetails = new NamesDetails();
   
   
   
    public BeanForSendMultiple(){
        nameDetails = new ArrayList<NamesDetails>();   
               
           NamesDetails nameFurtherDetails1 = new NamesDetails(); 
          
          
           for(int k=0;k<=documentDetails.length;k++){
               nameFurtherDetails1.setDocContentName(documentDetails[k]);                  
           }
           nameDetails.add(nameFurtherDetails1);
    }
   
   
    public HtmlDataTable getDataTable() {
        return dataTable;
    }

    public void setDataTable(HtmlDataTable dataTable) {
        this.dataTable = dataTable;
    }

     public List<NamesDetails> getNameDetails() {
        return nameDetails;
    }

       public void setNameDetails(List<NamesDetails> nameDetails) {
        this.nameDetails = nameDetails;
    }

      
      
      
       public String submit(){
        Iterator iterator = nameDetails.iterator();
        while (iterator.hasNext())
        {
            nameFurtherDetails = (NamesDetails)iterator.next();
            System.out.print(nameFurtherDetails.isSelected());
            System.out.print(nameFurtherDetails.getDocContentName());

        }
        return "dataTableCheckBox";
    }
     public String[] getDocumentDetails() {
       return documentDetails;
    }
   
   
   
       public void setDocumentDetails(String documentDetails[]) {
        this.documentDetails = documentDetails;
    }

}
and here are the getters and setters for the document

public class NamesDetails implements Serializable
{
    private static final long serialVersionUID = 7526471155622776147L;

    private boolean selected;
    private String docContentName;
   
    public boolean isSelected() {
        return selected;
    }
       
     public void setSelected(boolean selected) {
        this.selected = selected;
    }

     public String getDocContentName() {
       return docContentName;
    }
   
       public void setDocContentName(String docContentName) {
        this.docContentName = docContentName;
    }
}
But on running the application i am getting the following stack trace: The issue being a NullPointer exception in obtaining documentDetails.length from the BeanForSendMultiple

javax.faces.FacesException: An exception occurred processing JSP page /jsp/browse/browse.jsp at line 430

427: <a:sortLink id="col10-sort" label="#{msg.name}" value="name" mode="case-insensitive" styleClass="header"/>
428: </f:facet>
429:
430: <h:dataTable binding="#{BeanForSendMultiple.dataTable}"
431: value="#{BeanForSendMultiple.nameDetails}" var="loc">
432: <h:column>
433: <h:selectBooleanCheckbox value="#{loc.selected}"/>


Stacktrace:
caused by:
org.apache.jasper.JasperException: An exception occurred processing JSP page /jsp/browse/browse.jsp at line 430

427: <a:sortLink id="col10-sort" label="#{msg.name}" value="name" mode="case-insensitive" styleClass="header"/>
428: </f:facet>
429:
430: <h:dataTable binding="#{BeanForSendMultiple.dataTable}"
431: value="#{BeanForSendMultiple.nameDetails}" var="loc">
432: <h:column>
433: <h:selectBooleanCheckbox value="#{loc.selected}"/>


Stacktrace:
caused by:
javax.faces.el.EvaluationException: Cannot get value for expression '#{BeanForSendMultiple.dataTable}'
caused by:
java.lang.NullPointerException

Hide Details

javax.faces.FacesException: An exception occurred processing JSP page /jsp/browse/browse.jsp at line 430

427: <a:sortLink id="col10-sort" label="#{msg.name}" value="name" mode="case-insensitive" styleClass="header"/>
428: </f:facet>
429:
430: <h:dataTable binding="#{BeanForSendMultiple.dataTable}"
431: value="#{BeanForSendMultiple.nameDetails}" var="loc">
432: <h:column>
433: <h:selectBooleanCheckbox value="#{loc.selected}"/>


Stacktrace:
at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:425)
at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:211)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:132)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:140)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:110)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:122)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy185.doFilter(Unknown Source)
at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.alfresco.repo.web.filter.beans.NullFilter.doFilter(NullFilter.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:122)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy185.doFilter(Unknown Source)
at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:88)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.apache.jasper.JasperException: An exception occurred processing JSP page /jsp/browse/browse.jsp at line 430

427: <a:sortLink id="col10-sort" label="#{msg.name}" value="name" mode="case-insensitive" styleClass="header"/>
428: </f:facet>
429:
430: <h:dataTable binding="#{BeanForSendMultiple.dataTable}"
431: value="#{BeanForSendMultiple.nameDetails}" var="loc">
432: <h:column>
433: <h:selectBooleanCheckbox value="#{loc.selected}"/>


Stacktrace:
at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:419)
… 40 more
Caused by: javax.faces.el.EvaluationException: Cannot get value for expression '#{BeanForSendMultiple.dataTable}'
at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:405)
at org.apache.myfaces.application.ApplicationImpl.createComponent(ApplicationImpl.java:427)
at javax.faces.webapp.UIComponentTag.createComponentInstance(UIComponentTag.java:709)
at javax.faces.webapp.UIComponentTag.findComponent(UIComponentTag.java:596)
at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:315)
at org.apache.jsp.jsp.browse.browse_jsp._jspx_meth_h_005fdataTable_005f0(browse_jsp.java:5137)
at org.apache.jsp.jsp.browse.browse_jsp._jspx_meth_a_005fcolumn_005f9(browse_jsp.java:5034)
at org.apache.jsp.jsp.browse.browse_jsp._jspx_meth_a_005frichList_005f1(browse_jsp.java:4836)
at org.apache.jsp.jsp.browse.browse_jsp._jspx_meth_a_005fpanel_005f7(browse_jsp.java:4751)
at org.apache.jsp.jsp.browse.browse_jsp._jspService(browse_jsp.java:905)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
… 50 more
Caused by: java.lang.NullPointerException
at org.alfresco.web.bean.BeanForSendMultiple.<init>(BeanForSendMultiple.java:108)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at org.apache.myfaces.shared_impl.util.ClassUtils.newInstance(ClassUtils.java:277)
at org.apache.myfaces.shared_impl.util.ClassUtils.newInstance(ClassUtils.java:268)
at org.apache.myfaces.config.ManagedBeanBuilder.buildManagedBean(ManagedBeanBuilder.java:49)
at org.apache.myfaces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:314)
at org.springframework.web.jsf.DelegatingVariableResolver.resolveVariable(DelegatingVariableResolver.java:108)
at org.alfresco.web.app.AlfrescoVariableResolver.resolveVariable(AlfrescoVariableResolver.java:94)
at org.apache.myfaces.el.ValueBindingImpl$ELVariableResolver.resolveVariable(ValueBindingImpl.java:570)
at org.apache.commons.el.NamedValue.evaluate(NamedValue.java:124)
at org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:140)
at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:386)
… 62 more

Could any one please guide me on my approach where i am missing out.
Thank You

Outcomes