阅读363 返回首页    go 阿里云 go 技术社区[云栖]


MAG中关于数组和COMBO,LIST的联合使用例子(MAGList和MAGInputList)

直接贴代码:

        MAGList list = new MAGList("MAGList例子");

		String[][] data = {
			{"水木社区", "https://www.newsmth.net", "1000", "水木", "2008-05-14"},
			{"京东商城", "https://www.360buy.com", "5000", "京东", "2009-04-14"},
			{"北京缓解拥堵网", "https://www.bjhjyd.gov.cn", "10", "北京市政府", "2010-12-14"},
			{"百度贴吧", "https://tieba.baidu.com", "8000", "白度", "2009-05-14"},
			{"新浪新闻", "https://news.sina.com.cn", "2000", "新浪", "2010-06-23"},
			{"新浪汽车", "https://audo.sina.com.cn", "1200", "新浪", "2011-06-21"},
			{"新浪房产", "https://house.sina.com.cn", "1800", "新浪", "2011-06-23"},
			{"新浪科技", "https://tech.sina.com.cn", "1400", "新浪", "2011-05-23"},
			{"新浪财经", "https://finance.sina.com.cn", "1300", "新浪", "2011-04-23"},
			{"新浪读书", "https://book.sina.com.cn", "800", "新浪", "2010-04-23"},
			{"百度新闻", "https://news.baidu.com", "6000", "白度", "2011-07-08"},
			{"百度知道", "https://zhidao.baidu.com", "4500", "白度", "2011-01-11"},
			{"百度MP3", "https://mp3.baidu.com", "7700", "白度", "2011-03-28"},
			{"百度图片", "https://image.baidu.com", "9800", "白度", "2011-02-09"},
			{"百度视频", "https://video.baidu.com", "2300", "白度", "2011-02-11"},
			{"百度地图", "https://map.baidu.com", "2200", "百度", "2011-03-31"},
		};

		for (String[] d:data) 
		{
			MAGCombo combo = new MAGCombo("");
			combo.setClass("combo_style");
			MAGLink link = new MAGLink(d[0], new MAGLinkURL(d[1]).setExpireHours(0), MAGLinkTarget.LINK_TARGET_BROWSER, "link");
			link.setClass("link_style");
			combo.addChild(link);

			MAGText text = new MAGText("访问量:", d[2], "text");
			text.setClass("text_style");
			combo.addChild(text);

			MAGNote note = new MAGNote(d[3], d[4], "note");
			combo.addChild(note);
			list.addChild(combo);
		}
		
		MAGListOrderFieldSet order_fields = list.new MAGListOrderFieldSet();
		order_fields.addField("链接文字", "link._title", MAGListOrderFieldType.FIELD_TYPE_STRING);
		order_fields.addField("访问量", "text._text", MAGListOrderFieldType.FIELD_TYPE_NUMBER);
		order_fields.addField("类别", "note._title", MAGListOrderFieldType.FIELD_TYPE_STRING);
		order_fields.addField("日期", "note._note", MAGListOrderFieldType.FIELD_TYPE_STRING);	

		//list.setOrderBy(order_fields);
		list.setItemsPerPage(3);
		
		int items_per_page = 3;
		double pages = (double)data.length/items_per_page;
		if(pages != (int)(pages)) 
		{
			pages = (int)(pages)+1;
		}
		list.setFooter("共" + (int)pages + "页");
		list.setDescending(true);
		doc.addChild(list);
		
		
		MAGPanel panel = new MAGPanel("MAGInputList示例");
		
		MAGInputList input_list = new MAGInputList("网站列表", "_input_list", null);

		for (int i = 0; i<(data.length-1); i++) 
		{
			MAGCombo combo = new MAGCombo("item_"+i);
			combo.setClass("combo_style");
			MAGLink link = new MAGLink(data[i][0], new MAGLinkURL(data[i][1]).setExpireHours(0), MAGLinkTarget.LINK_TARGET_BROWSER, "link");
			link.setClass("link_style");
			combo.addChild(link);

			MAGText text = new MAGText("访问量:", data[i][2], "text");
			text.setClass("text_style");
			combo.addChild(text);

			MAGNote note = new MAGNote(data[i][3], data[i][4], "note");
			combo.addChild(note);
			
			input_list.addChild(combo);
		}
		
		input_list.setOrderBy(order_fields);
		input_list.setDescending(true);
		
		input_list.setItemsPerPage(items_per_page);
		input_list.setFooter("共" + (int)pages + "页");
		input_list.setDescending(true);
		panel.addChild(input_list);


最后更新:2017-04-02 16:47:50

  上一篇:go 友元类
  下一篇:go 如何从程序员转型为项目经理