鉴于我们无法创建一个annoations层次结构, why-is-not-possible-to-extend-annotations-in-java
如何对一个对象数组进行decalare以存储不同注释的有序列表
public @interface View {
Object[] elements();
//Invalid type Object[] for the annotation attribute View.elements; only
primitive type, String, Class, annotation, enumeration are permitted
or 1-dimensional arrays thereof
}
Elements could be @Field, @Tab, @Listing .... but i need to know the order
需要的是我有一个像这样的xml层次结构树
<view id="StkEntranceVoucher" name="StkEntranceVoucher" >
<listingHeader />
<listing >
<ref mode="vp" target="titleText"/>
<ref mode="vp" target="voucherNumber"/>
</listing>
<panel>
<tab>
<tab>
<panel>
<field name="title" />
</panel>
<field name="titleText" />
<field name="voucherNumber">
</tab>
</tab>
</panel>
</view>
我希望能够在模型上使用anotation配置生成此XML配置: 我已经能够做到这一点
@View(queryFilter=@QueryFilter(orderBy="(?).id.num"), detailSize="580px",
listingHeader=@ListingHeader(actions="printAll"),
listing={ "id.num", "reference", "onDate", "fromSection", "supplier",
"totalField", "buyOrder.id.num", "buyOrder.onDate", "receiptVcr.id.num", "receiptVcr.onDate",
"prdExitOrd.id.num", "prdExitOrd.onDate", "invExtract.id.num", "invExtract.onDate" },
tabs={
@Tab(name="GeneralTab",
SubTabs={
@SubTab( name="HeaderTab",
style =@Style(type=StlType.print, colWidths={"50", "400"}, width="450", marginB=2, marginT=8 ),
fields={
@Field(name="titleText", mode="p", valueExpr="#{bean.mapID( wcx,'reportTitle')}", expectedType=String.class,
style=@Style(type=StlType.print, align="center", bold=true, fontSize=16, marginT=20, paddingB=4, paddingL=4, paddingR=4, paddingT=4, textAlign="center", width="200")),
@Field(name="voucherNumberText", mode="p", valueExpr="#{bean.mapID( wcx,'VoucherNum')} : #{(?).id.num} #{bean.mapID( wcx,'VoucherOf')} #{util.format((?).onDate, 'dd/MM/yyyy')}", expectedType=String.class,
style=@Style(type=StlType.print, align="center", fontSize=10, textAlign="center" )),
@Field(name="id.sgSr", mode="", queryFilter=true),
@Field(name="id.num", width="60px", mode="v"),
@Field(name="reference"),
@Field(name="onDate", mode="v"),
@Field(name="fromSection"),
@Field(name="supplier") }
),
@SubTab( name="ItemsTab", subView=
@SubView( name="StkEntranceVoucherItem", entityType=StkInputVoucherItem.class, editable=true,
listingFields={
@Field(name="id.vcr", mode="", queryFilter=true),
@Field(name="id.item", width="60px", codeLabel=true),
@Field(name="id.item.label", width="150px", mode="rvp"),
@Field(name="quantity", width="60px"),
@Field(name="id.item.measureUnit", width="50px", mode="rpv"),
@Field(name="unitPrice", width="60px"),
@Field(name="amount", width="80px", mode="rvp",
calcExpr="#{(?).quantity*(?).unitPrice}"),
@Field(name="batch", jsfCpn=JsfCpn.button, linkedViewName="StkInputVoucherBatch",
styleClass="no_padding", width="24px"),
@Field(name="comment", width="100px") }) ),
@SubTab( name="StkEntranceVoucherTotalTab", style=@Style(css="float:right;"),
fields={
@Field( name="totalField", ofColFooter="amount", mode="rvp",
valueExpr="(?).amount", expectedType=Double.class,
calcExpr="#{(?)==bean.record?bean.sum(':amount'):(?).amount}") })
})
})
但它的语法不完全相同,因为我在这里使用了一个@Tab数组和一个@Field数组,但我不能有一个不同注释的数组