Wednesday, October 7, 2009

Spring effect for validation.

Recently I played around with the Spring effect developed by Chet Haase. After small modifications I have used it to highlight mandatory fields (or form items - Last Name) in the form.
Also in the Status label you could place some more additional information.

2 comments:

  1. Hi Denis,

    I am interested to see your source code how you do display validation result information not in tooltip area, but at fixed area at the top of the screen.

    Would like to compare with my own solution.

    ReplyDelete
  2. Here is my class StatusLabel (http://www.fileden.com/files/2009/9/27/2586671/StatusLabel.mxml). There is public property called message which is an array.
    Also I have a convention that first element always should be a message for user and second element is a type of your message, for example, informative message or warning.

    How to is it:
    Just place it wherever you want and link this component to the source of your messages, source should be type of array, not initialized and make it bindable. It could be some variable in the model or in the singleton class.

    [Bindable]
    public var statusUpdatesMessages : Array;

    local:StatusLabel top="10"
    horizontalCenter="0"
    message="{ statusUpdatesMessages }"/>

    And everytime time you need to display a message, just do following:

    statusUpdatesMessages = ["Please specify your First Name."];

    or if you want to display a warning message:

    statusUpdatesMessages = ["Internal server error. Please try again.", StatusLable.WARNING];

    That's my solution. Could you share your solution?

    PS There is one warning in the StatusLabel class, it is complaining about binding and square bracket operator, but it is working fine with bindable event on getter method.

    ReplyDelete