2016-11-04 9 views
0

서버 측 자바 스크립트를 사용하여 XPage에서 배열을 필터링하고 싶습니다. 이 오류가 발생하는 이유는 어떤 이유가서버 사이드의 Array.filter 함수 자바 스크립트

list.filter(function(){ 

}); 

: 나는이 같은 함수를 호출 ["elem1","elem2","elem3"]

같은 문자열의 배열을 가지고

Error calling method 'filter(Function)' on an object of type 'Array [JavaScript Object]'

: 불행하게도 나는 다음과 같은 오류가 발생합니다? 이 함수는 ssj에도 존재합니까?

이 질문은 Xpages/Lotus Notes가 백그라운드에서 Rhino를 실행한다는 것이 명확하지 않기 때문에 중복되지 않습니다.

+1

https://gist.github.com/katio/08bf3f5e058b950cd957 – mplungjan

답변

1

사용중인 서버 측 JavaScript 환경이 ES5 기능을 지원하지 않는 것처럼 들리지만 (2009 년 12 월 5 판 사양의 기능)

당신은 배열에 추가 된 다른 것들에 대한 polyfill을 사용 MDN를 볼 수 있지만, 조심 수

: ES5 기능이 지원되지 않는 경우,이 코드를 의미들을 열거하지 않고 Array.prototype에 일을 추가하는 것은 불가능하다 (잘못 입력하면 for-in에서 loop through arrays까지 영향을받습니다.

+0

polyfill로 받아 들여서 트릭을 만들었습니다. 그냥 ssjs 스크립트 라이브러리에 넣고 페이지에 포함 시키십시오. 그럼에도 불구하고 다른 모든 의견과 조언을 주셔서 감사합니다! – MeMeMax

0

XPages 뒤에 Rhino가 있습니다. 그리고이 SO 주제 No Array.filter() in Rhino?은 구식입니다.

편집 : 아니요, 아닙니다. 몇 년 전에 나는 그것에 대해 어딘가를 읽었다. 이제는 사실이 아닌 것 같습니다. (? 필립 Riand를 인용) 댄 낫 here에 의해 언급에 따르면 : 당신의 코드가 작동 할 최신 코뿔소 버전 있도록

It runs on the server jvm and uses javascript as the application language. For licensing reasons, IBM wrote their own jvm javascript engine instead of using Rhino. With Rhino shipping in java 6, they should be able to ship it in Designer 8.5 (or later). The licensing problems may have been around the extensions like @Formulas and type declarations. Classes, modules/namespaces and type declarations are coming in javascript 2 and even google is helping to get that implemented in Rhino. I'd hate to see a non-standard, javascript engine underlying the coolest web development technology in Domino.

Speaking of Rhino, the "most important new feature that is not as certain to be in 8.5 as XPages" uses Rhino and other jvm scripting languages on the client. If this makes it into the product, two years from now most new Notes applications will be written in neither Lotusscript nor Java. I'll leave it at that.

는 사실, 어떻게 XPages에서 코뿔소를 사용하는 몇 가지 항목이 있습니다. 어쨌든, 내 조언은 Java 호출을 사용하는 것입니다.

+0

ssjs가 기본적으로 Rhino를 사용한다는 확증을 찾지 못했습니다. 나는 [이] (http://dontpanic82.blogspot.co.uk/2010/05/using-rhino-javascript-engine-in-xpages.html)과 같은 것을 발견하고있다. /stackoverflow.com/questions/26695434/how-to-clean-ssjs-in-domino-server-after-someone-used-javascript-prototype-in-a)) 및 [this] (https : //en.wikipedia .org/wiki/Comparison_of_server-side_JavaScript_solutions). 그렇지 않은 것이 좋습니다. 그리고 Rhino에는 ** Array ** 필터 **가 ** 있습니다 **. 근원을 인용 할 수 있습니까? –