Flex With Domino Quick Start - Part 4
Hmm. What to do now? I guess we need to make the navigation elements we added last Wednesday actually do something. This is where we go beyond the basics though, stepping outside the idea of a "quick start" and it gets a bit complicated. I should probably have thought this through before I got this far.
There are two approaches we can take here. The most obvious approach would be to somehow have the code fetch the newly-selected view -- both its design and its data -- each time a different view is selected. This seems to be the goal of any Notes developer adapting to a new web framework -- Ext.nd have done it with Ext and it's already been done with Flex by FlexDomino.net. In both cases you select a view and it fetches the view's design and data as two separate requests and then re-builds the view on the fly.
That's all very clever (and useful if you want to quickly migrate a many-viewed database to the web) but it's not the only way to tackle things. Let's look at a way of just re-displaying the data we already have. What if we could categorise the existing data on any "field" it contained without needing to fetch anything back from the server?! Flex can do this.
Let's see an example first. Either look at the updated demo for this "series" of posts and click the "by something" links on the left or (if you're feeling underwhelmed by that) try the updated accounts.nsf which I've been working on in the background and click the "group by category" checkbox above the view.
In the both cases notice that there's no request sent to the server! How cool is that!?
To do this the first thing you need to do is switch from using a DataGrid to using an AdvancedDataGrid. Nothing tricky in that, but it does mean you'll need the professional version of Flex Builder, which is nearly three times the price of the standard version ($700 rather than $250). It's worth it for the advanced grid alone, but you also get the charts with the pro version. When combined, both features were enough to convince me to part with the extra cash.
Unfortunately I don't really have the time to talk about the code involved in categorising a previously flat "datagrid". Let's just say there's not really much to it (10 lines of code). You can see how it's done by right-clicking the demo and viewing the source. Look inside the treeItemClicked function.
Hopefully what this has shown is that you can do things differently sometimes. Although there's a big assumption in this case -- that you've already loaded the whole view. If you've only loaded the first 30 entries of the flat view then the categorised version you build might not tell the whole story!
Again it all comes down to the situation at hand, as to how you'd deal with it. It's just that it always seems to be assumed that all you want of a web-enabled Notes database is an exact copy of the client version in every way. Is that really always the case?
Whether I take this "quick start" series of posts any further I don't know yet. What do you think? Hopefully by now it's shown the power of Flex and how simple it is to achieve tangible results. Is there anything else you want to see added/tackled?
I love the flex tutorials you've posted. Hopefully it will result in more Flex/Domino awareness. I personally would love to work on Flex/Domino apps, but it doesn't currently fit into any of my projects.
I don't know if you've mentioned it, but have you used it in any real-world applications?
Did you feel the platform was limiting in any way?
How RAD is Flex compared to ExtJS?
The updated accounts.nsf in this article is pointing to
http://www.codestore.net/apps/account.nsf/
instead of
http://www.codestore.net/apps/accounts.nsf/
Please correct the link
Thanks Nagarajan. Fixed now.
Tommy. Yes, I've been using on actual applications for paying clients (I wouldn't be able to justify the $750 otherwise!). None that I can show here though, unfortunately.
Flex and ExtJS aren't even in the same league of RADness. For me at least. With ExtJS it's RAD until you get stuck and then I find it very nonRAD. The fact that Flex has a WYSIWYG IDE makes it RADder on its own.
I am yet to find a limitation of Flex!
I get the following when trying to view source:
Http Status Code: 404
Reason: File not found or unable to read file
Am I doing something wrong?
Thanks
David
No David. My fault. Looks like the view source URL is relative. My link to the app opened "/apps/flex.nsf" whereas it should have opened "/apps/flex.nsf/". Add the slash and it will work.
Hi Jake,
First at all congratulations for this magnific help!!
Can you hide elements like fields, buttons based on lotus domino roles?
Thank in advance!
You don't want much do you Aritz? ;o) Leave it with me and I'll make that the next Flex quick start post.
Jake... great work. I would like to see your source for creating the document in the account application. I have not tried to create a document yet with Flex.
Aritx / Jake... once the user logs in, couldn't you call an HTTP service that calls a Notes Agent that prints XML with the Effective User Name (run as web user) and inside the agent do an x = Evaluate(|@UserRoles|) and return formatted XML to show the user name and roles?
Hi Jake,
Check out our domino based app....found here:
http://flexingdomino.blogspot.com/
covers login, roles, events, event dispatch etc...
fairly comprehensive app w/ domino
cheers,
Mark
How about a reporting (charts) quick start post Jake? All great stuff - you have me inspired. Am trying to squeeze as much time as I can playing with Flex.
Hey -- put a multi-billion dollar company behind ExtJS like Adobe, and I'm sure they could come up with a GUI for you. :P
Last I heard, they're going to have a pretty good version of exactly that with ExtJS 3.0 when it comes out.
Great stuff Jake. Since you askedI would like to see some charting examples using Domino data. That kind of eye candy always sells management!
I'll try and cover that too Curt. There's an example in the account.nsf db, which I'll make an updated version available to shortly.
In the line below: is"selectedNode.@categoryField" a string? I am trying to duplicate your example, but I am hard coding the GroupingField. It blows up.
group.fields = [new GroupingField(selectedNode.@categoryField)];
Thanks, David
Hi David,
Yes, it's a string. The selectedNode corresponds to the <node> from the XMLList used to render the tree. See further down the MXML something like this:
<mx:XMLList id="xmlNavElements">
<node label="Cars">
<node label="By Engine Size" categoryField="size" />
The categoryField is a attribute of the node I made up. You can add any you like and then reference them as node.@myMadeUpAttrribute
So, in this case it would be something like "size" or "manufacturer". The important part is that these "map" to the names of actualy XML "fields" in the data of the dataProvider to the grid.
Hope that makes sense?
Jake
What version of Flex Builder are you using? I copied your source and ran it in Flex 3. The original grid loads, but I get an action script error when it is time to group the grid.
Same version as you by the sounds of it David
Had to update Flex 3.02. This is great stuff Jake.
Thx, David.