Notes on Java, Solaris, PHP, LDAP…

November 17, 2007

Using Flex with Subversion on Mac OS X or Linux

Filed under: Uncategorized — negev @ 8:06 pm
Tags: , ,

4 April 07
Flex and Subversion
Flex performs SVN housekeeping even without Subclipse being installed. If you delete a directory which is SVN-controlled and it has entry in its parent directory’s .svn, then Flex recreates that deleted directory.

Also, if new MXML files were added to a project while Flex was turned off and if those files have any compile-time error, then next time Flex will be building the project it doesn’t generate any SWF and it *doesn’t* display any error.
Solution: create new empty MXML files using Flex menu; turn off Flex, copy the actual files over, turn on Flex.

Separate Flex and web folders
Because of the above issues, I’ve separated Flex folder:
1. I’ve checked out on commandline to ~/TLGM2_svn
2. In Flex I’ve created a plain Flex project under ~/TLGM2
— the project itself is local only and it isn’t SVN-controlled

3. build the project – otherwise it may not build once you add new files
4. close Flex

5.
cd TLGM2
# Following are hard-links, not symbolic links
ln ../TLGM2_svn/TLGM2.mxml

cd deploy
ln ../../TLGM2_svn/bin/TLGM2.swf

6. Start Flex, use it
7. svn on commandline under TLGM2_svn

If we go this way, then we need to adjust locations of any embedded resources. Right now I’m using the following adjustment to TLGM2.mxml:
– <mx:Button id=”showGroupButton” fontSize=”8″ width=”25″ click=”show_hide_Groups()” height=”78″ labelPlacement=”left” textAlign=”left” icon=”@Embed(‘deploy/resources/groups.gif’)”/>
+ <mx:Button id=”showGroupButton” fontSize=”8″ width=”25″ click=”show_hide_Groups()” height=”78″ labelPlacement=”left” textAlign=”left” icon=”@Embed(‘../TLGM2_svn/deploy/resources/groups.gif’)”/>

Probably rather than using ‘TLGM2’ and ‘TLGM2_svn’ it would be easier to have trunk/TLGM2 which would be checked out from SVN and trunk/Flex which wouldn’t be under SVN. Then resources would point at e.g. ../TLGM2/deploy/resources/groups.gif

This way if Flex gets better and we’ll use it direct on SVN-controlled trunk/TLGM2 rather than on non-SVN local trunk/Flex, then the resource locations would work unmodified.

I have had one issue when I modified same TLGM2.mxml in both Flex and via commandline svn. But I believe that was because I didn’t do a hard link, but I copied the file while experimenting – this way the file was duplicated rather than hard linked.

Formatting whole row in DataGrid

There are about 3 different types of specifying a renderer for a DataGridColumn:
1. Fully customized, but you need to copy and paste it for every column and to change {data.mail} appropriately:
<mx:DataGridColumn dataField=”mail” headerText=”Email Address”>
<mx:itemRenderer>
<mx:Component>
<mx:Text text=”{data.mail}” styleName=”{data.hasOwnProperty(‘is_admin’) ? ‘adminStyle’ : ” }” />
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>

2. Using a component – in this case defined in MemberRenderer.mxml – which gets instantiated behind the scenes; however it can’t be parameterized and therefore you need one component per column
<mx:DataGridColumn dataField=”mail” headerText=”Email Address” itemRenderer=”MemberRenderer” />

3. Parameterized renderer, which gets created behind the scenes via implementation (subclass) of mx.core.IFactory:
<mx:DataGridColumn dataField=”fullName” headerText=”Full Name” itemRenderer=”{new utils.MemberRendererFactory(‘fullName’)}” />

I’ve tried to somehow retrieve DataGridColumn’s dataField in the renderer object, so that we could use option (2) without using IFactory. However, the rendered components can’t access DataGridColumn.

How I’ve tried it: In renderer’s text=”{expression}” I invoked a local function, in which I called Alert.show( “parent: ” +parent.toString()+ “, owner: ” +owner.toString() ) Those showed that the parent element is ListBaseContentHolder and owner element is DataGrid.

2 April 07
Flex mx:Model – they can’t be used in initial values for variables. Use them only once the app/component was initialized – in creationComplete handler.
public var memberListData:ArrayCollection; // = new ArrayCollection( memberListModel.item ); // – this assignment fails
Flex <mx:DataGrid dataProvider=”{myDataSourceVariable}” ..> — myDataSourceVariable doesn’t need to have any initial value, then an empty DataGrid is shown
with any columns defined in its body in mx:columns
mx.Text (and its parent mx.Label) has htmlText attribute, but in order to get it used in DataGrid we need a renderer anyway

You can use any custom component for mx:DataGridColumn itemRenderer property.
If you’d like to add extra bindable variables, you define them in mx:Script within body of the component tag.

If you’re not using a custom component as a renderer, then you need to have <mx:itemRenderer><mx:Component> and the actual visible items within them, e.g. <mx:itemRenderer><mx:Component><mx:Text text=”{data.cn}” /></mx:Component></mx:itemRenderer>

Advertisements

3 Comments »

  1. You can retreive an item renderers’s parent ‘dataField’ property with the following code.

    import mx.controls.dataGridClasses.DataGridListData;
    import mx.controls.listClasses.ListData;

    var df:String = DataGridListData(listData).dataField;

    df will contain the string value provided to your datagrid/list component’s dataField attribute.

    Comment by Ben — March 4, 2008 @ 3:14 am | Reply

  2. I forgot to mention your itemRenderer will have to implement ‘IDropInListItemRenderer’ for the previous example to work correctly.

    Comment by Ben — March 4, 2008 @ 4:49 am | Reply

  3. Ben, thank you

    Comment by negev — March 4, 2008 @ 10:41 am | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: