Showing posts with label flex 3. Show all posts
Showing posts with label flex 3. Show all posts

Thursday, March 17, 2011

Some Reading Materials

Since the last time I've posted anything, I ordered three books, "Flex on Java", "Flex 3 Bible", and "Flex and Java integration Bible".

I am almost through the first book, "Flex on Java." It isn't for starters as it isn't teaching you and code but how to use FlexMOJO and the Maven plugin. This book also covers the MVP (model, view, presenter) architecture.

I haven't finished the book yet, so I can't give a complete overview of it yet. As soon as I near finish, I will try to post more about it.

Thanks.

Tuesday, December 21, 2010

Flex 3: two way binding with value objects

Today at work I was working with a VO and I didn't want to code an update function to update my VO every time there was a change. I feel like that extra function and calling updateVO all over the place looks sloppy.

What I ended up doing was inside my action script file I created a bindable instance of my VO.

[Bindable]
public var exampleVO:ExampleVO = new ExampleVO();


For the mxml file I ended up doing this.

<mx:binding source="txtFname.text" destination="exampleVO.fname">
<mx:binding source="txtLname.text" destination="exampleVO.lname">
<mx:Vbox>
<mx:Hbox>
<mx:label text="First Name:">
<mx:textinput id="txtFname" text="{exampleVO.fname}">
</mx:Hbox>
<mx:Hbox>
<mx:label text="Last Name:">
<mx:textinput id="txtLname" text="{exampleVO.lname}">
</mx:Hbox>
</mx:Vbox>

I had to be placed bindable tags at the top of page inside of the main tag. I set my bindings right after where I created my remote object.

That is how I did my two data bindings and I'm sure there are some other ways but this was the easiest for me and for what I was working on.

I did try to set the bindings with just AS3 using the BindingUtils.bindProperty() but I couldn't get it to work. I think my problem was that I didn't set it up to go both ways, so I might have to come back to that and try it.

Thursday, December 16, 2010

Flex 3 ObjectUtil.copy()

So the other day at work, I was working with a datagrid whose data provider was an arrayCollection that was holding a list of VO's. What I wanting to do was edit the selected VO in another component.

What I was doing was passing the VO into the component like:
exampleComponent.exampleVO = arrayCollectionExample[dataGrid.selectedIndex];
This was doing what I wanted, set the component VO to the selected VO. Worked great.

Now the problem I ran into was when I updated the VO and an error occurred. Although it wasn't updating in the database, the datagrid was updated. The item was binded I believe.

To corrected this I found this ObjectUtil.copy().
exampleComponent.exampleVO = ObjectUtil.copy(arrayCollectionExample[dataGrid.selectedIndex]) as exampleVO;

It worked for me and there was no more binding to the data grid. :)