+1 for using the upload action.

Anca Paula Luca wrote:
> Asiri Rathnayake wrote:
>> Devs,
>>
>> I've been brainstorming about implementing office importer functionality in
>> wysiwyg where the user will be able to upload a document and have it's
>> content imported into the current page being edited (i.e into the wysiwyg
>> editor). Note that we already have the copy/paste functionality implemented.
>>
>> The first problem I see is that GWT doesn't have a way to upload a file with
>> a usual RPC call. Given the parameters, following is one possible way out of
>> this problem,
>>
>> 1. Define an OfficeImporterServlet which mapps to /xwiki/officeimporter
>> 2. Let the office importer wysiwyg plugin make a POST request to this
>> servlet with a FileUpload widget (
>> http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/user/client/ui/FileUpload.html
>> ).
> 
> You don't necessarily have to have your own servlet for this, you could 
> attach 
> it to a wiki document, by posting to the "upload" action for the wiki 
> document, 
> with the appropriate field names. I'm doing this in the image plugin with the 
> FileUploadForm.
> 
> You could even have your own action to post to, similar to the "upload" only 
> that it would invoke the importer plugin for the uploaded file and send back 
> the 
> results, although I'm not really sure this is a good idea, as actions are 
> quite 
> a core part of the wiki, and whose changing requires changes deep down (need 
> to 
> write your action and have it on the server, need to map it in the actions 
> mapping file). Your servlet would require web.xml mapping too, so maybe it's 
> quite the same.
> 
> Or, in order to get the output back you can:
> 1. upload the file to the current document and, when the upload call returns, 
> make a second call to the WywisygService to import the uploaded file and send 
> back (x)html.
> 2. upload the file to an office importer special document, transform it and 
> return it with the upload action result (I need to digg more on this to see 
> how 
> exactly would it be done). This solution would be hard to mix with the 
> uploaded 
> images in the file, as they won't be attached to the correct wiki document 
> upon 
> save, you'd need to move them.
> 
> Of course, you could also use solution 1. with a special OfficeImporter 
> document 
> as a repository for all files uploaded which need to be imported.
> 
> In both cases, uploaded attachment could be deleted after import.
> 
>> 3. The servlet will import the document into xhtml and write back the result
>> as the response.
>> 4. Office importer wysiwyg plugin in turn takes the result and put it into
>> the wysiwyg editor.
>>
>> And the second problem arises when there are non-textual content (ex.
>> images) in the document submitted. In this case, office importer servlet
>> must attach these files into the wiki page which is being edited. Now, if
>> the user decides to cancel the whole edit operation just after the import
>> operation, there must be a way to remove those attachments. How can we do
>> this? (For the moment I don't know how to handle this case)
> 
> You couldn't just save the document in which you import the uploaded file? 
> This 
> would solve a couple of problems from the previous point, too.
> 
> Otherwise, this problem is quite the same for any editing: the user does some 
> edits, image uploads, inserts his / her image and then cancels. The images 
> will 
> stay attached to the page even if the content that uses them won't.
> 
> One solution, not very clean and which I don't like, but would solve the 
> problem, would be to give them special names which would help you to have a 
> piece of code which could look for all unused such attachments and delete 
> them.
> 
> Or, with the (x)html content of the imported file, you could return to the 
> importer plugin a list of images attached with that file which you'd delete 
> upon 
> cancel.
> 
> Or you could just leave them there (could you?), as we do for all edit 
> situations, as I mentioned.
> 
> Happy coding,
> Anca
> 
>> Please let me know if you have any comments :)
>>
>> Thanks.
>>
>> - Asiri
>> _______________________________________________
>> devs mailing list
>> [email protected]
>> http://lists.xwiki.org/mailman/listinfo/devs
> _______________________________________________
> devs mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to