smarGwt / Grails 上传实例_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > smarGwt / Grails 上传实例

smarGwt / Grails 上传实例

 2011/8/10 17:21:04  lucene3211  http://lucene3211.iteye.com  我要评论(0)
  • 摘要:前台代码(smargwt):<prename="code"class="datasourcedatefielduploadingpic方法">publicdatasourcetextfielddatasourcedatefielduploadingpic(stringtimeid,stringtimename){//sc.showconsole();//"file"newdatasourcevalidatefile()
  • 标签:上传 rails grails 实例
    前台代码 (smargwt):
?

<pre name="code" class="datasourcedatefielduploadingpic 方法">public datasourcetextfield datasourcedatefielduploadingpic(string timeid,string timename){ //sc.showconsole(); //"file" new datasourcevalidatefile(); textuploadfile=new  datasourcetextfield(timeid,"<nobr>"+timename+"</nobr>"); formitem=new canvasitem(timeid,"<nobr>"+timename+"</nobr>"); formitem.setwidth("200"); final dynamicform picform=new dynamicform(); picform.setencoding(encoding.multipart); canvasitem pictureshowitem=new canvasitem("pictureshowitem","照片"); pictureshowitem.setrowspan(3); final image image=new image(); image.seturl(gwt.gethostpagebaseurl()+"icons/fwsp.png"); canvas c=new canvas(); c.addchild((image)); pictureshowitem.setcanvas(c); uploaditem pictureitem =new uploaditem("file","<nobr>"+timename+"</nobr>"); submititem submitpic=new submititem("submitpic","上传照片"); picform.setitems(pictureshowitem,pictureitem,submitpic); picform.setaction(gwt.gethostpagebaseurl()+"personalinfo/upload"); final window tipwin=new window(); tipwin.settitle("上传提示窗口"); htmlpane htmlpane=new htmlpane(); htmlpane.setcontents("<iframe name=\"uploadframe2018\" class=gwt-frame style=\"width:100%; height:100%\" src=\""+gwt.gethostpagebaseurl()+"uploading.gsp\"></iframe>"); htmlpane.setsize("100%", "100%"); htmlpane.moveto(0, 20); tipwin.addchild(htmlpane); tipwin.addcloseclickhandler(new closeclickhandler() { public void oncloseclick(closeclientevent event) {               mainservice.getpicname(new asynccallback() { public void onfailure(throwable caught) { } @override public void onsuccess(object result) { strvalue=result.tostring(); image.seturl(gwt.gethostpagebaseurl()+"picture/"+result.tostring()+"?"+random.nextdouble()); tipwin.clear(); } }); } }); picform.settarget("uploadframe2018"); submitpic.addclickhandler(new clickhandler() { @override public void onclick(clickevent event) { tipwin.setsize("300","300"); tipwin.setautocenter(true); tipwin.show(); tipwin.bringtofront(); picform.submitform(); } }) ; picform.setisgroup(true); picform.setgrouptitle("上传照片"); formitem.setcanvas(picform); return textuploadfile; }</pre>?
	public dynamicform createform(){		datasource datasource=new datasource();		datasource.setclientonly(true);				datasourcevalidatefile file=new datasourcevalidatefile();		datasource.setfields(file.datasourcedatefielduploadingpic("attachment1","上传访谈文件"));				final dynamicform form=new dynamicform();		form.setusealldatasourcefields(true);		form.setdatasource(datasource);		form.setfields(file.formitem);		return form;	}
?
visitrecorddto visit=new visitrecorddto();				visit.setattachment1(form.getvalueasstring("attachment1"));
??<span style="font-family: simsun; font-size: medium;"><pre name="code" class="前端所用到的 getpicname方法"> public string getpicname(){</pre></span>
<pre name="code" class="前端所用到的 getpicname方法"> return session["stupic"]; }</pre>?后台代码 (grails+groovy):

def upload={		params.each{			println it		}				commonsmultipartfile uploadfile=params.file			if(!uploadfile.isempty()){		string ofilename=uploadfile.getoriginalfilename()		date fname=new date()		long fff=fname.gettime()		def filesavename=fff+ofilename.substring(ofilename.lastindexof("."))		def filesavepath=request.getrealpath("/")+"uploads\\"+ filesavename		println filesavepath		uploadfile.transferto(new file(filesavepath) )		session.setattribute("stupic",filesavename)		render "上传成功,请关闭提示窗口!"		}else{		}	}
?如果有不会写的 请给本人留言 谢谢
 
发表评论
用户名: 匿名