In this post we will demonstrate OFBiz Content Management System usage for front end application static pages through simple content data setup and using it in a screen. This gives clients the flexibility to change the text to be shown on a static page when ever they want, without asking for any code change.
Take the example of an OFBiz e-commerce storefront web site. Often times, clients will wish to include “static” pages like About Us, FAQ, and so on. We want to empower the client to update this copy him/herself, without needing to request help from a programmer. The following example gives us a simple look at how that is done.
All the details given here are supported by the out-of-the-box (OOTB) OFBiz CMS implementation.
In this exercise we will:
- see the basic concept of DataResource and Content record.
- setup content data to embed FTL markup.
- setup a content driven screen and use it show the static content setup in data.
• Assumption: a component is already setup; here we using the name “cmsdemo” for component.
DataResource and Content records
Let’s suppose that we want to define content (that we will include in a screen) for the text “This is the text that will appear on screen.”.
First of all we have to define a DataResource representing this text. This gives you greater flexibility because you can store long texts in the textData field. If you want to embed FTL markup (directives etc…) that needs to be processed before the rendering you can achieve this using the dataTemplateTypeId attribute, in this way all the Freemarker instructions in the text will be executed before rendering the screen. Following data needs to be setup in a data file:
1 2 3 4 5 6 7 8 | </p> <DataResource dataResourceId="DS_EXAMPLE" dataResourceTypeId="ELECTRONIC_TEXT" dataTemplateTypeId="FTL"/> <ElectronicText dataResourceId="DS_EXAMPLE"> <textData><![CDATA[ <h1>CMS DEMO</h1> <h2>This is the text that will appear on screen.</h2> ]]></textData> </ElectronicText> |
Now we have to create a Content record that is associated to the DataResource. No matter what type of data resource you have choosen, the Content record is the same like:
1 | <Content contentId="CN_EXAMPLE" contentTypeId="DOCUMENT" contentName="Content 01" dataResourceId="DS_EXAMPLE"/> |
Using the element in a screen definition.
Now we can easily include the content directly inside the
1 2 3 4 5 6 7 8 9 | <screen name="main"> <section> <actions> </actions> <widgets> <content content-id="CN_EXAMPLE"/> </widgets> </section> </screen> |
Running the content driven screen
Make sure to have an entry in ofbiz-component file for the data file created for CMS date that we created earlier in the step.
1 | <entity-resource type="data" reader-name="demo" loader="main" location="data/CmsDemoDemoData.xml"/> |
or you can also load it through webtools \–> XML Data Import.
Now make sure you have main request and view defined in your controller file:
1 2 | <request-map uri="main"><security https="false" auth="false"/><response name="success" type="view" value="main"/></request-map> <view-map name="main" type="screen" page="component://cmsdemo/widget/CmsDemoScreens.xml#main"/> |
When the request [https://localhost:8443/cmsdemo/control/main] is served you will see the following page that will show up the contents that you have setup in data:

This was a very basic example of OFBiz CMS capability. We will expand on the details and demonstrate more OFBiz CMS functionality in upcoming posts. If you need help with OFBiz CMS in the mean time, contact HotWax Media today!
- Pranay
Pranay Pandey is Manager, Enterprise Software Development at HotWax Media (OFBiz Service Provider) and has been involved with the OFBiz project since 2007. He contributes actively to OFBiz, and also trains HotWax Media developers in OFBiz techniques and best practices.
Tags: cms, ofbiz cms, ofbiz content management, OFBiz Tutorial, Pranay Pandey

Hi Pranay,
Thanks for the informative articles on CMS.
Referring to your articles OFBiz Tutorial – Using CMS for Front End Application Static Pages – Part-1, and http://cwiki.apache.org/OFBIZ/ofbiz-content-management-how-to.html#OFBizContentManagementHowto-DataResource.
I have two queries, viz.
1. For content rendering in screen widget, instead of giving the CONTENT_ID directly, how can I access it using a variable, so that screen widget could be reused.
2. If I use FTL for rendering CONTENT (Electronic text in HTML) instead of the screen widget, how do I prevent HTML tags from being escaped in FTL.
Thanks
Hi Varun,
Thanks for the reading and sorry for being late in replying to your question. I have written one more tutorial on this available at: http://www.hotwaxmedia.com/apache-ofbiz-blog/ofbiz-tutorial-using-cms-for-static-web-pagesf/ Hope this helps.