CForm SWC

Lately I have been getting a lot of mails about using CForm. So, I kind of wrapped up the whole thing into a SWC and here it is. So all you need to do is download this and add this to the Lib of your project. For the source code, you can still check it out of SVN. But, to just use the CForm, you really do not need the source-code, you can just use this swc component. Click here to download the component.

Advertisements

[Component] CForm v1.0

CForm is all about creating data entry screens. This component allows developers to create standardized forms/CRUD screens in their applications. The CForm component is a Data Entry component that can be very useful if –

  1. you are building business applications with many data entry/view screens
  2. you are working with a lot of developers. each handling separate screens/modules
  3. you wish all your screens to have the standard look & feel across the application
  4. you wish to avoid different developers/designers designing their own UI/UX paradigms for their specific screens

Let me try to explain this in a very simplified manner. CForm reads XML file to create user entry forms. To implement CForm, the following steps are involved.

  • Developer creates XML file for each screen. The XML will contain the list of fields, controls to be used etc.
  • CForm is called in an MXML.
  • Now, the developer can use many of CForm’s exposed methods to access/manipulate data in the CForm.

The Demo walks you through a few use cases of how CForm can be used in real world. There are clear instructions on each example in the demo. For a detailed documentation on the XML part of this component, check out here and for the AS and MXML angle check out below. The source code will also be made available shortly in a 2 or 3 weeks. As of now, if you need the source code you will have to check it out from the SVN repository at http://flexedtoolkit.googlecode.com/. If you like this component and would be willing to extend a helping hand, send me a mail πŸ˜‰ .

If you have any questions/suggestions after viewing the demo, leave a comment on this page!!

**Update: Compiled SWC now available for download.

[ SWC | Demo | XML Documentation | Source of Example ]

Read more of this post

CustomGrid v1.2

I am releasing the v1.2 of CGrid. It’s been in drafts for a long while now.This time, a few more basic niceties have been added to the CGrid. πŸ™‚

  1. Export to Excel (Copy selected rows or entire grid to clipboard and paste in excel)
  2. User can select columns to view and width of the columns etc. This setting for each grid in the application is remembered across sessions.(For this to work properly, you will have to ensure that you always specify a distinct ID for for each grid in your application.) This feature is very useful, if you are fetching a lot of columns to display but are not sure whether all the users would be interested in all the columns. Now, the user can choose to see columns of his/her choice and that choice is remembered across sessions.
  3. Fixed the sorting logic in the column sort.
  4. The CGrid can now take in custom itemRenderer from the caller.

Check it out… πŸ™‚ For more details about what CGrid is all about, check out this post.

It’s been a long time since I updated the grid component. Hey, for that matter… It’s been a log while since I last posted here. πŸ™‚ Been quiet a bit busy lately. Anyway, am almost back. This month is also going to be a bit hectic. But, I hope to post regularly from September onwards.

Note: Thanks to all who downloaded CGrid v1.0 and used them in their projects. It really feels nice to see that the component has served some good purpose. The CGrid component is individually responsible for keeping my blog alive andΒ  bringing in readers even though I haven’t posted anything new for the last couple of months. So, this component is kind of the ‘old man’ of this blog. Anyway, Lemme thank all visitors for checking it out. Keep downloading. Keep leaving comments πŸ™‚ ….

[ Demo | Source | Sample Printout ]

Flexedtoolkit Google project

WANTED: Developers who can contribute to this open source initiative πŸ™‚

I have created a google project to put in some of the stuff that we have been working on and releasing through this blog. Some of the stuff that you can already download from Flexedtoolkit are –

  1. Autorefresher
  2. Client Idle Timeout
  3. Custom Alerts
  4. Custom Grid

I am working on a small component – CForms. The idea is to have a generic UI rendering engine that will create forms from an XML file. This is particularly useful in serious business applications where you have a lot of user entry screens. So, if the developer needs to have a screen, they just include something like –

<widgets:CForm controlsFile=”controls.xml” id=”VLAN”/>

Everything else – Styles, layout, look and feel etc. will be handled by the CForm component as per instructions in the abc.xml… Getting a picture?

We initially did this as part of my project requirements at work. And it was a life-saver. Now, I would like to extend it beyond what it is today. I want to make it more generic and feature rich so that others can leverage on it.

The project homepage is http://code.google.com/p/flexedtoolkit. If you are interested in joining the project, do leave a comment. πŸ™‚ Really hope some of you folks would find time to work on this.

Autorefresher Component

If you have been working on applications which serve highly dynamic data on the screen, you are most likely to have had to rely on the “polling” mechanism to get updated data from the back-end. We had similar requirement in our project and we created a tiny component using Flex’s Timer Class to fire a specific method at set frequencies.

And as usual, we didn’t to go around writing code all across the application to do this. The component we created can take in a function as an attribute. This function could be anything. It could be one that fires an SQL query and updates an ArrayCollection, or it could be one that sends out a Feed request or whatever! πŸ™‚ It’s pretty easy to use the AutoRefresher. All you have to do is add the AutoRefresher to your view –

<flexed:AutoRefresher id="exampleAutoRefresh" delay="5000" refreshFunction="FunctionToBeFiredPeriodically" />

The view then, refreshes every x milliseconds specified for delay. The default is 15000 milliseconds or 15 seconds. In the init method of your view, before starting the autorefresher, set the owner of the refresher to the parent like this-

exampleAutoRefresh.owner = this;
exampleAutoRefresh.start();

Setting the owner is to make sure that our refresher stops and starts based on the views visibility. In most cases, Polling mechanism ends up being really costly on the back-end. Especially if you are dealing with multi-tiered architecture and trying to talk to a web server, database server etc over the network. And its very much possible, that multiple views in your application might be required to autorefresh periodically. If you are polling in all the screens whether they are required or not, you are most likely to end up crashing the back-end infrastructure. In order to address this problem and minimize the load on the back-end, we built in a mechanism into the refresher by which it stops if the view is visible and starts automatically when the view is visible. This is why we are setting the owner in the init method. So, if you have autorefresher running on view A and B; and the user is viewing view B, then only view B is refreshing and when the user moves to view A; view B stops refreshing and view A starts.

Special thanks to Easwar for making this idea work! This component might come in handy for many πŸ™‚ . It sure saved a lot of effort for us πŸ˜‰ . Check it out.

Note: The demo is very basic. All it does is gets the time every 3 seconds and updates the label in the view.

[ Demo | Source | ASDocs ]

Client/User Idle Timeout Component

I was looking around in the net for an effective client/user IDLE TIMEOUT mechanism. My requirement was very simple – The UI should time-out if the user is idle for more than 5 minutes. In geek terminology, IDLE translates to zero keystrokes and zero mouse movements.

After googling around and then spending some time at Flexcoders, I came across a link from the CFML site – an example for just what I wanted to do πŸ™‚ . So, we went and took that script and added a few bells and whistles to it before converting it into a re-usable component. And here’s what we have :-

The ClientIdleTimeOut component can be added to an application using-
<flexed:ClientIdleTimeOut id="TimerId" onTimeOut="FunctionPassedFromCaller" listenKeyStroke="true|false" listenMouseMove="true|false" timeOutInterval="1" confirmInterval="1" />
Now, when the application starts, the timer starts. If there is no user activity for the timeOutInterval specified, then a timeout warning pops up and stays up for confirmInterval time. Once the confirmInterval has been crossed, the application is timedout. At this point, three actions happen – 1. The application is disabled; 2. The FunctionPassedFromCaller set to the onTimeOut attribute is fired; 3. An event of type appTimedOut is dispatched. We can have a listener for this event and fire our actions at this point apart from the onTimeOut function.

So, thats what the ClientIdleTimeOut does πŸ™‚ . Check it out. Enjoy

PS: The Demo has an idle timeout for 3 mins. and a warning prompt of 2 mins. The ASDocs provided is more of an experiment πŸ˜‰ .

[ Demo | Source | ASDocs ]

Passing unlimited arguments to a function

I recently stumbled across Flash Extensions which specializes in Flash Training & Solutions. There I found a few video tutorials and thats where this comes from πŸ˜‰

Here’s how you can pass unlimited arguments to a function. πŸ™‚ Flex Developers from the C++ and Java worlds might be familiar with this. Yet, this could be new stuff for some. The most common method used to pass multiple arguments to a function where the number of arguments are not predefined is to pass the arguments as a complex object like Array or something.


private function normalUsage(list:Array):void{
Alert.show(list.join(":"));
}

The other better way to handle this is something like this. Use “…args” in the function and then you can pass any number of arguments. –

private function dataToPop():void{
newUsage(1,2,3,5,6,7,8,9,10);
}


private function newUsage(...args):void{
Alert.show(args.join(":"));
}

Try it out. This could be useful at many places. πŸ˜‰