Hi,
I am new to smartgwt, The requirement is, in client side user can select multiple files, upload the files to server and process the files according to some business logics, if file contents some business errors then user must be view an error message in the panel. basically i completed the major parts of this,
i used
for file selecting purpose, added some form elements into
, finally i called
. The problem is, I cant get any response from the server.
how do i complete that?
I go through saveData() and submit() methods which has
mechanisms. the problem of that is, I cant get the file object in server side
I have attached my code segements, any of help highly appreciated.
how should i send a response to client ?
or
if you provide an example for submit(callback) or saveData(callback) with file attachment, also can be helpfull to me
thanks in advance.
I am new to smartgwt, The requirement is, in client side user can select multiple files, upload the files to server and process the files according to some business logics, if file contents some business errors then user must be view an error message in the panel. basically i completed the major parts of this,
i used
Code:
UploadItem
Code:
DynamicForm()
Code:
submitForm()
how do i complete that?
I go through saveData() and submit() methods which has
Code:
DSCallBack
I have attached my code segements, any of help highly appreciated.
My form
Code:
DataSource dataSource = DS.[I]getInstance[/I](); [B] final [/B]DynamicForm uploadForm = [B]new [/B]DynamicForm(); uploadForm.setDataSource(dataSource); uploadForm.setWidth(300); Canvas iFrame = [B]new [/B]Canvas([B]"iFrame"[/B]); [B] final [/B]TextItem uploadTitleItem = [B]new [/B]TextItem([B]"title"[/B]); uploadTitleItem.setRequired([B]true[/B]); UploadItem imageItem = [B]new [/B]UploadItem([B]"image"[/B]); imageItem.setMultiple([B]true[/B]); imageItem.setRequired([B]false[/B]); DS.[I]getInstance[/I](); uploadForm.setTarget([B]"iFrame"[/B]); ButtonItem saveItem = [B]new [/B]ButtonItem([B]"save"[/B], [B]"Save"[/B]); saveItem.addClickHandler([B]new [/B]ClickHandler() { [B]public void [/B]onClick(ClickEvent event) { [I]uploadForm.setAction("strut action call"); [/I][I] [/I]uploadForm.submitForm(); } }); uploadForm.setFields(uploadTitleItem, imageItem, saveItem, cancel);
DS class
Code:
[B]public class [/B]DS { [B]private static [/B]DS [I]instance [/I]= [B]null[/B]; [B]public [/B]DS() { setDataFormat(DSDataFormat.[B][I]JSON[/I][/B]); setAddDataURL([B]"addaction"[/B]); DataSourceTextField title = [B]new [/B]DataSourceTextField([B]"title"[/B], [B]"title"[/B]); DataSourceField image = [B]new [/B]DataSourceField([B]"image"[/B], FIELD.ANY,[B]"image"[/B]); setFields(title, image); } }
server operations
Code:
[B]public [/B]String addaction() [B]throws [/B]Exception{ [B]try [/B]{ [COLOR=#660e7a][B]File = getFile()[/B][/COLOR][COLOR=#000000]; // business logics } [/COLOR][B]catch [/B][COLOR=#000000](Exception e) { [/COLOR][B][I]log[/I][/B][COLOR=#000000].error([/COLOR][B]"Exception in Support " [/B][COLOR=#000000]+ e); } [/COLOR][B]return [/B][B][I]SUCCESS[/I][/B][COLOR=#000000]; }[/COLOR]
or
if you provide an example for submit(callback) or saveData(callback) with file attachment, also can be helpfull to me
thanks in advance.