当前位置: 代码迷 >> Web前端 >> SmartGwt 上拉列表
  详细解决方案

SmartGwt 上拉列表

热度:543   发布时间:2012-10-06 17:34:01.0
SmartGwt 下拉列表

下列代码实现的是 一个下拉列表的功能:

?

package com.tservice.PGA.smApp.client.Meeting;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.smartgwt.client.data.fields.DataSourceEnumField;
import com.smartgwt.client.data.fields.DataSourceTextField;
import com.smartgwt.client.widgets.form.fields.SelectItem;
import com.tservice.PGA.smApp.client.service.SmService;
import com.tservice.PGA.smApp.client.service.SmServiceAsync;

public class publicUserStringArrayList {
	SmServiceAsync mainService = (SmServiceAsync) GWT.create(SmService.class);
	ServiceDefTarget endpoint = (ServiceDefTarget) mainService;
	String moduleBaseURL = GWT.getModuleBaseURL()+"rpc";
	
	DataSourceTextField peopleText=null;
	SelectItem select=null;
	public publicUserStringArrayList(String titleId,String name){
		endpoint.setServiceEntryPoint(moduleBaseURL);
		//"people","参与者"
		 peopleText=new DataSourceTextField(titleId,name,10);
		 select=new SelectItem(titleId,name);
			mainService.getUserLists(new AsyncCallback(){
				public void onFailure(Throwable caught) {
					
				}
				public void onSuccess(Object result) {
					String[] str=(String[])result;
					select.setValueMap(str);
				}
				
			});
		
}
}
?

?

其他前端页面调用:

?

final publicUserStringArrayList userList=new publicUserStringArrayList("people","参与者");

?

DynamicForm form=new DynamicForm();
		form.setUseAllDataSourceFields(true);//只有这样才能让DataSource控件与常规控件(SelectItem)同事显示 
		form.setDataSource(dataSource);
		form.setFields(userList.select); 

?

DataSource dataSource=new DataSource();
dataSource.setClientOnly(true);
?

参考:

http://dragon0929.iteye.com/blog/611864#comments

?

?