2. Hello, World!

When learning a new language, it is almost traditional to create a "Hello, World!" program as your first project. Let's do that too! Along the way, I will skip a few details here and there, but don't worry; I will explain them in detail in the upcoming chapters. So, let's create our first widget!

To create a widget, we need to open the Widget Editor and create a widget library first.

Opening the Widget Editor

  1. Open or create a new WEM web project.

  2. Select the "Templates, widgets, files, and hyperlinks" tab in the project tree.

  3. Right-click on "Widget libraries" to display the context menu.

  4. Click on "Open widget editor."

Creating a Widget Library

To create a widget, we first need to create a widget library:

  1. Navigate to your workspace in the widget editor tree.

  2. Right-click on your workspace to display the context menu.

  3. Click on "Create library."

  4. Let's name the library "Widget Academy."

Creating the Widget

Now let's create the widget:

  1. Right-click on "Widget Academy" to display the context menu.

  2. Click on "Create widget."

  3. Name the widget "Hello, World!"

Almost There

  1. Double-click on the newly created widget to open it.

  2. Click on the Script tab.

  3. Write the following HTML code in the code editor:

    <h2>Hello, World!</h2>
  4. Press Save.

Congratulations! You have created your first widget! But how do you see it in action? To view it, we need to add the widget library to our project. Once we do that, we can add the widget to the template in the template editor.

Adding the Widget Library to Your Project

  1. Select the "Templates, widgets, files, and hyperlinks" tab in the project tree.

  2. Right-click on "Widget libraries" to display the context menu.

  3. Click on "Add widget library."

  4. Select the "Widget Academy" library.

  5. Press OK.

Placing the Widget on a Template

Now, let's place the widget on a template:

  1. Create a new flowchart.

  2. Create a new interaction node.

  3. Drag and drop the "Custom" ribbon item (the one with the rocket) at the top of the template.

  4. Expand the "Widget Academy" library.

  5. Select the "Hello, World!" widget.

  6. Press Select.

  7. Save the template.

Now, preview this interaction node, and you will be greeted with the words:

"Hello, World!"

This widget may not be anything special. We didn't even write any WEMscript, nor did we discuss binding with the WEM data model. I skipped a lot of details. But if you’ve made it this far, then let the fun begin!

Last updated