Use of FormFragment with Radio buttons


The FormFragment is a very useful component which can help us in checkout forms on e-commerce store pages. You can find a checkbox example on the official Tapestry website. Here, I show an example with radio buttons.


Let's imagine that you have a form which requires different fields depending on the user type who is handling it: a particular or a company.


FormFragment, TriggerFragment

Source codes

package es.carlosmontero.webapp.t5devutil.pages.components;

import org.apache.tapestry5.annotations.Property;

public class FormFragmentPage {

   public static enum TYPE {

   private TYPE type;

   private String userName, companyName, companyIdNumber;

   public void setupRender() {

      type = TYPE.PERSON;

   public TYPE getPerson() {
      return TYPE.PERSON;

   public TYPE getCompany() {
      return TYPE.COMPANY;

   public boolean isVisiblePerson() {
      return TYPE.PERSON.equals(type);