This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Looking for web application design input.

 
Ranch Hand
Posts: 1026
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I didn't know where to post my design question. Here is my requirement.

In my application we are implementing record locking concept. There are 2 different kinds of users. A normal user and a super user. There are 2 columns in my table where user's name and current locked by time will be stored. I have a button called lock in my page. When a normal user clicks the lock button then that particular record is locked by the normal user for 30 minutes. After 25 min there should be a pop-up message stating there is only 5 min left. After that a SQL query should be triggered which removes the user's name and time from those columns.

When a normal user has locked a particular record then another normal user cannot lock the same record. Whereas a superuser can lock the same record which was locked by a normal user. In this case the normal user must be notified that the lock has been taken by a superuser and he cannot edit the request any more and the control to go the search screen.

Coming to implementation part, calculating the 30 min can be done using two ways.

Using the setTimeout function in JS and
Using Thread in Java layer.

With javascript function implementation is easy. With threads we can calculate the time, but how to notify to the user after 25 seconds? How to take back the control to UI from java layer. I am using Struts 1.2.

I have the same doubt when superuser locks the record which is already locked by a normal user. How to notify the normal user (with a pop-up) about the changes that has taken place in back end. I am not using AJAX. Is it possible to achieve this with and without AJAX.

Please suggest me a solution without AJAX.
 
Bartender
Posts: 2968
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Coming to implementation part, calculating the 30 min can be done using two ways.

Using the setTimeout function in JS and
Using Thread in Java layer.


Seems easier to simply record the lock expiry time with the other lock information in the database.


First step is to challenge the requirements.

Basically you can simplify the entire system by focusing on
  • The user can lock a record (record user identity and expiry time of lock; i.e. a lock is only valid if it hasn't expired yet), provided the record doesn't have a valid lock on it.
  • A super user can override (overwrite) a normal user's lock (write (super) user identity and new expiry).
  • Any user can only successfully modify the record if they have a valid lock on it - otherwise the operation fails.

  • Note that there is no need to update the locking data on the record when the lock goes invalid. The passage of time will make the lock invalid. You will clear the locking data if the user intentionally releases the lock.


    Now go back and say something along the lines: "What you are asking for is possible and nice but will take two, three, four times as long (as much money) as this solution" possibly followed by "which probably means that we won't be able to implement X which you really seem to want."

    Its amazing how easily "non-essential" requirements are identified once the cost/effort comes into play.

    Look for information on the pessimistic offline lock.


    Later on you can always add "equivalent" features by using AJAXish techniques. Expose a "service" on the web application that allows the JS client to get the remaining time on the lock (../locks/{username}/{recordname}/{recordid}) which the JS client calls every 120 seconds or so (most Servlet containers don't like open HTTP requests to support "immediate client callbacks" unless they support continuations like Jetty). If the lock expires or is overwritten by a superuser the remaining time is 0 and a JS pop-up informs the user that the lock has been lost. If the remaining time is 4 - 6 min another JS pop-up is used to inform the user that the lock is about to be lost in m:ss minutes.
     
    I've read about this kind of thing at the checkout counter. That's where I met this tiny ad:
    free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
    reply
      Bookmark Topic Watch Topic
    • New Topic