Clone wiki

AspectFaces / 7.6.Multiple-instances

Sometimes you need to produce form from multiple instances of different classes. For such case you need to consider how to transform it. There are two possible ways, with collate true and collating false (default). The collate is in the AF Context and defines how to process fields (a1,a2,a3,b1,b2,b3 versus a1,b1,a2,b2,a3,b3).

Example classes to process

public class Address {

 public String getAddressLine1() { return addressLine1; }
 public String getAddressLine2() { return addressLine2; }


public class Contact {

 public String getPhone() { return phone; }
 public String getSkype() { return skype; }


For JSF OnDemand you need to set collate option in JSF Handler, as is explained in 7.1. Aspect Faces Context.

Information passing to the context through the JSFHandler

public class CustomHandler extends DefaultAFGeneratorHandler {

  protected final TagAttribute collate;

  public CustomHandler(ComponentConfig config, int afCacheTime) {
    super(config, afCacheTime);
    this.collate = this.getAttribute("collate");

  protected void hookAddToAFContext(Context context) { 
    if (collate != null) Boolean.parseBoolean(collate.getValue());
    else afContext.setCollate(false); 

And use in the JSF

Generate view via Aspect Faces

<!-- Dual Form generated via AspectFaces -->
<af:ui instance="#{bean.instance.address},#{}" collate="true" edit="true"/>