Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents
maxLevel2

 

 


...


The functions for the contentelements are separated into two categories: creating an element and deleting an element. To create an element there are several functions available that all have the same name but different in parameters.

 


Creating an Element

To create an element there is one method available with six different parameters. The method name is createAndInsertElement. It returns an Element and can have up to three parameters:

...

The following code sample shows how to add a Text element to the homepage:

 


Code Block
themeEclipse
Page homepage = mySession.getXperienCentralApplication().getWebsites()[0].getHomePage();
myElementService.createAndInsertElement(homepage, TextElement.class);

...


The following code sample shows how to add an image element at the top (position 0) of the homepage: 


Code Block
themeEclipse
Page homepage = mySession.getXperienCentralApplication().getWebsites()[0].getHomePage();
myElementService.createAndInsertElement(homepage, ImageElement.class, 0);

...


Back to Top 


...

Deleting an Element

Deleting an element is done using the method deleteElement. It returns a boolean indicating whether the delete action was successful. The method has one parameter: the element to be deleted.

For example:

 


Code Block
themeEclipse
Page homepage = mySession.getXperienCentralApplication().getWebsites()[0].getHomePage();
Element element = myElementService.createAndInsertElement(homepage, TextElement.class);
if (!myElementService.deleteElement(element)) {
	LOG.severe("Failed to delete element: " + element);
}

 

 

 

...