Hi,
I am working on a public page where the data pull from database base on
different UUID. Where this page doesn't required login account. It differential
by UUID where it send via email.
What I affaird in the email that contain UUID that might forward to multiple
users for filling in a long forms with same UUID.
(This form it could be share same department but different sections).
How can I lock this page or only allow accessing by a user until been
submitted?
Azadi - 04 Aug 2007 15:23 GMT
please clarify your problem - your description is not very clear....
---
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com
garlington@tiscali.co.uk - 06 Aug 2007 10:51 GMT
> Hi,
> I am working on a public page where the data pull from database base on
[quoted text clipped - 7 lines]
> How can I lock this page or only allow accessing by a user until been
> submitted?
Are you trying to lock web page for a period of time until the first
(First come - first served basis) user submits the page?
If that then how do you know if the user is going to submit it at all?
He/she might be just viewing the page with NO INTENTION of completing
the form? How long do you intend to wait?
I would suggest to issue each user unique session ID on top of UUID
that you already have and then process submitted results for each user
separately.
qoop - 08 Aug 2007 03:41 GMT
Basically this page is link via url UUID which send by email- which is unique
base on Dept ID and it is sending to all dept head's to fill in.
What I affaird the he/she might forwards this to couple staffs with same Dept
ID to fill in - which might be error if someone saved it last will be over
write the early saved.
So i would like to control this page that it only allow 1 user to view the
page at a time sometime like lock but i cannot implement with login account as
I would like it to be simple and easy.
Please advise.
BKBK - 08 Aug 2007 07:04 GMT
Locks check concurrent actions, two users acting at the same time. What you
want is to make it impossible for one user to overwrite the previous efforts of
a colleague. So a lock would solve only part of the problem.
I would record every form submission by ID in the database. When a user opens
the form page I would run an initial check to see if a form corresponding to
his or her UUID had previously been submitted. I am assuming that you already
have a way to validate the UUID beforehand.
Now, consider the case where two users having the same UUID are concurrently
filling the form. It suggests that you should also include code that does a
check when the user presses the submit button. It should verify from the
database whether a form corresponding to that UUID had already been submitted.
What about the time wasted by the later user? You will have to ignore such
matters, as you want things [i]"to be simple and easy"[/i].
qoop - 08 Aug 2007 08:29 GMT
Thank BKBK.
Yes, I hv a code that verify if submitted if will lock n show a message.
The prob i hv is concurrent filling the form. How can I able to lock this that
only allow 1 visitor at a time?
Any syntax that can do this? CFLOCK able to do the trick?
BKBK - 08 Aug 2007 21:57 GMT
you could do something like this to prevent concurrent access
<cfset isDone = false>
<!--- Assuming (1)You have by this point verified that the client's UUID is
valid
(2) For example, default UUID is 471E3E7D-138F-F126-01F8F4E31705E611 --->
<cfparam name="URL.uuid" default="471E3E7D-138F-F126-01F8F4E31705E611">
<!--- default department id is UUID471E3E7D138FF12601F8F4E31705E611 --->
<cfset variables.dept_id = "UUID" & replace(URL.uuid,"-","","all")>
<cftry>
<cflock name="#dept_id#" throwontimeout="Yes" type="readonly" timeout="3">
<!--- Database check whether form having that id has been submitted --->
<!--- If so, do <cfthrow type="formAlreadyDone"
message="A form having your departmental ID has already been
submitted.">--->
<!--- The code block within the lock will throw an exception if it cannot
obtain
the (named) lock after 3 seconds. --->
</cflock>
<cfcatch type="formAlreadyDone">
<cfoutput>#cfcatch.message#</cfoutput>
<cfset isDone = true>
</cfcatch>
<cfcatch type="lock">
A colleague having your departmental ID is currently filling the form.
<cfset isDone = true>
</cfcatch>
</cftry>
<cfif NOT isDone>
<cflock name="#dept_id#" throwontimeout="Yes" type="exclusive" timeout="20">
<!--- the form to be filled --->
</cflock>
</cfif>
Nytyme - 09 Aug 2007 13:58 GMT
do you have a last modified date on the table being updated?
if so, when you pull up the record store the date in a field and check to make
sure it's the same when the user runs the update.
you can keep track of the first person who enters the site, create a session
for that person, and set a timeout so that if they haven't submitted the
changes within an hour or so, that it unlocks.
qoop - 10 Aug 2007 05:00 GMT
Hi BKBK.
I tested but it cannot be lock - i open the dept_id:HR in my pc and I open same dept_id:HR in other pc which able to view same page.
ps: dept_id = base on URL.UUID.
BKBK - 10 Aug 2007 06:54 GMT
Qoop wrote:
[i]I tested but it cannot be lock - i open the dept_id:HR in my pc and I open
same dept_id:HR in other pc which able to view same page.
ps: dept_id = base on URL.UUID. [/i]
That is a paradox. If entry to the page cannot be locked then the form should
not to appear on at least one of the PCs. Could we see your code.
qoop - 10 Aug 2007 05:04 GMT
Hi Nytyme,
I also thought same as u but i would like to try on BKBK's method if doesnt
work.. i will using database to control.
eg:
when user view the page > it write into database with timespan
if user refresh/click it update wth new timespan.
If current time > timespan with diff IP address then unlock else lock
something like this
qoop - 16 Aug 2007 07:09 GMT
sorry for late reply.
anyway, here is the code (simplify version), so how do i able to lock base on
my code? thanks again.
<cfquery of DEPT info base on the #URL.UUID#>
<cfif DEPT recordcount EQ 0>
Missing dept info <cflocation to xxx.cfm>
<cfelse>
<cfif SUBMIT EQ 1>
TQ for submitting...
<cfelse>
code start here...
<form action= next_page_action.cfm>
</cfif>
</cfif>
Prabhu S - 16 Aug 2007 13:03 GMT
Try the above options with your "USE J2EE session varaibles" enabled in the
Memory variables of CFMX administrator. It would solve the concurrent issues in
terms of sharing the session variables. Try & reply me back.
Could u please share the version of your CFMX server ?
qoop - 17 Aug 2007 07:24 GMT
Hi Prabhu,
I am using CFMX 6 but the server is sharing with other applications.
Prabhu S - 17 Aug 2007 07:44 GMT
Is there any progress in using the "Use J2EE session variables" ?
BKBK - 19 Aug 2007 22:29 GMT
Qoop wrote:
[i]I tested but it cannot be lock - i open the dept_id:HR in my pc and I open
same dept_id:HR in other pc which able to view same page.[/i]
BKBK wrote:
[i]That is a paradox. If entry to the page cannot be locked then the form
should not appear on at least one of the PCs. Could we see your code.[/i]
Qoop later wrote:
[i]anyway, here is the code (simplify version)...:
<cfquery of DEPT info base on the #URL.UUID#>
<cfif DEPT recordcount EQ 0>
Missing dept info <cflocation to xxx.cfm>
<cfelse>
<cfif SUBMIT EQ 1>
TQ for submitting...
<cfelse>
code start here...
<form action= next_page_action.cfm>
</cfif>
</cfif> [/i]
I have tested my suggestion. It works.
I can see where your code is leading to. However, it does not follow the line
I suggested on 08/08/2007. Its logic is essentially different from mine. In my
code, the condition for displaying the form is in a lock. In your code, the
form is displayed unconditionally.
qoop - 20 Aug 2007 10:45 GMT
Hi BKBK,
I understand ur code, which u lock when database recordcount found.
But I need it to be lock not even yet submit to database.. I would like it
lock it when someone is viewing the page(dept A form) and no other person able
to view dept A form until the person submit and close the page.
Hope this is clear.
BKBK - 20 Aug 2007 21:02 GMT
Qoop wrote:
[i]But I need it to be lock not even yet submit to database.. I would like it
lock it when someone is viewing the page(dept A form) and no other person able
to view dept A form until the person submit and close the page.[/i]
You may leave out the database code if you want. Try something like:
<cftry>
<cflock name="#variables.dept_id#" throwontimeout="Yes" type="readonly"
timeout="3">
<!--- The code block within this lock will throw an exception if it cannot
obtain
the (named) lock after 3 seconds. --->
</cflock>
<cfcatch type="lock">
A colleague having your departmental ID is currently filling the form.
<cfset isDone = true>
</cfcatch>
</cftry>
<cfif NOT isDone>
<cflock name="#variables.dept_id#" throwontimeout="Yes" type="exclusive"
timeout="20">
<!--- the form to be filled --->
</cflock>
</cfif>
qoop - 30 Aug 2007 02:06 GMT
Hi all,
Sorry for such late reply.
I hv solved the prob.. by combine BKBK and Nytyme methods.
So far, its work prefectly :)
Thanks again guys for all ur great help and advised.