Reuse a Fragment

Because a fragment is essentially a reusable piece of UI, you can use it in a page as well as in multiple pages, even other fragments.

Say you define a fragment to show an employee's contact information. You can pull in the fragment in multiple pages, where ever you want an employee's contact details to show. For example, you can use the fragment in a page that displays an employee's contact details as well as in another page where the contact details can be edited.

You can also use a fragment multiple times in the same page, typically when you provide different sets of input parameters to the same fragment. It's also possible to create pages starting with the contents of an existing fragment, essentially using the fragment as a page template.

Because fragments are defined at the application level, they can be used in any page, in any flow within the application.

  • To use a fragment in multiple pages:
    1. Open the page you want to add the fragment to.
    2. In the Page Designer, drag and drop a Fragment Container from the Components palette onto the canvas. Then in the General tab of the container's Properties pane, click Select to select an existing fragment. If the available fragments don't meet your needs, you can create a new fragment from the Select Fragment dialog.

      Tip:

      If your fragment already exists, simply locate it in the Components palette (you can enter frag to filter components or scroll down to the Fragments category), then drag and drop it directly onto the canvas.
    3. Repeat the steps to add the same fragment to another page.
  • To use a fragment multiple times on the same page:
    1. Open the page you want to add the fragment to.
    2. In the Page Designer, drag and drop the fragment from the Components palette onto the canvas.
    3. To add the fragment to another area of the page, drag it from the Components palette and drop it where you want it to display.
  • To use a fragment within a fragment:
    1. Open the fragment where you want to use another fragment.
    2. In the Fragment Designer, drag and drop a fragment from the Components palette onto the canvas.

      Alternatively, drag and drop a Fragment Container from the Components palette onto the canvas. Then in the General tab of the container's Properties pane, click Select to select an existing fragment or Create to create a new one.

      When you add a fragment to a fragment, both pieces will display on the page consuming the initial fragment. For example, if you added emergency contacts as a separate fragment within the employee's contact information, the emergency details will display on every page that pulls in the contact information fragment.