Visual Report Writer and The Web (XII)
by
, 18-Jun-2013 at 06:22 AM (33584 Views)
In this twelfth blog about Visual Report Writer and the Web I want to take you some not really report related features that can be found at the Live Demo website (European Server, USA server). If this is the first blog you read I encourage you to read the eleven other blogs (1: The Solution, 2: Invoices Report, 3: The Cleanup, 4: The CustomerList, 5: The Orderlist, 6: The Credit and Balances Overview), 7: Inventory Stock Levels), 8: Sick Leave), 9: FileList (RDS)), 10: Four Wine Data Based Reports) and 11: Top 10 Salespersons). Meanwhile we have been able to release the Alpha II version of Visual Report Writer 3.0 and the 2.1+ Library only setup. The latter one is needed to make the web reporting using the 17.1 DataFlex Web Framework easy and look like at the demo website.
Toolbars
If you navigate around at the demo website you should discover that in some cWebView based views you will have a tool-bar to find data to be used as selection criteria. The tool-bar shown is the standard find tool-bar that is created when you create a new web project, it is only not always visible. How is this done?
The solution I came up with consists of two parts. First, the site supports a login system, a visitor will be automatically logged in as guest and a guest user does have limited rights. These limited rights tell the application to hide the standard find tool-bar. The automatic login is done with the following code:
Login or connect to the web application triggers the OnChangeRights event to be executed. In the oFileMenu object this event is catched to hide the normal file pull-down options such as find, save and delete and to hide the standard find tool-bar.Code:Object oWebApp is a cWebApp Set psTheme to "Df_Web_Creme" Procedure OnLoad Boolean bIsLoggedIn Get IsLoggedIn of ghoWebSessionManager to bIsLoggedIn If (not (bIsLoggedIn)) Begin Get UserLogin of ghoWebSessionManager C_$GUESTLOGINID C_$GUESTLOGINPWD to bIsLoggedIn End End_Procedure
With the above a guest user - which is a user that does not have data edit rights - does not see a standard file pull-down and a standard find tool-bar. How come that some views while the guest user is logged in get a find tool-bar?Code:Object oFileMenu is a cWebMenuItem Set psCaption to "File" Procedure OnChangeRights Integer iUserRights Get piUserRights of ghoWebSessionManager to iUserRights WebSet pbRender of oClearMenuItem to (iUserRights <= C_DATAEDITRIGHTS) WebSet pbRender of oClearAllMenuItem to (iUserRights <= C_DATAEDITRIGHTS) WebSet pbRender of oPromptMenuItem to (iUserRights <= C_DATAEDITRIGHTS) WebSet pbRender of oFindMenuItem to (iUserRights <= C_DATAEDITRIGHTS) WebSet pbRender of oNextMenuItem to (iUserRights <= C_DATAEDITRIGHTS) WebSet pbRender of oPreviousMenuItem to (iUserRights <= C_DATAEDITRIGHTS) WebSet pbRender of oLastMenuItem to (iUserRights <= C_DATAEDITRIGHTS) WebSet pbRender of oFirstMenuItem to (iUserRights <= C_DATAEDITRIGHTS) WebSet pbRender of oSaveMenuItem to (iUserRights <= C_DATAEDITRIGHTS) WebSet pbRender of oDeleteMenuItem to (iUserRights <= C_DATAEDITRIGHTS) WebSet pbBeginGroup of oLoginMenuItem to (iUserRights <= C_DATAEDITRIGHTS) WebSet pbRender of oFileToolBar to (iUserRights <= C_DATAEDITRIGHTS) End_Procedure
This is done from the view object itself. Each view - normally instantiated from cWebView - is instantiated from a sub-class named cVRWWebView. In this sub-class the methods OnShow and OnHide are taken to handle the find tool-bar related actions. For this the class defines a property named pbUseFindToolBar which defaults to false and can be set to true on a view-by-view base.
The event OnShow takes the property and sends a message to the commandbars object to show or hide the find tool-bar.Code:Class cVRWWebView is a cWebView Procedure Construct_Object Forward Send Construct_Object Property Boolean pbUseFindToolBar False Set pbServerOnShow to True Set pbServerOnHide to True End_Procedure
When the view focus changes to another view the find tool-bar is always hidden.Code:Procedure OnShow Handle hoCommandBar Boolean bUseFindToolBar Get phoCommandBar of oWebApp to hoCommandBar Get pbUseFindToolBar to bUseFindToolBar Send EnableFindToolBar of hoCommandBar bUseFindToolBar End_Procedure
Finally the commandbars object (in WebApp.Src) sets the pbRender property of the find tool-bar based on the passed true/false value.Code:Procedure OnHide Handle hoCommandBar Get phoCommandBar of oWebApp to hoCommandBar Send EnableFindToolBar of hoCommandBar False End_Procedure
Next to the find tool-bar there is a file tool-bar. This bar is only available if the logged in user has data or doc edit rights. Doc edit rights make it possible to change the contents of "The Solution" page as well as the contents of the "Show Documentation" modal dialogs, which is the same text. Data edit rights allow the logged in user to edit, delete or create rows in the weborder, wines or adventure works data via the views that can be opened from the view pull-down. These rights are meant for demonstration purposes. The views can be opened to inspect the report results if you like.Code:Procedure EnableFindToolBar Boolean bShow WebSet pbRender of oFindToolBar to bShow End_Procedure End_Object Use SessionManager.wo
Login
As mentioned above the demo web application supports a login of a user. Normally if your application invokes the login dialog the name and password fields will be empty and the user has to enter the information. Because an automatic login is coded in this demo application and you might not know the login credentials I decided to already fill in the login credentials if the login dialog is invoked. For a data or doc edit session the operator knows the other login account information values and can change them. For a visitor all what is needed is clicking on OK. Pre-enter the login credentials is done via the OnShow event of the login dialog.
The rest of the login dialog is the same as the standard login dialog provided by the framework.Code:Set pbServerOnShow to True Procedure OnShow WebSet psValue of oLoginName to C_$GUESTLOGINID WebSet psValue of oPassword to C_$GUESTLOGINPWD End_Procedure
Documentation
In all report views you will find a tool-bar item labeled "Documentation". Clicking the button opens a modal dialog in which a text is shown explaining information about the report view. The text is the same as the text displayed if you click individual examples in the "The Solution" page. In the "The Solution" blog is described where the data is stored. The documentation button sends the message ShowViewDocumentation to the cVRWWebView based object. In this method the name of the view is retrieved and a row in the documentation table is located. The ID of the documentation row is passed to the method that shows the modaldialog.
The oModalDocumentationDialog is a "normal" cWebModalDialog object where the upper panel (cWewbPanel) object has only one child object, a cWebHtmlBox object.Code:Procedure ShowViewDocumentation Handle hoReturn Handle hoView String sViewName Get ViewObject to hoView Get Object_Label of hoView to sViewName Clear Documentation Move sViewName to Documentation.ViewName Find Ge Documentation by 2 If (Found and (Documentation.ViewName = sViewName)) Begin Send ShowDocumentation of oModalDocumentationDialog hoReturn Documentation.ID End End_Procedure
The ShowDocumentation method stores the passed ID of the documentation row and not the full HTML documentation string because the client first needs to be instructed to open the modal dialog before the value can be displayed. Storing the ID takes less memory and transport space than storing the full HTML string, certainly because the property is a web synchronized property. The drawback of storing the ID is that the system needs to read the row in the documentation table twice (once for locating the correct topic and once for showing).Code:Object oModalDocumentationDialog is a cWebModalDialog Set psCaption to "Documentation" Set piMinWidth to 600 Set piMinHeight to 400 Object oMainPanel is a cWebPanel Object oWebDocumentationBox is a cWebHtmlBox Set psHtmlId to "SolutionText" Set pbFillHeight to True End_Object End_Object
When the dialog opens the event OnShow is triggered and this event is used to fill the contents of the cWebHtmlBox object. This is done with the following code enhancement.Code:{ WebProperty = True DesignTime = False } Property Integer piDocumentationId Procedure ShowDocumentation Handle hoReturn Integer iDocumentationId WebSet piDocumentationId to iDocumentationId Send Popup hoReturn End_Procedure
This concludes this twelfth blog about Visual Report Writer and the Web. There is one more blog that will show up in this serie which will deal with the HTML report supporting the onclick event. The 3.0 product will support this. We are working on its interface (the current shown way is a "hack") so this blog might take another couple of weeks before it shows up here.Code:Set pbServerOnShow to True Procedure OnShow Clear Documentation WebGet piDocumentationId to Documentation.Id Find Eq Documentation by 1 Send UpdateHtml of oWebDocumentationBox (Trim (Documentation.Value)) End_Procedure
We hope we were able to encourage you with these twelfe blogs and the demo website to get started with Visual Report Writer in the Web framework.