Yep, thats true. But the case which i am handling is something like this

1. We need to create the view component on the fly based on the HttpService
response.
2. The response from the HttpService will be an XML file and that will have
the details of how the view component should be framed.
3. So, I decided to write a response render action script, which can parse
the XML response and create the components on the fly. Now, that i created
the component, I need to add event listeners to the dynamically created
components. Event, should ofcourse will be traversed via the Event
Dispatcher in the Cairngorm.
4. As you suggested, I created the Dto object and linked it to the event.
Now, i wasnt sure of how to bind the dynamically created controls to the
event, so that the user interactions are recorded.

5. So, what i thought is to bind the whole form and assign the form
reference to the event.data instance.

I think i confused you even more.. let me know if you need more detailed
explanation.

Here is the response render.as file

package com.anf.chr.model
{
    import com.adobe.cairngorm.control.CairngormEventDispatcher;
    import com.anf.chr.events.HomePageEvent;
    import com.anf.chr.events.submitFormDataEvent;

    import flash.events.Event;
    import flash.events.MouseEvent;

    import mx.containers.ControlBar;
    import mx.containers.Form;
    import mx.containers.FormItem;
    import mx.containers.Panel;
    import mx.controls.Button;
    import mx.controls.TextInput;


    public class ResponseRender
    {
        [Bindable]
        private var modellocator:ModelLocator = ModelLocator.getInstance();

        [Bindable]
        public var currentForm:Form;


        public function ResponseRender()
        {
            //TODO initialize the components (if any)
        }

        public function renderData(responseData:XML):void
        {
             //Attributes common to most of the form types.
             var formType:int;
             var pnlForm:Panel;
             var frm:Form;
             var vFormItem:FormItem;
             var fi:Object;

             var btnSubmit:Button;
             var btnCancel:Button;
             var vTextInput:TextInput;
             var cb:ControlBar;

            // Creates the main Panel
            pnlForm = new Panel;
            pnlForm.layout = 'absolute';
            pnlForm.percentWidth = 100;
            pnlForm.percentHeight = 100;
            pnlForm.title = responseda...@header;

            // Creates the main form
            frm = new Form();
            pnlForm.addChild(frm);
            frm.percentWidth = 100;
            frm.percentHeight = 100;

            formType = responseda...@type;

              for each (var prop:XML in responseData.detail.formitem)
               {
                fi = new Object();
                fi.type = pr...@entrytype;
                fi.label = pr...@label;

                //entryType = pr...@entrytype;

                switch (formType)
                {
                    case 0: //Simple Form
                        vFormItem = new FormItem();
                        vFormItem.label = pr...@label;
                        var s:String =  vFormItem.label;
                        vFormItem.visible = true;
                        vFormItem.required = pr...@required;
                        frm.addChild(vFormItem);
                        vTextInput = new TextInput();
                        vTextInput.id = pr...@name;
                        vTextInput.text = "";
                        fi.object = vTextInput;
                        vFormItem.addChild(vTextInput);

                        //Adds the attributes to the object dynamically

                        //testobj[pr...@label] = vTextInput.text;
                        //a.addItem(testObj);

                        cb = new ControlBar();
                        btnSubmit = new Button();
                        btnSubmit.label = "Submit";
                        cb.addChild(btnSubmit);

                        btnCancel = new Button();
                        btnCancel.label = "Cancel";
                        cb.addChild(btnCancel);


btnSubmit.addEventListener(MouseEvent.CLICK,postForm);

btnCancel.addEventListener(MouseEvent.CLICK,cancelForm);

                        pnlForm.addChild(cb);

                        break;

                    case 3: // Home Page Form
                        vFormItem = new FormItem();
                        imgForm = new Image();
                        imgForm.percentHeight = 100;
                        imgForm.percentWidth = 100;
                        imgForm.x = 0;
                        imgForm.y = 0;
                        imgForm.scaleContent = false;
                        imgForm.source = responseda...@img;
                        fi.object = imgForm;
                          break;

                    }
                }
            currentForm = frm;
            modellocator.currentState  = pnlForm;
        }

        private function postForm(event:Event):void
        {
            var evnt:submitFormDataEvent = new submitFormDataEvent();
            evnt.data = this.currentForm;  // here is where i am assigning
the form reference to the event data.
            CairngormEventDispatcher.getInstance().dispatchEvent(evnt);
        }

        public function cancelForm(event:Event):void
        {
            var homePageEvent:HomePageEvent = new HomePageEvent();

CairngormEventDispatcher.getInstance().dispatchEvent(homePageEvent);

        }
    }
}

- Many thanks for your reply.


On Tue, Mar 24, 2009 at 1:58 PM, Vaibhav/Steve <seth.vaibhav...@gmail.com>wrote:

>
> Hi Veena,
> As per Cairngorm, command should not contain the view's refrence.
> All you need to do is that fill the event.data with FormVO's object,
> where FormVO will contain the properties required to fetch from the
> form and then dispatch the Cairngorm event.
>
> : Vaibhav
>
> On Mar 24, 7:46 pm, Veena <veenachezhia...@gmail.com> wrote:
> > Hi Guys -
> > I have been developing a component in Cairngorm Framework and there is
> > case where i have to pass the form (reference) to the event data and
> > access the form elements to retrieve the user entered data.
> >
> > Can anyone help me doing this..
> >
> > //event.data has the reference to the View Form. This form has many
> > form items in them.
> > var frm:Form = event.data;
> >
> > I need to iterate thro' the 'frm' form object and access the form
> > elements so that I can retrieve the user entered value.
> >
> > Thanks!
> > Veena
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to flex_india@googlegroups.com
To unsubscribe from this group, send email to 
flex_india+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to