数据源

    对于下拉列表、下拉多选框、单选框和多选框等,它们需要选择项列表。用于提供选择项列表的称为数据源,数据源设置一般有下面几种方法。

1.value子节点

    如:

<?xml version='1.0' encoding='utf-8'?>

<attribute name="sex" descriptors="xworker.lang.MetaDescriptor3/@attribute" inputtype="select">
    <value name="male" value="male"/>
    <value name="female" value="female"/>
</attribute>

2.重写List<Thing> getValues()方法

     如:

<?xml version='1.0' encoding='utf-8'?>

<attribute name="job" descriptors="xworker.lang.MetaDescriptor3/@attribute" inputtype="select">
    <actions>
        <GroovyAction name="getValues" descriptors="xworker.groovy.GroovyAction">
            <code><![CDATA[import org.xmeta.Thing;

def values = [];

def male = new Thing();
male.put("name", "Male");
male.put("value", "male");
values.add(male);

def female = new Thing();
female.put("name", "Female");
female.put("value", "female");
values.add(female);

return values;]]></code>
        </GroovyAction>
    </actions>
</attribute>

3.数据对象

    数据对象是一个二维表格数据的框架,是存储和界面的桥梁。通过数据对象可以实现数据的CURD操作,也可以很容易的映射到界面上。

3.1.设置数据对象为数据源

    如:

<?xml version='1.0' encoding='utf-8'?>

<attribute name="fontName" descriptors="xworker.lang.MetaDescriptor3/@attribute" inputtype="select"
     relationDataObject="xworker.things.p2018.p02.p22.FontNames" relationValueField="name"
     relationLabelField="name"/>、

3.2.设置数据仓库为数据源

    如:

<?xml version='1.0' encoding='utf-8'?>

<attribute name="fontName" descriptors="xworker.lang.MetaDescriptor3/@attribute" inputtype="select"
     dataStore="xworker.things.p2018.p02.p22.FontNameStore"/>

Copyright ©  2007-2019 XWorker.org  版权所有  沪ICP备08000575号