阅读:14313回复:0
使用服务装配为下拉列表组装数据
本案例是为下拉列表组装最近三周的数据,效果如下
图片:a.jpg 步骤如下: 1. 新建java类获取并组装近三周数据,代码如下: package projectTaskMng; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import com.sunsheen.jfids.system.base.composite.data.page.java.IPageDataListSource; import com.sunsheen.jfids.system.data.component.IDataComponent; import com.sunsheen.jfids.system.data.component.combo.ComboItem; public class WeekList implements IPageDataListSource{ @Override public List<?> getListData(HttpServletRequest arg0, Map<String, Object> arg1) { // TODO Auto-generated method stub List<IDataComponent> list = new ArrayList<IDataComponent>(); //获取年份 Calendar cal = Calendar.getInstance(); int year = cal.get(Calendar.YEAR); //获取当前周次 Calendar calendar = Calendar.getInstance(); calendar.setFirstDayOfWeek(Calendar.MONDAY); calendar.setTime(new Date()); System.out.println("当前周为"+calendar.get(Calendar.WEEK_OF_YEAR)); int week = calendar.get(Calendar.WEEK_OF_YEAR); //上一周 int lastWeek = week - 1; ComboItem c1 = new ComboItem(); c1.setCode(Integer.toString(year) + "-" +Integer.toString(lastWeek)); c1.setText(Integer.toString(year) + "-" +Integer.toString(lastWeek)); list.add(c1); //本周 ComboItem c2 = new ComboItem(); c2.setCode(Integer.toString(year) + "-" +Integer.toString(week)); c2.setText(Integer.toString(year) + "-" +Integer.toString(week)); list.add(c2); //下一周 int nextWeek = week + 1; ComboItem c3 = new ComboItem(); c3.setCode(Integer.toString(year) + "-" +Integer.toString(nextWeek)); c3.setText(Integer.toString(year) + "-" +Integer.toString(nextWeek)); list.add(c3); return list; } } 2. 创建服务装配文件,组装构件 图片:b.jpg 3. 在下拉列表数据源中配置服务装配 图片:c.jpg 图片:d.jpg 如果是使用“reload”构件为下拉列表加载数据源,则可通过上述方式获取服务装配调用路径 图片:e.jpg 将路径粘贴到reload构件中即可 图片:g.jpg |
|