Examples
In this example the Any component is use to generate XML order list document.
<?xml version="1.0" encoding="ISO-8859-1" ?>
<order-list>
<order-item id="91307" order-id="2137" cust-id="94" order-date="2002-04-13" desc="AWB-TS 4.5mm"/>
<order-item id="91308" order-id="2137" cust-id="94" order-date="2002-04-13" desc="TGM-M2 30mm"/>
<order-item id="92571" order-id="3846" cust-id="94" order-date="2002-05-09" desc="AWB-TS 4.5mm"/>
<order-item id="92572" order-id="3846" cust-id="94" order-date="2002-05-09" desc="P6-AA Series 2"/>
<order-item id="92573" order-id="3846" cust-id="94" order-date="2002-05-09" desc="AWB-TS 10mm"/>
</order-list>
|
<?xml version="1.0" encoding="ISO-8859-1" ?>
<order-list>
<span jwcid="@Foreach" source="ognl:orderItemList" value="ognl:orderItem">
<order-item jwcid="orderItem">
</order-item>
</span>
</order-list>
<property-specification name="orderItemList" type="java.util.List"/> <property-specification name="orderItem" type="com.dsconsulting.order.model.OrderItem"/>
<component id="orderItem" type="Any">
<binding name="id" expression="orderItem.id"/>
<binding name="order-id" expression="orderItem.orderId"/>
<binding name="cust-id" expression="orderItem.customerId"/>
<binding name="order-date" expression="orderItem.orderDate"/>
<binding name="desc" expression="orderItem.description"/>
</component>
public abstract class OrderItemsXML extends BasePage {
public abstract List getOrderItemList();
public abstract void setOrderItemList(List value);
}
public class OrderItem {
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
private Integer id;
private Integer orderId;
private Integer customerId;
private Date orderDate;
private String description;
public OrderItem(Integer id, Integer orderId, Integer customerId,
Date orderdDate, String description) {
this.id = id;
this.orderId = orderId;
this.customerId = customerId;
this.orderDate = orderDate;
this.description = description;
}
public Integer getId() { return id; }
public Integer getOrderId() { return orderId; }
public Integer getCustomerId() { return customerId; }
public String getOrderDate() { return DATE_FORMAT.format(orderDate); }
public String getDescription() { return description; }
}
|