Editing texts

Text elements in RedDot CMS can be either of type ASCII or HTML. jRQL supports both with the following methods.

Let us start with some basic check methods if a value is entered by an user or the text element did not have a value. jRQL always returns the default value from the content class element automatically, if available.

String logonGuid="6EB1C39F6A584ABBB9DBB6D36E27FAD7";
String sessionKey="36E1E61495654EB8A4505AC604925FCA";
String projectGuid="73671509FA5C43ED8FC4171AD0298AD2";

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

Page currentPg = project.getPageById(“4711”);
boolean textEmpty = currentPg.isTextEmpty(“templateElementName”);
boolean textValueEntered = currentPg.isTextValueEntered(“templateElementName”);

Method isEmpty() returns true, if there is no default value in content class element and text element on page is not filled. Method isTextValueEntered() returns true, if the text element on the page currently has a text, regardless from where it comes – from the page element or the content class element’s default value.

String textValue = currentPg.getTextValue("templateElementName");
currentPg.setTextValue("templateElementName", "htmlSourceCode");
currentPg.enterText("templateElementName", "text editor input");
currentPg.deleteTextValue("templateElementName");

You can get and set the value of text elements. If it is an HTML text element, than you get and shcould set the HTML source code. For an ASCII text element the unchanged value (as entered) will be returned. Especially on an HTML text element the method enterText() would be of interest. It will encode the given text automatically to handle for instance < and > in same way as you would enter the text into the RedDot’s text editor. (For ASCII text elements it will not harm.)

As for all element types you can get the page element from the page to access additional methods. I want to show you this style here to find out what kind of text element it is.

TextElement textElement = currentPg.getTextElement("templateElementName");
textElement.isAsciiText();
textElement.isHtmlText();

There is support for copying text values from one page to another with several copyText* methods. For further details, please refer to the javadoc of class Page and TextElement.

Post a comment or leave a trackback: Trackback URL.

Leave a comment