Dec
18
2010

Agile Platform 5.1.1

We’ve recently released version 5.1.1 of the Agile Platform. It’s got a lot of great new features and an improved look & feel. And better yet, it’s compatible with 5.1.0, so you don’t need to upgrade your server.

Check the post New-in-the-Agile-Platform-v5.1.1 for more info.

Aug
23
2010

Agile Platform Tips & Tricks #7

How to change the page styles dynamically at runtime

[Edit 01/09/2001: Updated the sample to also override the colors in the popups]

Service Studio gives you a few good options to define style sheets for you pages and emails. Besides the global style sheet that applies to the whole eSpace, you can add a custom style sheet to each web screen and email, and you can even define a custom style sheet for each web block. The platform will take care of including all the style sheets in the html of the page/email according to the following order:

  1. The style sheet of all the web blocks directly or indirectly included in the page/email (including referenced ones), from the inner most blocks to the outermost blocks in case of nesting
  2. The eSpace style sheet
  3. The style sheet of the web screen or email.

In web screens, all those style sheets are deployed to separate files and referenced by the page, while in emails, their content is merged together and included inline in the html for optimal display in the majority of email clients. The platform also applies some post processing to the content of the style sheets to optimize their usage in content delivery networks.

All these style sheets are statically defined at design time and can’t be dynamically changed at runtime, but it’s possible to include more style sheets at runtime that override the static ones. That allows us to do cool things like giving a specific user a different style sheet, changing the color scheme to red when some critical situation is happening, or even letting the user choose the style sheet of his preference, like this:

 image

To accomplish this, we need to do two things:

  1. Make sure the extra style sheets are deployed together with the application
  2. Manipulate the html returned to the browser to include a <link rel=”stylesheet”> tag in the <head> section

For #1, we can create the .css text files outside Service Studio and then import them as resources by using the Import Resource operation available in the eSpace tree context menu. However, that’s not a very manageable solution. An alternative way is to create a set of web blocks that we don’t use in any page, and use them just to define these style sheets. The platform will still deploy their style sheet files, even if the blocks themselves aren’t used, and we can then reference those files in the page.

For #2, the AddStyleSheetTag action from the HTTPRequestHandler extension seems an obvious choice, but that will put the <link> tag at the beginning of the <head> section. As we want our dynamic style sheets to override the static style sheets, we must include them at the end, so this option doesn’t work for us. Fortunately, we can also do this easily by using a little bit of JavaScript. For a complete example, take a look at this eSpace:

DynamicStyleSheet.oml

Aug
18
2010

Agile Platform Tips & Tricks #6

Calling Screen Actions from custom JavaScript events

Imagine you’re using the Tabs_ClientSide from RichWidgets and you’re showing a list in each tab. Instead of loading all the lists when the screen is loaded, you want to only populate each list when the corresponding tab is activated. The Tabs_ClientSide already provides a way to call custom JavaScript code on tab activation, so if we could call a Screen Action from JavaScript code, we could make that Screen Action refresh the table on the corresponding tab. So, how can we do that?

The AJAX capabilities of the Agile Platform already allow you to trigger the execution of Screen Actions when some standard JavaScript events are raised. For example, if you specify a Screen Action in the OnChange property of an Input widget, when the end-user types in something in the correspondent input displayed by the browser, that Screen Action will be called at the server. To do this, the Agile Platform generates custom JavaScript code that will send an AJAX request to the server when the native onchange event of that input HTML element is triggered. So, if we add an hidden Input widget to the page and on the OnTabActivation parameter of the Tabs_ClientSide we put some JavaScript code to trigger that onchange event manually, we know that the platform will take care of calling the Screen Action specified in the OnChange of that Input widget. This way we can put there the logic to refresh the list inside the tab that was activated in that Screen Action. Unfortunately, we have no way of telling to pass the tab which was activated as a parameter of that Screen Action, and that forces us to have to an hidden Input for each tab, and decide which hidden Input to trigger in JavaScript.

Fortunately, there’s a simpler way to do this. It involves using the OnNotify property of a Web Block widget, call it by using OsNotifyWidget JavaScript function,  and in the associated Screen Action using the NotifyWidgetGetMessage built-in action to get the tab that was activated. Instead of explaining it in detail, I’ve made a sample eSpace that exemplifies this scenario. Here it is:

FruitsAndVegetables.oml

Aug
18
2010

Agile Platform Tips & Tricks #5

When you need to change a public element of an eSpace, such as an Action or a Web Block, it’s good to know before-hand where that element is being used, so you can anticipate possible problems. To do that, you can go to Service Center and check the References tab in the page relative to your eSpace. There you will find listed all the consumers of your eSpace, and if you click on the Details links next to each consumer eSpace, you can check which specific elements are being used:

image


To help to improve this process, I’ve recently published the References Dashboard component on the OutSystems Network. It has similar functionality to this tab of Service Center, but the consumers are grouped by element instead of by consumer eSpace, allowing for faster search:

image

Mar
29
2010

Agile Platform Tips & Tricks #4


If you seen this post on the Agile Network Forums - Usability Tip (Ctrl+shift+click) - you already know a quick way to get some extra space between two elements in a flow.

From 5.0.2.9 up, there’s an even easier way: just drag the the element, and if there’s little space, the flow will be automatically arranged:

About the author

  Gustavo Guerra
  London, UK

  Software Developer
  interested in Functional Programming, Machine Learning, Robotics, and User Experience Design

Archives



Recent Comments

Powered by Disqus