We implemented a web service that gets called on save. Can we get Form Builder to send all files uploaded in the form every time the form is saved, instead of just the files that were newly uploaded since the last time the form was saved?
I imagine you're implementing the persistence API. Assuming this is the case, the short answer is no.
But then, why would you want that to happen? If a file has already been saved to your persistence layer, when the data is saved you get the form definition with a "link" to that saved file. If you need to retrieve it, you can do so, but, unless I misunderstand what you're doing, you don't need to get it back from Form Builder.
Related
I'm new to Orbeon. Perhaps this is a dumb question but I'll ask it anyway: is it possible in Orbeon to change the form data after the first time the form is submitted? I mean, suppose that I'm a student that is using Orbeon to enter some of my personal information into a form. After I submit the data I remember that I forgot some data or informed something wrong and then I want to come back, find the data I placed earlier and update the contents.
Is it possible or am I missing something?
Marcos
The simpliest way is to define 2 xf:submission.
One for the pre-load of the data of your form, you send it with something like this :
<xf:action ev:event="xforms-ready">
<xf:send submission="preload"/>
</xf:action>
the second one you'll use it when you need to save the datas (a save trigger is the most common use-case).
With this, when you come for the first time, your preload submission loads only blanks, your save submissions will save your instance. When you'll come back, this saved instance will be loaded by your 'preload' submission and you'll be able to modify your datas before submitting again.
I have a MVC 3 application with Razor. The form is data driven and has a series of testboxes and radio buttons and a file upload control. The textboxes and radiobuttons reside in first form and the upload control is in its own form. If the file is uploaded first then everything is fine. But if say the user fills in the form with the textboxes and radio buttons and then browse's to the file to attach and clicks attach (a submit button) within the 2nd form, the whole page is posted back and all the controls loses their values and its not user intutive. As I am trying to do the file upload and uploading the file on the server as a separate task on the form, I am not able to find any examples on the net for such a scenrio. All I find is people doing form elemnets and file uploads in one subit action. My requirement is such that the file upload is kept seperate so that users can attach files and also remove files which are attached, so only when they are happy do they submit the form. Any pointers welcome.
Here's an approach you could try and which seems adapted to your scenario:
Use AJAX (or Flash/Silverlight/HTML5) in order to upload the file to avoid page reloads. There are many plugins and possibilities out there: plupload, uploadify, jquery form, ..., just pick one that suits you.
When the user uploads the file store it on the server on some temporary location and return an unique id so that later you could fetch this file.
On the client use the id to inject it into a hidden field on the first form (the one that contains all the textboxes and radios).
When the user submits the first form the id of uploaded file will be sent to the server and you will be able to fetch the file that was uploaded.
This approach could also allow you to upload multiple files. Just play with jQuery and manipulate the array of hidden fields (add, remove, ...).
I have a project where I have several content types (Article, Interview, etc) with nested images. To handle the images, what I did was implement a popup 'image upload' box (using a combination of Paperclip and Uploadify) so the user can upload an image immediately to the article.
The process works like this: the user clicks the 'upload an image' icon, then a box pops up where they can add paperclip file upload fields to upload as many images as they want. Uploadify instantly uploads the photos and assigns them the article ID number they're attached to. Then the photo's HTML gets sent to the WYSIWYG editor. If they want to delete photos as well, they can. If it sounds like WordPress, that's what it's based on.
Anyway, I have this working great. Photos remain associated and attached with their respective articles, as opposed to throwing everything in one huge folder (like many WYSIWYG image uploaders do) where anyone can add/delete anything.
But there is one little flaw to this...as I said, the image is assigned the content's ID number when an upload is performed. Well, you can see how this is an issue when creating a brand new article, as a new article doesn't have an ID number before saving it. So the image upload fails. Thus, this whole process only works on the 'edit/update' action.
In the interim, I told the team to make sure to SAVE the article first, then when they go back to edit it they can then upload their images to the body. But naturally, they forget as it's an easy thing to do, and as this is very user-unfriendly, I gotta solve this.
I see two ways I can go about this.
Assign an ID (hidden field or otherwise) to an article on the 'new' form. This would appease the uploader as it fills the 'nil' value it errors out on, then when the article gets saved the first time, it would assign it that very same number. But I see a potential issue...what if another user creates an article at the same time and the database assigns it an identical ID number?
I noticed that the moment you create a new WordPress document, the new document 'autosaves' immediately as a draft. So my line of thinking is this...when the user goes to create a new document, the 'new' action would actually trigger a 'save' operation, bypass any validation errors (since the fields are blank), then immediately redirect to the 'edit' action. That way, the ID is saved and everything would work as normal, and the entire process may look seamless to the user.
How would you handle this situation? Like I suggested above, or is there an even better way?
I decided to go the second route and perform a save on the new action and bypassing the validations, then redirecting to the edit form, throwing as "autosaved" flash message in for good measure. It works well.
I have a head aching problem that I can't seem to find an easy solution to.
I have a couple of models, each with an image attachment, that belongs to a user. I have made a very nice ajax file upload and image cropping form, but there is a problem. Everything works fine when I am editing objects that is already in the database but when I upload a file as I create a new object it doesn't. The thing is, to be able to upload and save the image, the object already has to be in the database. I have found two possible solutions to this problem but none of them will work properly.
The first one is to create the object in the database in the new action and redirect to edit action. The pros is that it is a very simple fix. The cons is that the objects will show up in the list with previously created ones even if the user canceled or never submitted the form, which is very confusing.
The second possible solution is to lift out the attachment fields of the model to a separate model. On creation I would then only need to create an attachment object. If the user canceled it would leave the attachment orphaned, but that is probably okay as the orphans could be cleared periodically. The problem with this is that I can't find a way to prevent users from hijacking the orphaned images, or any other image for that sake. Unless I cant solve this problem I'm stuck.
I'm all out of ideas and would really need some help on this one.
Thanks, godisemo
EDIT:
I was probably unclear. In my form it is possible to upload an image. The image is uploaded instantly to the server with javascript, before the form is submitted. The reason is that I want to allow the users to crop the image. This is no problem wen working with existing objects but it is when creating new ones, as I tried to explain earlier.
I've never had to have the model already in the db for paperclip to work.
One thing you can try though is the following. I don't know what your model is called but let's say User has an image. Make your new form so that all of your user fields are passed in the params[:user] var, but then make your image upload file separate from params[:user], say params[:my_image].
Then in your controller validate and save the user, then after user.save, attach the image.
I solved the problem now, with a completly different approach. Instead of thinking databases, objects and models I solved it using file system and temporary files. When the image is uploaded it is processed by paperclip, I then move the generated images to a folder where I have control over them.
I based my solution on a really great article which you can find here, http://ryantownsend.co.uk/articles/storing-paperclip-file-uploads-when-validation-fails.html
I have an ASP.NET MVC page with multiple file uploads. After a failed post, all the file upload boxes are blanked out. I don't want the user to need to reselect all the uploaded files. Is there a way I can preserve the values in these fields if other fields fail to validate on Post?
I could do the uploads via AJAX, but this would be more complex as I'd need to ensure they were cleaned up if the user decided not to submit the form in the end.
You need to write your upload view so that you can pass default values to the text boxes.
When your user submits the file upload from your upload view, you will have all of the values for the text boxes in your controller method. Then, when your post fails, you can simply pass the values back to your upload view to populate the text boxes, rinse and repeat.
Actually, FireFox does preserve value. But you can't preserve it (set on server) according to http://www.cs.tut.fi/~jkorpela/forms/file.html#value. So I think your best way is AJAX. If you can actually clear the value.
Also, not sure if this will help, but try http://jquery.malsup.com/form/ which does file upload in iframe.
Or let user choose a better browser ;-)