Getting started – get and set standard field values

In my article on the Unofficial RedDot CMS blog I focused on installing the plugins and configure the connection between jRQL and your MS. Follow these instructions to prepare MS for contact from jRQL. You will get 12 plugins which might help.

To get in touch with jRQL I recommend to use it from your favorite IDE. Jar all classes from the path apache-tomcat-6.0.10\webapps\rql_rdug\WEB-INF\classes and put in in your class path.

You are ready now for the first lines of code!

Assume you want to read a value from a StandardField Text from a page within one of your projects.
The easiest way is to re-use your current login information for your jRQL requests. So copy these lines and replace with your GUIDs.

String logonGuid="FFFD75C022BB41F580186D0FB63A6F27";
String sessionKey="DFD154CF95464902A7C3EFEF29FBF3C7";
String projectGuid="268F46EF5EB74A75824856D3DA1C6597";

Afterwards jRQL needs to wrap your session information into objects.

CmsClient client = new CmsClient(logonGuid);
Project project = client.getProject(sessionKey, projectGuid);

jRQL now knows which user you are and what project you are currently use.

In this example I want to get data from page with ID 1234. The following line triggers a RQL search request to get the page GUID and encapsulate it in currentPg.

Page currentPg = project.getPageById("1234");

To access an element value of page 1234 you need to know on which content class (formerly called Template) it is based and what’s the name of the template element is. Template element names are crucial for work with jRQL; whole jRQL is based on these names.

To get the value of StandardField Text column_1_header of page 1234 would read like this:

currentPg.getStandardFieldTextValue("column_1_header");

From your Java experience you can now guess how to update this value on page 1234:

currentPg.setStandardFieldTextValue("column_1_header", "new header value");

Well done! At the end the whole program for easy copying.

String logonGuid=”FFFD75C022BB41F580186D0FB63A6F27″;
String sessionKey=”DFD154CF95464902A7C3EFEF29FBF3C7″;
String projectGuid=”268F46EF5EB74A75824856D3DA1C6597″;

CmsClient client = new CmsClient(logonGuid);
Project project = client.getProject(sessionKey, projectGuid);

Page currentPg = project.getPageById(“1234”);
System.out.println(currentPg.getStandardFieldTextValue(“column_1_header”));
currentPg.setStandardFieldTextValue(“column_1_header”, “new header value”);

Similar setter and getter methods are available for these standard field types:

currentPg.getStandardFieldDateValue(“column_updated”);
currentPg.getStandardFieldNumericValue(“column_width”);
currentPg.getStandardFieldUserDefinedValue(“column_email”);

currentPg.setStandardFieldDateValue(“template element name”, new ReddotDate());
currentPg.setStandardFieldNumericValue(“template element name”, 60);
currentPg.setStandardFieldUserDefinedValue(“template element name”, “my-email@test.test”);

Check the javadoc of class Page.

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

Comments

  • Landon  On 24. November 2009 at 3:35 pm

    Very interesting. Just curious if you provide source code for the jRQL?

    • Frank  On 24. November 2009 at 4:13 pm

      Hello Landon, I developed it for Hapag-Lloyd AG, they donate jRQL (and 12 plugins for admin), but without source code so far.

      But I’m sure it’s useful even without source code – all classes offer a javadoc and are compiled with debug attributes, so all parameter variables are named.

  • Frank  On 25. November 2009 at 3:11 pm

    Hello Landon, if you’re interested in unofficial RQL commands let me know, I will publish it.

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: