Blog do projektu Open Source JavaHotel

środa, 1 maja 2013

Jython framework and new widget

Introduction
I added new widget to my MVP Jython framework. The purpose is to handle set of checking like that:


It is a matrix of logical values. It can be used like in the example above : to set permissions for a given user in the list of  hotels (or any other objects). The same user can have different permission in every hotel. Lines (rows) are hotels and columns are permissions. Of course - it is a matter of opinion if it were better to have hotels as lines and permissions as columns or opposite. The crux of the matter is to have the 'lines'/'columns' defined programmatically (dynamically) - not statically in the dialog definition.
Implementation
Sample implementation (Google App Engine application) is available here. Click "Check list" button at the bottom. Check/uncheck matrix elements and click "Check". The current values are sent to the Jython code in the background and two values in the upper half are set.
Defining check list in the dialog is very simple - just add checklist tag like in this sample. More than one check list is allowed. Handling values in the backing Jython code is unfortunately more complicated. We have to support three scenarios.
  • Defining lines and columns for the first time.
  • Setting values
  • Getting values.
A pretty complicated data structure is used to accomplish the task. It is described here. A sample Jython code is available here.
Future
  • It is possible to implement a matrix of number (and any other data types) but I can hardly find any use case which can implement it. 
  • Error messages applied directly to the matrix. For instance message like "Checking here is not allowed" in the direct matrix position.
Next steps
I will try to implement the beginning of my new hotel management application. It will be administrative part: defining of hotels, user and permission of user in the particular hotel.  Then implement this solution as a realm for 'Shiro' to implement security for a hotel management (not administrative).

Brak komentarzy:

Prześlij komentarz