What's the best way to prevent multiple submission in XPages? - xpages

What's is the best way to prevent multiple submission when I'm using XPages?
For "classic web" solution is below.
How to Block Multiple Submissions of the Same Document from the Web
http://www-304.ibm.com/support/docview.wss?uid=swg21089865
Using jQuery, the solution is below.
http://www.norio.be/blog/2008/09/using-jquery-prevent-multiple-form-submissions
But I don't know the way in Xapges. How to prevent it in XPages or Dojo?

It is best not to apply such client-side techniques, because combined with an unreliable internet connection the user may find that the submission fails but be unable to retry.
A much more robust solution is to deduplicate on the server side, which can be done in a variety of ways; these are some that come to mind:
Define the semantics of your form contents so that it doesn't matter if you receive two requests (e.g. if it is updating a record, then a second update just changes nothing).
If you have seen the exact same submission before (compare all the relevant fields), ignore it.
Generate a serial number when you send the form to the client. Don't accept submissions that have a serial number you've seen before — or do something useful; for example, if it is a blog posting or comment form, then a second submission should be treated as an edit to the post created by the first submission.

You can prevent a submit by using XSP.addQuerySubmitListener and return false. This is not the easiest function to get working. So I suggest you take a look at the function in the book 'Xpages Portable Command Guide' or try my project multiple file uploader on OpenNTF. Download the project source code here.

Related

ServiceStack Razor - How to Return Validation Errors to a Form?

I'm trying to figure out if it is possible to use ServiceStack Razor for old-fashioned server-side form validation.
By way of example: a GET to a url returns a razor template with a form. When the user POSTs the form, request DTO is validated and if there were errors, the user is shown the same form, with original values re-populated as and fields in error marked somehow. If, on the other hand the request DTO is valid, the service will redirect the user to another page.
Is that scenario possible?
If so, how would one go about implementing it? I presume I'll have to write certain filters or features for this to work, however I'm wondering what strategy will require minimum amount of coding.
(I understand javascript validation is possible, however my question is specifically whether it is possible to round-trip the form with server-side validation).
Take a look at ss-validation.js, it can be used to apply validation errors to your form based on ServiceStack's ResponseStatus.
So we write all our validation code server side using FluentValidation, then on round trip ss-validation reads ResponseStatus and applies markup.
Out of the box is assumes Bootstrap style validation, but it's fairly easy to modify to suit your needs, e.g. we amended to display inline icon tool tips instead of inline/block messages, and provide an error summary.
After a lot of spelunking of the ServiceStack codebase, it seems it is theoretically possible to achieve the desired scenario.
The code already contains ModelMetadata and ModelMetadataProviders classes, and some of the HTML helpers are ported from System.Web.Mvc.
Sadly, the classes are not fully wired, so I guess it will require solid amount of work to get everything working correctly as one would expect.

Saving to multiple lists from 1 sharepoint 2007 list form

I have a request form I'm working on, wherein different departemnts need to be able to update it. To minimize overlap and lost changes I'd like to be able to submit data from the new form to different lists, but I cannot find a way to do this.
Does anyone have any experience trying to do anything similar?
If you're familiar with JQuery andSPServices I could envisage a way to do this.
In the EditForm.aspx, add the JQuery and SPServices libraries. using the $.(document).Ready function, I'd do a quick item update with the SPServices and just copy a column with the same data, so in effect no change looks to have taken place. I'd add in the edit comments something like "Pseduo checkout to [name], [date_time]".
Then allow the user to edit the form as normal but in the code you've added, you trap the PreSave Action and check that the person trying to do the save is the same as the last modified - if it is, save as normal, otherwise, return false on the PreSave and it will be denied. When you actually allow the save, set the edit comments to something sensible.
To complete this, check before doing the pseudo checkout, that the last comments don't contain the psuedo checkout phrase so that you can prevent anyone opening/editing the form whilst somebody else is in the middle of an edit.
This gives a cheap and relatievly easy to implement Check-In/Check-Out for a list. Not perfect of course but should work well in most scenarios (not in datasheet though, so you might need to prevent that type of edit).
If you have two lists would you not then have the problem of potentially two requests for the same thing?
Does none of the version control options for the list solve the problem of potentially multiple concurrent editors?
While SPService is certainly a solution, but you will have to build a UI of ur own.
Try writing a event receiver, which can copy over item to another list as soon as it is created.
It will be nice if you can tell why you really want to have a copy of item in another list
i.e. Auditing purpose etc. , you can get a perfect solution for this in Forum

DataModelSelection on list exposed via EntityQuery

Is it possible to have support for enabling DataModelSelection on a list page paginated via EntityQuery? (All the examples load the list by performing a query on the #Factory method). But, I would like to re-use the existing pagination mechanism and just enable the ability to support DataModelSelection on it.
I am also assuming that DataModelSelection is capable of tracking a single row in a List, how do we extend this to support a certain action (say deletion, activation ...) of multiple rows.
I am a newbie and would appreciate any help on this topic. I have already gone through the samples shipped as part of Seam (booking, message).
I have already posted this in seam users forum, but I am yet to get a response
I guess you would have solved this issue by now but these two code snippets might help a bit
html code (jsf file)
a method in the bean that handles the action from the jsf

Multiple Sharepoint Forms

I am trying to split out what I originally wanted in a single form. The downside was that I wanted to keep multiple lists and I found that I could not use a single form with multiple lists.
What I am trying to do is to keep my customer information in a separate list/form so I can re-use it in a different application as well.
What I would like to do is give a picker to pick the customer from a list, and if the customer is not listed to allow the creation of a new one.
What I am wondering is how I can leave the main form, create the new customer, and then return to the main form but with the new customer information passed to the new form as selected. In ASP.NET one of the ways I would do this is through the querystring, but I am not sure if that is doable or preferred in Sharepoint.
Any thoughts or links to tutorials would be great.
Please keep in mind that due to access/security limitations I am trying to do this strictly through the browser and Sharepoint Designer.
Thanks!
With your access limitations, I don't see a solution that will allow the refresh of the original form to get the new data. You may be able to hack in some JQuery stuff to do this, but I just don't see it being an easy/value-for-time thing to do.
You may just have to allow the form user to save the form without customer info and come back to it.
A list view can then highlight forms with no customer info. This all depends on the usage scenario.
You can use the Source query string parameter to get you back to the original form after completing the new customer form. However, unless you add some code (either javascript or server side) you won't get the id of the new customer.
The best option is probably using jquery and the sharepoint web services. It's quite easy if you start with the right scripts, and you can do something like your original plan - make a simple form in a jquery ui popup.
You can also use javascript to manage linking between multiple forms, but you need to be careful about clearing out already entered form data.
Another option would be to edit dispform.aspx and add dataviews for other lists, along with appropriate add buttons, and add javascript to the new customer form that sets the value of a connecting lookup field. However, that tends to require quite a bit of messing about with list guids and other undocumented bits.

Change template html in sharepoint discussion reply box

I have a wss 3.0 install which needs an "anonymous" discussion board. I can modify the view so no usernames are displayed, however when I click on "reply", the message I'm replying to shows up in the rich text box with the username of the previous poster.
Is there a way to remove that username? or Remove the previous posted text altogether? I've found the schema.xml file with lots of relevant info under the ..12\TEMPLATE\FEATURES\DiscussionsList\Discuss folder, but not sure if this is the easiest way to adjust this setting.
Any comments appreciated.
Best practice says that you should always create a custom list definition instead of trying to modify the OOB assets.
The easiest way to do this is take a copy of the 12\TEMPLATE\FEATURES\DiscussionsList\Discuss folder, modify the feature Ids and names so that its unique. Then your free to change the schema render template (i.e view schema) and modify the edit and display forms.
If you need to modfify the actual entry form you may consider a custom control template : http://msdn.microsoft.com/en-us/library/aa543922.aspx
Custom list definition : http://msdn.microsoft.com/en-us/library/ms466023.aspx
Agrothe,
I have a similar requirement (hide or mask the author inside the reply thread.). What exactly inside of schema.xml do you think will allow you to do accomplish that?
Not sure if the list forms are exposed to xslt. If so, then perhaps this is another approach.
FWIW, the other solutions I have investigated:
(1) A custom event handler. Unfortunately, I can't pinpoint which event fires when someone click reply.
(2) Anonymous blog comments (http://blogs.msdn.com/sharepoint/archive/2007/08/06/anonymous-comment-feature-for-sharepoint-blog-now-available-on-codeplex.aspx).
(3) the other thing I am considering, is to introduce a global anonymous active directory login, which users can use to post anonymously. Not ideal, but for the amount of time I have spent researching a solution, might be my last hope.

Resources