logo

Flex With Domino Quick Start - Part 2

Back to the simple application I started building yesterday. Let's take it a bit further and add some more elements and lay them out like a more normal application -- header, navigation and main content area. This is the layout of the app.

First we'll create the header area. To do this we'll drag an <mx:VBox> element in to the design area and give it a width and height of 100%. The VBox is a layout element which stacks its child elements vertically. We're going to add two <mx:HBox> elements as direct children of it. The HBox does the opposite and arranges its children horizontally.

Using these two layout containers it's a doddle to do what with HTML is often a frustrating nightmare. Consider the code below:

ScreenShot001

First we have a VBox. Consider this a bit like a "container" DIV that takes up the whole page. Inside it are two HBoxes. Consider these as being like two rows of a table. Anything we put in these "rows" will be arranged horizontally, just like TD table cells would be.

The really clever bit with Flex is the way it works out sizes. Notice that the first HBox (the "header" area) has a fixed height of 60 pixels. But the HBox below it has a height of 100%. How can that work!? Don't the two conflict? Well, no. Flex is intelligent about it and makes the second HBox equal to the full height of the browser minus 60px. As you resize the browser the header's height remains fixed as the region below it resizes to take up the remaining height.

The same happens with widths. Notice I've added an <mx:Tree> element as the first child of the second HBox. This is our "navigation" area. It has a width of 25% while the DataGrid to the right of it has a width of 100%. Again Flex knows the second element should just take up all of the remaining horizontal space. We could just as well have made the width of the grid 75% but I wanted to make a point.

That's all you have to do for the layout! Yep, no CSS required. Just a few width and height settings and you've created a cross-browser (all Flex apps are by nature anyway) layout that adjusts to the browser size and looks something like this:

 ScreenShot002

How simple was that!?

Now let's look at another really nice element -- <mx:Spacer>. Let's say we want to add a "Login" button to the right-most side of the header area. To do this with HTML and CSS involves understanding the intricacies of floating elements. Not so Flex. Consider this code:

ScreenShot003

We've added two new elements to the header - a <mx:Spacer> and a <mx:LinkButton>. Again we've given an element a width of 100% but Flex knows not to take this literally. It knows we merely want it to take up all the space not taken up by the other elements it's in line with. In this case it pushes the login button to the very right of the screen.

Notice also that I've told the HBox that makes up the header to align child element in the middle of it. The result looks something like this:

ScreenShot004

You can see the end result here. Still nothing fancy, but, hopefully, you're starting to see how easy Flex makes things?

Your challenge for today is to take the updated source dode (right-click the demo app and "View Source") and compile it in Flex Builder. Then update the NSF I made available yesterday with the new SWF. Do it!

More tomorrow...

Comments

  1. Great tutorial but do you really think Domino is a good datastore for Flex? It is not easy to secure xml Views, you will fight with Non-Summary data (although Rich Text is now possible with ?OpenField). Not that I am all against Domino but for example MySQL seems to be a much better fit in this case and it removes many limitations that you will approach with Domino.

    • avatar
    • Jake Howlett
    • Tue 27 Jan 2009 05:10 AM

    Hmm, yes and no. Don't know. Who knows? Horses for courses and all that. Don't really want to get in to it at this point. Whether Notes is suitable is down to a per-app decision.

  2. Henning,

    I would say Domino is a great fit for Flex. Why would you secure XML views?

    If security is an issue wouldn't you just use Readers fields etc?

    The same constraints and advantages that apply to a standard Domino application apply here, just the UI is different & better.

    Mark

    • avatar
    • Rishi
    • Tue 27 Jan 2009 06:25 AM

    @Henning, Being a Lotus Notes Developer, got an opportunity to develop few workflow apps in MySql+PHP . I will tell you its reall pain, the day I realise no one can beat LN for workflow apps.

    Suppose in PHP apps, You have a data grid (like notes view) where few docs should be visible/hidden based on roles and many more hide when which we often do in LN web apps easily. Everytime on the page load you need to query a database to find who logs in and accordingly do you action. In Domino all is built in, its less time consuming and fast.

    • avatar
    • Jono
    • Tue 27 Jan 2009 06:41 AM

    Hey Jake - I am following the 'quick start' - great work by the way. I am now wanting to get the login button to work.... I will await Part 3 :)

    • avatar
    • Jake Howlett
    • Tue 27 Jan 2009 06:48 AM

    Cool. Glad somebody is Jono. You might have to wait for part 6 or 7 before we get that advanced though. You can see the login button at play in the DEXT demo though: www.codestore.net/apps/dext.nsf/flex

    Let me know if you want the source for that...

    • avatar
    • Jono
    • Tue 27 Jan 2009 07:08 AM

    Hey Jake, Source would be great thanks - I've added my email to this post. I was trying to get an existing database of mine displaying in the 'Flex view' and I kept getting a bizarre Flex error saying I need to close my tags... I validated my XML view via tinternet site and it was fine... I then realised my DB had Anonymous - No Access. The <br> tags must be in the login page (session based). I've since allowed Anonymous for testing and it works a treat. Does your DEXT demo use session based auth or not?

  3. Sorry I did not want to provoke anything. I am just curious why people reduce Domino to its nsf storage engine and for example use xml views to filter information. Reader fields for example are not easy with xml views because the most common practice with readviewentries is to use anonymous access.

    If you look at it from a positive side. I am just looking for valid points to keep using Domino because the trend to use different technologies is there, at least here in my region (South Bavaria, Germany). Sorry again, I keep calm now.

    • avatar
    • Palmi
    • Tue 27 Jan 2009 08:28 AM

    Great work but how do you find time ? Are your not loaded with projects all day , - boy am lucky to get 4 hours a week in doing "my stuff" between my domino work and my 4 kids (1,6 to 20 years old ) - keep up the hard work Jake.

    • avatar
    • Jake Howlett
    • Tue 27 Jan 2009 09:32 AM

    I wonder myself sometimes Palmi. I'm lucky at the moment as I'm being paid to do some Flex work and so I can justify the learning time I'm spending on it.

    This blog entry itself took about 30 mins to write this morning as I drank my wake-up cup of tea.

    It can be hard to find the time though. Hence there was no entry on codestore last week!

  4. Jono... you can get a login embedded in your HTTP Service Call to not have to open Anonymous (at least while you are testing...)

    Instead of calling the HTTPService Send on the creationComplete... call a function you write that will add parameters to your HTTPService call. One of the parameters will be to use the RedirectTo option, which will be your call to whatever creates the xml for you, be it a view or an agent.

    I've included the basics below...

    <mx:Application

    xmlns:mx="http://www.adobe.com/2006/mxml"

    layout="absolute"

    creationComplete="{prepareData()}"

    height="618">

    <mx:HTTPService id="yeardata" url="http://myserver/mydb.nsf?login" showBusyCursor="true" />

    <mx:Script>

    <![CDATA

    private function prepareData():void

    {

    var params:Object = new Object();

    // params.count = '-1';

    params.username = "Troy Robinson";

    params.password = "passwordhere";

    params.redirectto = "http://myserver/mydb.nsf/ForFlexTesting?OpenAgent&reporttype=Year"

    yeardata.send(params);

    }

  5. Hey Jake,

    I also like "Jono", I will await Part 3 to keep learning.

    Thanks

    Great tutorial ! !

    • avatar
    • Rob
    • Tue 27 Jan 2009 11:23 PM

    Dear Henning,

    I don't think anybody here got worked up over your questions and I like it when the pros and cons are discussed.

    The Notes security model is the most complete and robust of any I've ever used. If anything needs securing I use reader fields; one of the most powerful and flexible features in Notes. We the proper application of reader fields there is really no need to secure views. On the other hand, if you do need security, securing the views is not enough. You've got to add reader fields.

    The thing that opened my eyes about reader fields was when I discovered that you can put roles in them. I almost never put individual names in them any more. I use groups and apply the role to the group in the ACL. I have a whole infrastructure build up around roles, groups, the ACL and reader fields. I use it for everything even down to my navigator links and workflow control. You only see the navigator links that match the roll(s) you have and the workflow step in force at the time.

    All of this will work just fine with Flex because all magic happens on the server before the documents are exposed in any view.

    It's the front end of Notes that's falling behind. The back end still rocks!

    Thanks Jake. I plan to try this out.

    Peace,

    Rob:-]

    • avatar
    • Jono
    • Wed 28 Jan 2009 04:25 AM

    Rob --> Agree with everything you've said. It's just a shame that my company is looking to move away from Domino. They just don't understand that it IS and probably always will be the best collaboration software around and to do what Domino does in anything else (M$) will just cost a fortune and take three times as long.

    Ah well, that's entirely different discussion for another blog I guess...

  6. Ron, thank you for taking the time to answer my question. I will be following the tutorial with interest.

    • avatar
    • Aritz
    • Fri 6 Feb 2009 11:35 AM

    Jake,

    Excellent work!!!!!! :-)

    One question more.. is there any possibility to hide at all the the "add new car" button?

    Thanks!!!!

    • avatar
    • Jake Howlett
    • Fri 6 Feb 2009 12:34 PM

    Hi Aritz,

    Yes. Easy peasy. Instead of using the "enabled" property use the "visible" property. So it would be:

    <mx:Button visible="{condition in here}" label="...

  7. Just thought I would share a laugh. I get online with IBM support about an issue I am having with LEI. (Lotus Enterprise Integrator). When I ask the support person for help on LEI... they ask me, "What is LEI?"

    Nice support IBM.

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Tue 27 Jan 2009

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content

[