First of all, to follow the tradition and even though it seems a bit late, I’d like to wish all Genuxians in Chile a happy and prosperous 2009.
It seems that during 2008 we were all pretty busy, which means that we didn't organize any activities whatsoever and didn't even write on our blog.
This lack of participation and enthusiasm surely has to do with the usefulness of the GUGXChile for Genuxians in their daily tasks, something that hasn't happened so far. That is to say, it should be a more effective instance for collaboration.
There may be other reasons, but now I’d like to go into the subject of this post.
From GeneXus 9 we have the possibility of working with Patterns which, in simple words, are intelligent "molds" or "templates" used to automate a lot of work that we would usually do manually.
Probably the most used pattern is the WorkWith that comes with GeneXus, so I assume that most of us have experimented a bit creating some transactions and watching how, in seconds, a complete application is obtained with the "work with" screens and tabs with views according to the relationships given by the transaction attributes.
In spite of all those wonderful things, most of us (it happened to me) have probably missed some form of access control and rights and maybe other things as well.
Why didn’t Artech create it with more features? Maybe another improved version is coming soon? No. The idea is that everyone creates his or her own patterns and the WorkWith is just a good example of the power of this tool.
ww2I wanted to approach this subject not by creating a pattern from scratch, but changing Artech's WorkWith (GXXEv1 Beta1). Based on that work I've prepared a version called ww2 which is available at
GXOpen.
This version covers the following topics:
- Creating transactions for Users, Modules and Rights
- Procedure to initialize the admin. user
- Procedures to validate accesses and rights
- Login in the Home Web Panel
- Adding security routines in the generated Web Panels.
Vista del Login en webpanel Home
The expected functionality is more or less like this:
- the user will view, in the menu, only those modules for which he or she is registered.
- in the "work with" screen he or she will only view options depending on rights (Insert, Update, etc.).
- the user will be able to have individual accesses and rights or for being part of a users group.
View of the Menu in the Home Web Panel
Change the Work With
I will not explain the changes in detail, as that would be too long and the idea is that you discover things on your own, with a little guidance, by looking at the XML and DKT files of the ww2.
Change the CSharp project
In the case of the Work With, the sources come with the SDK Platform.
This is a bit advanced and aimed at CSharp programmers rather than GeneXus users.
In the case of the ww2 pattern, the Csharp code had to be altered to change the Work With name to ww2.
Change the resource file
The resource file is an xml file containing the definition of the objects consolidated in the KB the first time the pattern is applied.
To add objects to the resource file you only have to make an export, open the xpz and copy the desired Object element.
In this way I added the transactions and procedures to the resource file of the ww2.
Change the DKT templates The DKT templates are text files with embedded CSharp programming that is interpreted by GeneXus when applying the pattern. The execution of each template returns the parts (Events, Variables, etc.) of the new objects.
It could be said that it’s a special consolidation (import), not from an xpz file but from the template interpretation.
In these templates we can easily identify, for instance, the parts of GeneXus code which are static and those parts that are dynamically built interpreting Csharp.
A good example is the code of the Permissions routine in the GridEvents.dkt file of the ww2 pattern.
Well, that’s all for now!
*Posted by Miguel Figueroa in GUGX - Chile.