Patrick Kwinten
Patrick Kwinten

Reputation: 2048

JSON-RPC within xp:repeat

In the article "Improve XPages Application Performance with JSON-RPC" Brad Balassaitis writes:

For example, if you have a repeat control with a collection named myRepeat and a property named myProperty, you could pass/retrieve it in client-side JavaScript with this syntax: ‘#{javascript: myRepeat.myProperty}’ Then your call to the remote method would look like this: myRpcService.setScopeVar(‘#{javascript: myRepeat.myProperty}’);

If I look at the xp:repeat control where should I set this myProperty property?

My idea is to display values from another source within a repeat control. So for each entry in the repeat control I would like to make a call via the Remote Service control and add additional information received from the service.

Anyone achieved this before?

Upvotes: 1

Views: 220

Answers (1)

Paul Stephen Withers
Paul Stephen Withers

Reputation: 15739

JSON-RPC is just a mechanism to allow you to trigger server-side code without needing a full partial refresh. myProperty is not an actual property, same as myRepeat would not, in practice, be the name of your repeat. It's an example.

Are you wanting the user to click on something in the row in order to load additional information? That's the only use case for going down the RPC route.

If you want to show additional information not available in the current entry but based on a property of that entry, just add a control and compute the value.

In terms of optimisation, unless you're displaying hundreds of rows at a time or loading data from lots of different databases or views, each based on a property in the current row, it should be pretty quick. I would recommend getting it working, then optimise it if you find server-side performance is an issue. view.isRenderingPhase() is a good option for optimising performance of read-only data within a repeat, as is custom language to minimise the amount of HTML pushed to the browser, and also using a dataContext to ensure you only do the lookup to e.g. another document once. But if the network requests to and from the server are slow, optimising the server-side code to shave a fraction of a second on processing will have not have a very perceptible impact.

Upvotes: 1

Related Questions