Skip to main content link. Accesskey S

The useful resource for IBM Lotus Domino XPages development

Submit Search


Home > UI > Work with views
xpageswiki.com
is maintained by 
Julian Buss.
and hosted by laurus.ch.
Julian Buss
Created by Anonymous on 23.07.2009 15:33:19

Hi Julian,re: Search in a view with code to optimze the search query string

I remember that in Java, strings are immutable and I can't remember if it is the same case in Jscript. If strings are immutable, it might be better to do a regex substitution instead of repeated v.replace.

Soon i'll get into xpages, so ill investigate then.

Patrick


Created by Anonymous on 01.10.2009 18:38:19

Hi Julian

the dbcolumnarray works well but the dblookuparray cannot be used more than once without causing the wrong cached value to be returned. The requestscope varaiable needs to be made more comprehensive to look something like "dblookuparray-"+viewname+"-"+k+"-"+field in a similar way to the dbcolumnarray function

Love your blog an Wiki - thanks for the help, Sean


Created by Anonymous on 01.10.2009 18:39:19

p.s. using ff3.5 amm getting the following error message when posting ....


Created by Anonymous on 01.10.2009 18:41:02

Problem submitting an area of the page.

_10f.push is not a function

Submit the entire page?

and an empty response if you click yes


Created by Julian Buss on 12.10.2009 09:51:53

true! thanks for the hint!


Created by Anonymous on 31.12.2010 08:31:43

var viewcontrol = getComponent("viewPanel1");

var ids = viewcontrol.getSelectedIds();

If more than 10 documents are selected in viewPanel1, then this throws an Unexpected runtime error:

"Error while executing JavaScript action expression

Array index out of range: 0"

plz help! to overcome this problem..


Created by vijayasree on 23.03.2011 06:43:22

How to change the field value while transfering the documents to another view with xpage button


Created by vijayasree on 23.03.2011 10:57:10

i am getting error while taking getSelectedIds()


Created by Mark Leusink on 23.03.2011 21:17:21

Julian,

This row contains an error causing it to not work at all:

var lookup = @DbLookup(@DbName, "viewname", key, 2);

It should be:

var lookup = @DbLookup(@DbName(), "viewname", key, 2);

Mark


Created by Julian Buss on 06.04.2011 10:10:52

thanks, Mark!


Created by Ronie on 17.05.2011 11:36:42

Hi Julian,

I have a view with a computed first column which looks like this:

Segment +

@If(ProductFamily="";"";"\\" + ProductFamily) +

@If(ProductCategory="";"";"\\" + ProductCategory) +

@If(ProductGroup="";"";"\\" + ProductGroup) +

@If(Product="";"";"\\" + Product)

I tried to use your code to correct the indentation of the categories. Where do I put this code exactly, because I don't see any changes...

Ronie


Created by Julian Buss on 24.05.2011 12:16:11

Ronie, the xp:scriptBlock needs to be placed somewhere after the xp:view tag.


Created by Lenni on 30.05.2011 23:46:12

Hi Julian,

I'm having the same problem as Ronie above. When it said above to put it after the view control, I put it right after and I didn't receive any errors, but nothing happened. After the reply to Ronie, I tried putting it after the and I received an error that the JavaSCript must be well-formed.

I'm so sorry to be dense about this, but could you please clarify further?


Created by Ronie on 19.07.2011 10:49:15

Hi Julian,

I still have the same problem as Lenni. can you please advise?


Created by Ronnie on 25.07.2011 15:23:37

Hi Julian,

I'm quite new to Xpages and I would like to learn how to access fields of records and use them for computations. I have tried it in Xpages where it access Lotus Notes Forms and it works fine, however, when I create Xpages accessing Lotus Notes views and insert formulas an Error 500 always occurs when I preview the view in the web browser. Could please advise me on this? Thank you in advance!


Created by Tadeopulous on 25.08.2011 15:29:08

Hi,

I'm deep frustrated - new to XPage - trying to get simple achivement

I have view - it must be show single category - because contains data for all customer

after login I put to session scope his Preferredlanguage field value (which is his UniqeID from normal Lotus form)

so it's easy to display - FILTER BY COLUMN VALUE in first column we use PreferredLanguage field - sorted and categorized

but now I must search this view - but when I add query string via Scoped variables - search put back all results - even those from other cusomer!Grrrrrrrrrrr - so Filter by Column value dosen't work after search??

Right now I'm dooing this way - add to search string scoped variable containing customer ID

it's there a simplest way??

the same is when I build my own view - via repeat control and computed field

Best regards

thanks in advance


Created by Hans-Peter Kuessner on 25.10.2011 22:56:00

Hi Julian,

I'd like to suggest an improvement to the "Search in a view with code to optimze the search query string" section: your .replace statements will only replace the FIRST occurrence of those unwanted characters. A better approach would be to use (example for the opening parenthesis):

v = v.replace (/\(/g," ");

Using the regex notation with the slashes you can add the "g" command, for "global replacement". You have to escape the parenthesis with the backslash then.

And I would replace those special characters by a blank instead of the empty string, so that the special characters are treated as word separators.


Created by Julian Buss on 18.11.2011 15:06:44

Thanks, Hans.

Are you sure that the .replace method only replaces the first occurence when a string instead of a regex is used as first parameter?

In any case, using a regex with the /g option is the safest option, I agree.


Created by Victory Tadeopulous on 25.01.2012 04:08:34

I didn't have luck using @name('[abbreviate]',@username) in the category filter. Anyone knowing how todo @Functions in the Xpage filter arena, please be un-stingy.

Instead, I ran across IBM's Javascript Reference and used this code for the Category filter and IT WORKED!:

javascript:session.getUserNameObject().getAbbreviated();

sites:

(amazingly IBM doesn't include all the variation javascript functions - for [CN], [Abbreviate], etc)

http://publib.boulder.ibm.com/infocenter/domhelp/v8r0/index.jsp?topic=%2Fcom.ibm.designer.domino.api.doc%2Fr_domino_Session_UserName.html

http://www-10.lotus.com/ldd/ddwiki.nsf/dx/NotesName_sample_JavaScript_code_for_XPages


Created by vijayasree on 03.05.2012 12:54:56

session.getDatabase("jasmine06/SRVR/polarisFT","names.nsf").open()

The above code is not working to open the db so any one can help me out..


Created by Roopesh laxman on 03.05.2012 13:11:16

did any one know @command([FileOpenDatabase];"server":"Database") to do in xpage.Should work in Client aslo.

Thanks in advance :-)


Created by Julian Buss on 14.05.2012 08:53:46

no, does not work


Created by yotam on 19.07.2012 10:48:41

Hi all.

I have a very strange problem with searching a view in xpage.

I have a text fields called "subject".

Users enters text to the field, sometime they use ":" (colon) sometime hyphen (-).

when searching part of the text without the ":" I get results.

when searching part of the text with ":" I get no results.

For example:

In the text field the user entered "old form number: QA-444".

Searching for "old form number" will bring results"

Searching for "444" will bring results

Searching for "old form number:" will bring NO results

Searching for "QA-444" will bring NO results.

Any ideas?

Thanks


Created by Craig Lordan on 07.12.2012 17:15:02

The link in the section "Customize the pager and translate the strings in a pager" is to a design partner forum with limited access. This public article may be a good replacement: http://www-10.lotus.com/ldd/ddwiki.nsf/dx/JavaScriptInternationalization.htm


Created by Johann Echavarria on 02.04.2014 17:02:09

Hello Julian.

Thank you for share your code. All your XPages series is awesome.

Please take note that in the "Search in a view" code the words that contains "or" or "that" (like ORganization) have problems. So I changed this lines:

v = v.replace("not", "\"not\"");

v = v.replace("or", "\"or\"");

for:

v = v.replace(" not ", " \"not\" ");

v = v.replace(" or ", " \"or\" ");

And now it worked with words like "ORganization".

I even wrote this function for a general use:

function viewSearchFilter(arrFieldNames){

var v:string = viewScope.get("query");

var arrQuery = [];

var sQuery

if (null !== v && "" !== v ) {

v = v.toLowerCase();

v = v.replace("\"", "");

v = v.replace("(", "");

v = v.replace(")", "");

v = v.replace("[", "");

v = v.replace("]", "");

v = v.replace("$", "");

v = v.replace(" and ", " ");

v = v.replace("{", "");

v = v.replace("}", "");

var a = v.split(" ");

v = a.join(" and ");

v = v.replace(" not ", " \"not\" ");

v = v.replace(" or ", " \"or\" ");

$.each(arrFieldNames, function(index,value){

arrQuery.push('FIELD ' + value + ' = "' + v +'"')

})

sQuery = arrQuery.join(" OR ")

//println(sQuery)

return sQuery

}else{

return ""

}

}

And I call the function like this in the search property:

viewSearchFilter(["fieldToSearch1","fieldToSearch2"])

Please take note that I use an iterator function (similar to one yours):

var $ = function() {

}

$.each = function(obj, callback){ /*Static method*/

if (null === obj){

return false;

}

for (var x in obj) {

if (obj.hasOwnProperty(x)) {

callback.call(obj, x, obj[x]);

}

}

}


Created by AR Skurka on 06.06.2014 12:25:28

Hello Julian.

here is a new Link to

==Sort a view column==

Rashid Azar told me about his solution to dynamically sort view columns. See here in his blog

==>

http://blog-rashid.rhcloud.com/?p=305