Edit several elements on a page with only one RQL command

All update methods in the style of set*Value(“templateElementName”, “new value”) immediately triggers an RQL command.

If you do so for several page elements the performance would be quite poor. To address this, jRQL offers a way to combine updates on several page elements into only one RQL command.

See the following lines how to achieve this better performance updating several elements on one page.

// 1. step – prepare the page
Page currentPg = project.getPageById(“4711”);
currentPg.startSetElementValues();

// 2. step – remember new page element values only
currentPg.addSetOptionListValue(“templateElementName”, “value”);
currentPg.addSetStandardFieldDateValue(“templateElementName”, new ReddotDate());
currentPg.addSetStandardFieldNumericValue(“templateElementName”, 20);
currentPg.addSetStandardFieldTextValue(“templateElementName”, “text value”);
currentPg.addSetStandardFieldUserDefinedValue(“templateElementName”, “value”);

// 3. step – build a combined update RQL command and trigger it
currentPg.endSetElementValues();

The first step simply empty the internally used list to remember the page element values and prepare so for step 2. You can use any method used in step 2 as often as you want – as long as they are on the same page.  Step 3 itself calls the CMS with only one RQL command and therefore boosts performance.

Neiter are text elements nor image or media element supported for a combined update. But you can trigger updates on these kind of elements at any time beside you are collecting new element values.

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: