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>
<order-item id="91308" order-id="2137" cust-id="94" order-date="2002-04-13" desc="TGM-M2 30mm"></order-item>
<order-item id="92571" order-id="3846" cust-id="94" order-date="2002-05-09" desc="AWB-TS 4.5mm"></order-item>
<order-item id="92572" order-id="3846" cust-id="94" order-date="2002-05-09" desc="P6-AA Series 2"></order-item>
<order-item id="92573" order-id="3846" cust-id="94" order-date="2002-05-09" desc="AWB-TS 10mm"></order-item>
</order-list>
|
<?xml version="1.0" encoding="ISO-8859-1" ?>
<order-list>
<span jwcid="foreachOrderItem">
<span jwcid="orderItem" element="order-item">
</span>
</order-list>
<component jwcid="foreachOrderItem" type="Foreach">
<binding name="source" expression="orderItemList"/>
<binding name="value" expression="orderItem"/>
</component>
<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 class OrderItemsXML extends BasePage {
private List orderItemList;
public List getOrderItemList() { return orderItemList; }
public OrderItem getOrderItem() { return orderItem; }
public void setOrderItem(OrderItem value) {
orderItem = value;
}
public void detach() {
orderItemList = null;
orderItem = null;
super.detach();
}
}
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; }
}
|