I need to implement some mechanism to prevent users from editing same objects in the same time. Here's my application flow:
Go to 'list' page
Select row to edit form datatable
Click edit button (navigation to 'edit' page)
Change data
Click 'Save' or 'Cancel' (navigation back to 'list' page)
I wish I could check at step 3. if another user is editing same record (same id) and display information e.g. 'Sorry, another user is editing this'.
My idea is to keep map of logged users and table names + ids, which they currently edit. I would use application scoped bean (e.g. EJB 3.1 #Singleton) for this purpose. Can you point weaknesses of this solution? Can you propose any other?
I use Java EE 6, Seam3, Glassfish 3 and Oracle DB 11. I use MyBatis, no JPA frameworks.
You would be much better off having some sort of mechanism to accept well identified changes, and when applying changes, detect if the change was initiated on a different copy of the data than now exists, and raise an exception.
This kind of work flow prevents the dreaded, "I can't save the company because someone in CA started to change the critical record but then went to lunch."
Read the first few chapters of the Subversion book. While you are currently not concerned with data version control, the conflict scenarios are more complete, and better thought out than the old "library" system, where shared items are not available as long as they are in possession of one person.
Related
We plan to write a Vaadin front-end which contains a couple of hundred Vaadin portlets which are associated to a menu, which in turn will dynamically select the functions that need to be presented to the user. The UI will feature a set of menu options for the user to select, and based upon user's command, it will load the appropriate portlet to an adjacent Vaadin panel. Even though the intention is to have something like this, the question is whether this application will pre-load all the functions during initialization and take a long time to load? Should we follow a particular design pattern to avoid such undesirable delay in loading the front-end?
I'm working with a project of patient queuing using JSP and Eclipse IDE. In it, I require a message to be conveyed between two different sessions of same website (i.e. the doctor's and compounder's homepage are alive).
As soon as the doctor finishes consulting a patient, a message is to be passed to the compounder's home page saying "To send new patient in".
I checked session creations and MVVM. But it doesn't satisfy me. Will anyone please help me out on this? I have tried an "auto refresh" inside JavaScript, but I ended up in an infinite loop.
This is a very broad topic. You can go about it in several ways and using several technologies (message queues/brokers, websocket, dwr, etc).
This is similar to building a chat application so maybe search for that online (again another broad topic).
If you want something very simple (and most of the times inefficient - but that depends on your requirements) you can go about it this way:
Have a simple database behind your application (an application wide thread-safe queue should work too but a database gives you persistance in case something happens to the application, like a server crash);
once the doctor finishes the consultation, his page saves an entry to the database, a flag basically;
The compounder's page has an Ajax request that from time to time (say 10 sec) looks for the flag in the database;
if the flag is found it displays a message on the compounder's page to send the next patient and then resets the flag
repeat step 2.
Those are broad steps to build something simple. As I said, not the most efficient way. Search for how to build a chat and you'll find better ways since a requirement for chat applications is to be fast and scalable.
First, this is not a programming question, yes I know.
Now, I am developing a custom software (Java Swing) for a company as a sub contracting company. I create the code and database (MySQL), send them via a protected method online and their IT people install it there by them selves. I cannot reach their place as I am in a far far away city.
I am having a problem with the database, that is, should I hard-code the database configurations into the Java swing application (or .properties file) or else should I allow the user to decide the password, user name and server IP ? Which means user can edit them at any time, I am planning to use java.util.pref.Preferences in that case.
However I have heard that lot of development companies do not allow the user to edit the password, user name etc, mainly because they might go and edit the database.
So right now I am confused. which method should I select? Hard coding the configurations or allowing dynamic configurations? Any advice please?
Given an java web application that is currently running in a server, will deploying the same app (giving it a new context name ie. /app-readonly) but provide it with a readonly db account the only thing I need to make a readonly version of a web application.
I would expect that this readonly version of the application will be able to view, search but any updates/creates that are triggerred from the screen will just return an error (which is fine). This is the simplest solution I can think of, without introducing a code change in order to give finer grain control on the application's user access control. At the moment the user access control only dictates what screens are accessible to a user. It is not complex in that it does not dictate what the user can do in a given accessible page.
Is this a correct approach or am I missing something?
That approach is good only if you specifically want to deploy a new web application.
In my view you should create read only user and give that user access limited to Search, view.
In this case user wont have the rights to perform insert, update.
This approach should be there within your project, who can access what ? If you have to deploy a new app for view only, IMHO you need to revisit your access control design.
I have an EJB 2.1 Project (Actually, it must be migrated into EJB 3.1 :-)) Currently it supports only one window. it means the user should work on a window. It is because of the variables, used as session variables. (Last Search Criteria, last used id, etc...).
I want to make it possible to open two or more tabs in for example Firefox and work parallel. If the user is on the same tab, the variables should be kept only for that tab. Only global variables can be valid for all tabs.
How can i approach to this problem.??
Any documentation to understand multiwindow will be also helpful.
Or any other idea or experiences about multiwindow web project is also welcome.
There isn't any built-in way to deal with this in either browsers or any EJB that I am aware of. Other web app frameworks have the concept of Web Flows that are series of connected actions that can handle multiple flows in different tabs of the same browsers, so you may wish to start looking there.
In a nutshell, they create their own "cookies" that the application controls, not the browser itself. These "application cookies" are then used to stash chunks of information related to the current set of operations, much like a session.
These sorts of things are often kicked off by the user clicking a link that opens in a "new window" (or tab) that notifies the application (via a page hit or an ajax call) that a new "work session" is being opened and gets the inner-session set up.