Grid
public class DhtmlxGridRow {
Object id;
Object data;
public Object getId() {
return id;
}
public void setId(Object id) {
this.id = id;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
}
import java.util.ArrayList;
import java.util.List;
public class DhtmlxGridTable {
List<DhtmlxGridRow> rows;
int total_count;
int pos;
public int getPos() {
return pos;
}
public void setPos(int pos) {
this.pos = pos;
}
public int getTotal_count() {
return total_count;
}
public void setTotal_count(int total_count) {
this.total_count = total_count;
}
public List<DhtmlxGridRow> getRows() {
if(rows ==null){
rows = new ArrayList<DhtmlxGridRow>();
}
return rows;
}
public void setRows(List<DhtmlxGridRow> rows) {
this.rows = rows;
}
}
Tree
import java.io.Serializable;
import java.util.List;
/**
* @Description:DhtmlxTree节点类
*
*
* @Version: 1.0
*
*/
public class DhtmlxTreeItem implements Serializable {
/**
* 2011-8-2
*/
private static final long serialVersionUID = 1L;
public static Long ROOTID = 0L;// 要求树的根的id为0
public static final String[] INCLUDE_SIMPLE = { "id", "text", "item" };
public static final String[] INCLUDE_CHECKED = { "id", "text", "item",
"checked" };
public static final String[] INCLUDE_OPEN = { "id", "text", "item", "open" };
public static final String[] INCLUDE_OPEN_CHECKED = { "id", "text", "item",
"open", "checked" };
public static final String[] INCLUDE_ALL = { "id", "text", "item", "open",
"checked", "child", "im0", "im1", "im2", "aCol", "sCol", "style",
"select", "call", "tooltip", "nocheckbox", "radio", "imheight",
"imwidth", "topoffset" };
private String id;// id of the node
private String text;// label of the node
private String im0;// image for a node without child items (tree will get
// images from the path specified in setImagePath()
// method)
private String im1;// image for an expanded node with child items
private String im2;// image for a collapsed node with child items
private String aCol;// colour of an item that is not selected
private String sCol;// colour of a selected item
private String style;// text style of a node
private String open;// show a node opened (any value)
private String select;// select a node on load (any value)
private String call;// call function on select(any value)
private String tooltip;// tooltip of the node
private String checked;// check checkbox if exists (in case of 3-state
// checkboxes values can be 1 - checked or -1 -
// unsure)
private String nocheckbox;// instruct component, to not render checkbox for
// related item, optional
private String child;// specifies whether a node has child items (1) or not
// (0)
private String radio;// if not empty, child items of this node will have
// radio buttons
private int imheight;// height of the icon
private int imwidth;// width of the icon
private int topoffset;// offset of the item from the node above
private List<DhtmlxTreeItem> item;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getIm0() {
return im0;
}
public void setIm0(String im0) {
this.im0 = im0;
}
public String getIm1() {
return im1;
}
public void setIm1(String im1) {
this.im1 = im1;
}
public String getIm2() {
return im2;
}
public void setIm2(String im2) {
this.im2 = im2;
}
public List<DhtmlxTreeItem> getItem() {
return item;
}
public void setItem(List<DhtmlxTreeItem> item) {
this.item = item;
}
public String getOpen() {
return open;
}
public void setOpen(String open) {
this.open = open;
}
public String getSelect() {
return select;
}
public void setSelect(String select) {
this.select = select;
}
public String getCall() {
return call;
}
public void setCall(String call) {
this.call = call;
}
public String getTooltip() {
return tooltip;
}
public void setTooltip(String tooltip) {
this.tooltip = tooltip;
}
public String getaCol() {
return aCol;
}
public void setaCol(String aCol) {
this.aCol = aCol;
}
public String getsCol() {
return sCol;
}
public void setsCol(String sCol) {
this.sCol = sCol;
}
public String getStyle() {
return style;
}
public void setStyle(String style) {
this.style = style;
}
public String getChecked() {
return checked;
}
public void setChecked(String checked) {
this.checked = checked;
}
public String getNocheckbox() {
return nocheckbox;
}
public void setNocheckbox(String nocheckbox) {
this.nocheckbox = nocheckbox;
}
public String getChild() {
return child;
}
public void setChild(String child) {
this.child = child;
}
public String getRadio() {
return radio;
}
public void setRadio(String radio) {
this.radio = radio;
}
public int getImheight() {
return imheight;
}
public void setImheight(int imheight) {
this.imheight = imheight;
}
public int getImwidth() {
return imwidth;
}
public void setImwidth(int imwidth) {
this.imwidth = imwidth;
}
public int getTopoffset() {
return topoffset;
}
public void setTopoffset(int topoffset) {
this.topoffset = topoffset;
}
}
import java.util.ArrayList;
import java.util.List;
public class DhtmlxTreeGridRow {
Object id;
Object data;
String xmlkids;
List<DhtmlxTreeGridRow> rows;
public Object getId() {
return id;
}
public void setId(Object id) {
this.id = id;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
public List<DhtmlxTreeGridRow> getRows() {
if(rows==null){
rows = new ArrayList<DhtmlxTreeGridRow>();
}
return rows;
}
public void setRows(List<DhtmlxTreeGridRow> rows) {
this.rows = rows;
}
public String getXmlkids() {
return xmlkids;
}
public void setXmlkids(String xmlkids) {
this.xmlkids = xmlkids;
}
}
import java.util.ArrayList;
import java.util.List;
public class DhtmlxTreeGridTable {
int total_count;
int pos;
List<DhtmlxTreeGridRow> rows;
public int getTotal_count() {
return total_count;
}
public void setTotal_count(int total_count) {
this.total_count = total_count;
}
public int getPos() {
return pos;
}
public void setPos(int pos) {
this.pos = pos;
}
public List<DhtmlxTreeGridRow> getRows() {
if(rows==null){
rows = new ArrayList<DhtmlxTreeGridRow>();
}
return rows;
}
public void setRows(List<DhtmlxTreeGridRow> rows) {
this.rows = rows;
}
}
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
import org.apache.commons.lang.StringUtils;
import com.mogenesis.mobileadplatform.web.util.ArrayUtil;
/**
*
* @Description: dhtmxTree JSON输出构建类,使用方法见
*
*
* @Date: 2011-8-3 下午10:57:19
* @Version: 1.0
*
*/
public class DhtmlxTreeBuilder {
/**
* 递归构建json字符串
*
* @param <T>
* @param root
* @param cb
* @return
*/
public static <T> String buildRecursiveJson(T root,
DhtmlxTreeBuildCallback<T> cb) {
DhtmlxTreeItem d = buildRecursive(root, cb);
if (d == null) {
return "{}";
}
String[] includeProperties = cb.includeProperties();
String[] excludeProperties = cb.excludeProperties();
Set<String> includes = null;
if ((includeProperties != null) && (includeProperties.length > 0)) {
includes = new TreeSet<String>();
for (String property : includeProperties) {
if (StringUtils.isNotEmpty(property)) {
includes.add(property);
}
}
if (includes.size() == 0)
includes = null;
}
Set<String> excludes = null;
if ((excludeProperties != null) && (excludeProperties.length > 0)) {
excludes = new TreeSet<String>();
for (String property : excludeProperties) {
if (StringUtils.isNotEmpty(property)) {
excludes.add(property);
}
}
if (excludes.size() == 0) {
excludes = null;
}
}
JsonConfig config = null;
if ((excludes == null) && (includes == null)) {
return JSONObject.fromObject(d).toString();
}
Set<String> ex;
if (includes != null) {
ex = new HashSet<String>();
for (String s : DhtmlxTreeItem.INCLUDE_ALL) {
if (!(includes.contains(s)))
ex.add(s);
}
if (ex.size() > 0) {
config = new JsonConfig();
config.setExcludes((String[]) ArrayUtil.toArray(ex));
}
}
if (excludes != null) {
config = new JsonConfig();
config.setExcludes((String[]) ArrayUtil.toArray(excludes));
}
if ((excludes != null) && (includes != null)) {
ex = new HashSet<String>();
for (String s : DhtmlxTreeItem.INCLUDE_ALL) {
if (excludes.contains(s))
ex.add(s);
else if (!(includes.contains(s)))
ex.add(s);
}
if (ex.size() > 0) {
config = new JsonConfig();
config.setExcludes((String[]) ArrayUtil.toArray(ex));
}
}
return ((String) JSONObject.fromObject(d, config).toString());
}
public static <T> DhtmlxTreeItem buildRecursive(T root,
DhtmlxTreeBuildCallback<T> cb) {
if ((root == null) || (cb == null)) {
return null;
}
DhtmlxTreeItem dRoot = cb.getDhtmlxTreeItem(root);
if (dRoot != null)
buildRecursiveJson(root, dRoot, cb);
return dRoot;
}
private static <T> void buildRecursiveJson(T t, DhtmlxTreeItem dT,
DhtmlxTreeBuildCallback<T> cb) {
T[] nodes = cb.getChildren(t);
if ((nodes == null) || (nodes.length == 0))
return;
List<DhtmlxTreeItem> children = dT.getItem();
if (children == null) {
children = new ArrayList<DhtmlxTreeItem>();
dT.setItem(children);
}
for (int i = 0; i < nodes.length; ++i) {
T node = nodes[i];
if (node == null) {
continue;
}
DhtmlxTreeItem o = cb.getDhtmlxTreeItem(node);
buildRecursiveJson(node, o, cb);
children.add(o);
}
}
}
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import org.codehaus.jackson.JsonFactory;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.map.annotate.JsonSerialize;
public class PojoMapper {
private static final ObjectMapper objectMapper = new ObjectMapper();
private static final JsonFactory jsonFactory = new JsonFactory();
private static final String JSON_DATE_FROMATE = "yyyy-MM-dd HH:mm:ss";
static{
SimpleDateFormat dateFormate = new SimpleDateFormat(JSON_DATE_FROMATE);
objectMapper.getSerializationConfig().setSerializationInclusion(JsonSerialize.Inclusion.NON_NULL);
objectMapper.getSerializationConfig().setDateFormat(dateFormate);//the withDateFormate method can not effect
objectMapper.getDeserializationConfig().setDateFormat(dateFormate);
objectMapper.getSerializationConfig().set(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, true);
}
/**
* deserializea a json string to an object
*
* @param <T>
* @param jsonAsString
* @param pojoClass
* @return
* @throws Exception
*/
public static <T> T fromJson(String jsonAsString, Class<T> pojoClass)
throws Exception {
return (T)objectMapper.readValue(jsonAsString, pojoClass);
}
/**
* serializea an object to a json string
* @param pojo
* @param prettyPrint if true,enabling pretty-printing using the default pretty printer
* @return
* @throws Exception
*/
public static String toJson(Object pojo, boolean prettyPrint)
throws Exception {
StringWriter sw = new StringWriter();
JsonGenerator jg = jsonFactory.createJsonGenerator(sw);
if (prettyPrint) {
jg.useDefaultPrettyPrinter();
}
objectMapper.writeValue(jg, pojo);
return sw.toString();
}
public static String toJson(Object pojo) throws Exception{
return toJson(pojo, false);
}
}
分享到:
相关推荐
dhtmlxGantt 甘特图组件使用指南 dhtmlxGantt 是一个 JavaScript 组件,能够创建动态的甘特图和以便利的图形化方式查看项目计划。它能够展示各个活动之间的依赖关系,显示当前计划的状态,以完成百分比阴影的方式...
**dhtmlx中文手册+dhtmlx.js+dhtmlx.css** dhtmlx是一个强大的JavaScript库,用于构建富客户端Web应用程序。这个压缩包包含了dhtmlx的核心组件:`dhtmlx.css`,`dhtmlx.js`,以及一份中文操作手册——`dhtmlx中文...
dhtmlx API dhtmlx 帮助文档dhtmlx API dhtmlx 帮助文档dhtmlx API dhtmlx 帮助文档dhtmlx API dhtmlx 帮助文档dhtmlx API dhtmlx 帮助文档dhtmlx API dhtmlx 帮助文档dhtmlx API dhtmlx 帮助文档
dhtmlxGantt是一款强大的JavaScript库,用于在Web应用程序中创建功能丰富的甘特图。它提供了灵活的项目管理和任务调度工具,适用于各种业务场景。这个压缩包“dhtmlxGantt.rar”包含了dhtmlxGantt的最新版本,以及...
DHTMLX是一个强大的JavaScript库,专门用于构建富客户端Web应用程序。这个免费版的全套DHTMLX包含了一系列的UI组件,可以帮助开发者快速创建交互式的、功能丰富的网页应用。DHTMLX的核心在于其轻量级、高性能和灵活...
根据提供的文件信息,我们可以从《DHTMLX中文使用手册》这一资源中提炼出与DHTMLX相关的多个知识点。下面将详细介绍这些知识点。 ### DHTMLX简介 DHTMLX 是一个全面且功能强大的JavaScript库,旨在帮助开发者快速...
DHTMLX是一个强大的JavaScript库,它提供了一系列组件,用于构建高度交互式的Web应用程序。这个库以其丰富的用户界面元素和功能而闻名,包括树形控件、数据网格、日历以及可编辑、可拖拽和可排序的表格。下面将详细...
### DHTMLX中文API开发手册知识点概述 #### 1. DHTMLX介绍 DHTMLX是一个用于快速开发Web应用的JavaScript库集合,它包括多个组件,如日历、组合框、编辑器、布局管理器、菜单等。DHTMLX旨在提供丰富的用户界面元素...
dhtmlxGrid是一款功能强大的JavaScript数据网格组件,用于在Web应用程序中展示和操作表格数据。它提供了丰富的功能,包括排序、过滤、分页、编辑、拖放等,以满足专业级的数据管理需求。这款组件是dhtmlx Suite的一...
**dhtmlx** 是一个强大的Web用户界面库,专为构建富互联网应用程序(RIA)而设计。这个库提供了丰富的组件集合,包括表格、树、菜单、日历、对话框等,使得开发者能够创建功能丰富、交互性强的网页应用。dhtmlx支持...
Dhtmlx是一款强大的JavaScript库,专门用于构建富客户端应用程序,特别是那些需要动态、交互式用户界面的项目。在这个“Dhtmlx日程-图表-甘特图实例”中,我们将会探讨如何使用Dhtmlx Suite来创建高效的时间管理和...
**dhtmlx套件 V2.0:一个全面的前端Web开发工具** dhtmlx套件是一款功能强大的JavaScript库,专为构建富交互式的Web应用程序而设计。它提供了丰富的组件集合,包括表格、日历、树形视图、图表等多种元素,能够帮助...
**dhtmlxGantt_v4.0.0:深度解析甘特图库的资源与应用** **一、dhtmlxGantt简介** dhtmlxGantt是一款强大的JavaScript库,专门用于创建交互式的甘特图。它允许用户在网页上直观地展示项目计划,包括任务、依赖关系...
DHTMLX和EXT是两种流行的JavaScript库,常用于构建富客户端Web应用程序。它们提供了丰富的用户界面组件和交互性,能够创建动态、响应式的网页应用。 DHTMLX是一个全面的JavaScript和HTML5 UI库,它包括各种组件,如...
《深入解析dhtmlx Pro 3.6:构建动态Web应用的专业工具》 dhtmlx Pro 3.6是一款强大的JavaScript库,专为构建交互式、动态的Web应用程序而设计。这个版本被誉为“绝对的Pro版本”,包含了dhtmlx系列的全部组件,如...
**dhtmlx4.5.1pro** 是一个专业版的Web应用程序开发框架,主要用于构建交互式的、富客户端用户界面。这个版本是dhtmlx库的4.5.1更新,提供了一系列强大的JavaScript组件,帮助开发者创建高效且具有高度定制性的网页...
1. **dhtmlxgrid.css**:这是dhtmlxGrid的样式表文件,包含了表格的各种样式定义,如单元格、行、列的样式,以及可编辑状态下的样式等。自定义这些样式可以改变表格的视觉效果。 2. **License_GPL.html**:该文件...
grid.setImagePath("assets/dhtmlx/imgs/"); grid.setHeader("姓名,性别"); grid.setEditable(false); grid.init(); grid.enablePaging(true, 10, 3, "pagingArea"); grid.setPagingSkin("toolbar"); ...