This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Aug 7, 2014, 11:21 AM
41 Posts

Use @Sort() in dblookup

  • Category: Server Side JavaScript
  • Platform: All
  • Release: 9.0.1
  • Role: Developer
  • Tags: @Sort()
  • Replies: 7

Dear Team,

 

I want to use @Sort() in dblookup for sorting the values but @sort is not working so can you give me a alternate solutions.

Aug 7, 2014, 2:22 PM
26 Posts
Can you post the code
and what the results of the dblookup returns.
Aug 7, 2014, 6:28 PM
1 Posts
where?

where (what specific desing element) are you putting this formula?

Aug 7, 2014, 8:17 PM
586 Posts
Think about it.

It's impossible for anyone to assist you without seeing your original code.  It's best if you can pase the code and then detail what "isn't working".  Is it an actual error?  if so paste that in as well.  Is it unexpected results?  If so then please describe.

 

I'm not a fan of @dbLookup in XPages really but if I was going to use it there is an xsnippet on OpenNTF that is better.  And I believe that also contains an option for sorting inside it.  I think it's called @DbLookupArray so you might want to check that out.

 

 

Aug 7, 2014, 10:21 PM
453 Posts
Not sure @DBLookUp is a good way to go

I have done a fair bit with re-ordering the returns from a FTSearch or a viewEntryCollection. A getAllEntriesByKey returns the viewEntryCollection in the same order as in the view. When that does not do it then my next would be a documentCollection or a FTSearch and then pass the resulting collection into a TreeMap to get the documents in the correct order. The process is actually pretty fast and the sort order etc can be controlled very precisely. A little bit of code, but that's the way that I would do it. I did a test on a returned collection of 5000 documents that I did the treeMap and returned it to a repeat control and the response was fully acceptable. I always run my test on an old server that is memory and processor challenged if it works well there then I know that when it gets to a production environment it should perform well.

I went down the @DBLookup road for awhile before frustration and kludge said that I was going down the wrong road. Backed up and built the treeMap process and wont go back. I believe David L has a video on treeMap and hashMap on his Notesin9 site take a look at that. As I said it took a bit of time to get the treeMap working but well worth the trouble IMHO.

Aug 7, 2014, 11:03 PM
586 Posts
TreeMaps

Bill,

TreeMaps are great and I really like them.  But as you keep going down the Java path keep your eye on "comparators".  If you convert your document into a serializable java object which I do a lot of, then via Comparator's and "Comparables" you can add sorting logic to your java object.  That's really cool.  Then you don't have to use TreeMaps but you can have an ArrayList and do a Collections.sort on it... Or use a Set and get it sorted without needing the key/value pair.  Lot of neat possibilities.

Aug 8, 2014, 3:01 PM
453 Posts
Comparators?

David

as I previously said you have convinced me that I need to move more into the JAVA domain :-) and have developed a couple of pretty cool managed beans with a lot of help from my friends (at least I sure hope they still are).

Your suggestion sounds interesting. Do you have a sample of doing this? This might be a great NotesIn9 topic, I know I would watch it.

Bill

Aug 9, 2014, 12:03 AM
586 Posts
:-)

Coming soon to NotesIn9... :-) I hope at least.  I'm having a hard time keeping up with my contributors at the moment.  But it's coming.  A LOT of Java coming actually.  I have 2 shows by someone on Java up next.  Hopefully early next week.

I will tell you that this blog post helped me tremendously.  http://www.mkyong.com/java/java-object-sorting-example-comparable-and-comparator/  There's a bunch of great Java posts on that site actually.

 

 


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal