Jahia Dev Forum > Getting Exception...

0 (0 Good)
0 (0 Bad)

Getting Exception when trying to use <jcr:sort> tag

by  abhinitb »  2013/04/01 10:59

Hi,

 

I am using the <jcr:sort> tag in my jsp. My requirement is to sort all the nodes on the basis of date. But I am getting NullPointer Exception for this. The list is an ArrayList of JCRNodeWrapper objects. I am able to printit in my JSP in order to validate it. But when, I pass it to the <jcr:sort< tag, it throws an excpetion. Any pointers ?

Caan anyone suggest a solution for this.

 

Thanks in advance.

 

Best Regards,

Abhinit

  (abhinitb)

Number of messages  28
Registration date
0 (0 Good)
0 (0 Bad)

Re: Getting Exception when trying to use <jcr:sort> tag

by  namitgupta »  2013/04/02 11:20

Hi,

 

I am not sure about your content retrieval method. However, if you are using JCR-SQL for content retrieval then you can simply sort the nodes based on the created/modified date. 

Example: SELECT * FROM [jnt:article] order by [jcr:created] desc

 

Regards,

Namit

  (namitgupta)

Number of messages  36
Registration date
0 (0 Good)
0 (0 Bad)

Re: Re: Getting Exception when trying to use <jcr:sort> tag

by  abhinitb »  2013/04/03 07:31

Hi Namit,

 

Actually I am fetching different kind of nodes by different queries which are already sorted with the help of query. Now, I want to merge all these nodes and sort them as a single set so that all these nodes are together sorted datewise.

When I tried using the jcr:sort tag, it is giving an exception. 

Best Regards,

Abhinit

  (abhinitb)

Number of messages  28
Registration date
0 (0 Good)
0 (0 Bad)

Re: Re: Re: Getting Exception when trying to use <jcr:sort> tag

by  namitgupta »  2013/04/04 04:13

Hi,

I think we can apply JCR:sort only to a homogenous list of JCR objects. In your case, the list contains nodes of different types.

I feel that sorting can be done using a standard Java comparator in this case.

 

Regards,

Namit

  (namitgupta)

Number of messages  36
Registration date
0 (0 Good)
0 (0 Bad)

Re: Re: Re: Re: Getting Exception when trying to use <jcr:sort> tag

by  abhinitb »  2013/04/04 12:59

That's what I did while posting this query :)

Anyways thanks.

 

Best Regards,

Abhinit

  (abhinitb)

Number of messages  28
Registration date
0 (0 Good)
0 (0 Bad)

Re: Getting Exception when trying to use <jcr:sort> tag

by  pap@commaro.com »  2013/04/04 21:14

Hello,

on which code line exactly did you get the NullPointerException ?

Regards,
Benjamin

Benjamin Papez (pap@commaro.com)

Number of messages  220
Registration date
0 (0 Good)
0 (0 Bad)

Re: Re: Getting Exception when trying to use <jcr:sort> tag

by  abhinitb »  2013/04/05 09:34

Hi Benjamin,

Please find below the partial stack trace :

 

2013-04-01 12:33:13,443: WARN  [http-8080-1] org.jahia.services.render.filter.TemplateScriptFilter: Error including the content of the template 'Path dispatch : /modules/MEP_Latest_Updates/jnt_meplatestupdatesjson/html/meplatestupdatesjson.jsp'. Cause: null
java.lang.NullPointerException
at java.util.ArrayList.<init>(Unknown Source)
at org.jahia.taglibs.jcr.node.JCRSortTag.doEndTag(JCRSortTag.java:97)
at org.apache.jsp.modules.MEP_005fLatest_005fUpdates.jnt_005fmeplatestupdatesjson.html.meplatestupdatesjson_jsp._jspx_meth_jcr_005fsort_005f0(meplatestupdatesjson_jsp.java:286)
at org.apache.jsp.modules.MEP_005fLatest_005fUpdates.jnt_005fmeplatestupdatesjson.html.meplatestupdatesjson_jsp._jspService(meplatestupdatesjson_jsp.java:103)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 
Best Regards,
Abhinit

  (abhinitb)

Number of messages  28
Registration date
0 (0 Good)
0 (0 Bad)

Re: Re: Re: Getting Exception when trying to use <jcr:sort> tag

by  pap@commaro.com »  2013/04/05 10:14

Hello Abhinit,

we will make the tag more fail-safe to prevent the NullPointerException. The problem however is in the list parameter you pass into the tag. It is either null or not of type Collection or Iterator.

What are you passing as list parameter into the tag and how?

Regards,
Benjamin

Benjamin Papez (pap@commaro.com)

Number of messages  220
Registration date