|
自定义Dataset的步骤说明,以实现dorado与自己开发的后台业务逻辑框架的无缝集成,dorado高级技术,请谨慎使用。下载: http://221.130.182.164/download?subpath=dorado$2FTECHSENIOR$2FProcessofSelfDefinitionDataset$2DBenny$2Dv10$2D20070903$2Ezip/
<!---->
自定义dorado的dataset的步骤
注意:在实做时配置文件中的My字符串都应被替换成实际的Dataset的类型名,Custom、AutoSql都属于Dataset的类型名。
1. 定义Dataset 从com.bstek.dorado.view.data.CustomDataset继承,并给新的类添加一到多个Bean属性例如: package sample;
import org.apache.commons.lang.StringUtils;
import com.bstek.dorado.utils.variant.DataType; import com.bstek.dorado.view.ViewModel; import com.bstek.dorado.view.data.CustomDataset; import com.bstek.dorado.view.data.ViewField;
public class MyDataset extends CustomDataset {
private String xmlPath;
public String getXmlPath() { return xmlPath; }
public void setXmlPath(String xmlPath) { this.xmlPath = xmlPath; }
public MyDataset(ViewModel viewModel, String id) { super(viewModel, id); }
protected void doLoad(boolean createFields, boolean loadData) throws Exception { if (createFields) { if (StringUtils.isNotEmpty(xmlPath)) { // 创建Field ViewField field; field = (ViewField) addField("field1");
field = (ViewField) addField("field2"); field.setDataType(DataType.INT);
field = (ViewField) addField("field3"); field.setDataType(DataType.BOOLEAN);
field = (ViewField) addField("field4"); field.setDataType(DataType.DATE); } } super.doLoad(createFields, loadData); }
}
2. 部署 将此Dataset打成jar包的,并将jar包复制到studio/lib中。jar包中可以有其他的class.
3. 配置Studio 编辑studio/configs/user-view-rules.xml,(如无此文件则新建) <?xml version="1.0" encoding="UTF-8"?> <rules> <rule name="Controls"> <children> <child name="Control-MarmotQuery" insertable="true" defaultNamePrefix="marmotQuery"/> </children> <palette> <item name="Control-MarmotQuery"/> </palette> </rule> <rule name="Control-DataTable" object="org.marmot.framework.dorado.MarmotDataTable" /> <rule name="Control-AutoForm" object="org.marmot.framework.dorado.MarmotAutoForm" /> <rule name="Control-MarmotQuery" text="MarmotQuery" tagName="Control" object="org.marmot.framework.dorado.MarmotQuery" nameAttribute="id" editable="true" icon="view/item.png"> <properties> <property name="type" visible="false" defaultValue="MarmotQuery"/> <property name="id" required="true"/> <property name="category" required="true"/> <property name="conditionDataset" idRef="true" editor="com.bstek.designer.impl.view.DatasetEditor"/> <property name="queryDataset" idRef="true" required="true" editor="com.bstek.designer.impl.view.DatasetEditor"/> </properties> </rule>
<rule name="Datasets" expanded="true" showDetail="false"> <children> <child name="Dataset-My" insertable="true" defaultNamePrefix="dataset"/> </children> </rule> <rule name="Dataset-My" text="CustomDataset" tagName="Dataset" object="sample.MyDataset" nameAttribute="id" editable="true" icon="view/dataset-custom.png" expanded="true" eventSet="Dataset"> <properties> <property name="id" required="true"/> <property name="listener"/> <property name="state" visible="false"/> <property name="type" visible="false" defaultValue="My"/> <property name="objectClazz" type="java.lang.String"/> </properties> <children> <child name="MasterLink" fixed="true"/> <child name="Fields-Base" fixed="true"/> <child name="Parameters" fixed="true"/> <child name="Properties" fixed="true"/> </children> <functions> <function text="Auto create fields" icon="module/list-field.png" clazz="com.bstek.designer.impl.view.DatasetListFieldFunction"/> <function text="Open Listener" icon="java/java.png" clazz="com.bstek.designer.impl.module.ShowDatasetListenerClassFunction"/> </functions> </rule> </rules>
4. 配置项目 在home新增view-datasets.xml <?xml version="1.0" encoding="UTF-8"?> <datasets> <dataset type="My" clazz="sample.MyDataset"/> </datasets> |
|