SmartGwt 下拉列表

本文介绍了一个使用GWT框架实现的下拉列表功能。该功能通过调用远程服务获取用户列表,并将其设置为SelectItem组件的值。此外,还介绍了如何在前端页面中配置DataSource并展示下拉列表。
下列代码实现的是 一个下拉列表的功能:
 
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);
 参考:
[url=http://dragon0929.iteye.com/blog/611864#comments]http://dragon0929.iteye.com/blog/611864#comments[/url]
 
 
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值