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.
package es.carlosmontero.webapp.t5devutil.pages.components;
import org.apache.tapestry5.annotations.Property;
public class FormFragmentPage {
public static enum TYPE {
PERSON, COMPANY
};
@Property
private TYPE type;
@Property
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);
}
}