Skip to main content

Customizations

There are 2 ways to add custom code to an application:

  • Insert code in custom anchors.
  • Add a custom class to one of the ext directories.

You will be using both when implementing custom features in you application.

Custom Anchors

A custom anchor is a location in the generated code that is demarcated by 2 comments: a start and an end anchor. Custom anchor always start with anchor:custom-.

This sets them apart from other anchors, which do not contain custom and are not harvestable.

  @EJB
MessageCrudsLocal messageCrudsLocal;

// anchor:custom-variables:start
// anchor:custom-variables:end

Simply add some code between the anchors and then execute harvest. The changes you made will be stored in the source directory.

  // anchor:custom-variables:start
private int count;
// anchor:custom-variables:end

Ext Directories

Each Component Layer has an ext and a gen directory.

  • The gen directory contains all of the generated artifacts.
  • The ext directory can be used to add additional classes and other files to the project.

When harvesting, files in these directories are stored to the source directory to be returned on the next expansion.

demoApp
├── components
│ ├── space
. │ ├── control
. │ ├── gen
│ └── ext
├── data
│ ├── gen
. └── ext

Hiding non-custom Anchors

You can hide non-custom anchors in the generated code by adding the following option to your expansionSettings:

Option
hideAnchors ExpansionSettings

Hide non-custom anchors, such as anchors used by expanders and feature anchors

<options>
<hideAnchors/>
</options>