Saturday, July 25, 2009

"Databinding will not be able to detect assignments to ..." AGAIN - Arrrggghh

Ok, I've finally decided on a wiki package and have been able to get back to programming.

I keep running into this warning message "Databinding will not be able to detect assignments to {some variable name}" Since I am new to Flex and all the books seem to show the syntax I am using is right I have been baffled over this for some time. All the google research I have done says I should add the [Bindable] metadata tag to my variable declaration. The problem is, I did, and it still didn't work. Well I am hear to say I FINALLY understand how to fix this. Here is what I am talking about:

I have the following value object class:
public class LoginVO {
public var username: String;
public var password: String;

public function LoginVO(){
}
}
I used this in the following mxml:

<?xml version="1.0" encoding="utf-8"?>
<mx:vbox mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" label="Login" creationcomplete="init()">
<mx:script>
<![CDATA[
import com.bmast.model.vo.LoginVO;
import com.bmast.BudgetMasterConstants;
[Bindable]
public var loginVO:LoginVO = new LoginVO();
private function init():void{
loginVO.username="user";
loginVO.password="";
}]]>
</mx:Script>
<mx:form labelwidth="150">
<mx:formitem required="true" label="Username">
<mx:textinput id="loginTI" text="{loginVO.username}">
</mx:formitem>
<mx:formitem required="true" label="Password">
<mx:textinput id="passwordTI" displayaspassword="true" text="{loginVO.password}">
</mx:formitem>
<mx:formitem>
<mx:button id="loginButton" label="Login" click="dispatchEvent(new Event("try_login",true))"/>
</mx:formitem>
</mx:form>
</mx:vbox>

I could never understand why I got this warning on the two TextInput fields and databinding didn't seem to work. FINALLY, I have realized the problem. The issue is I have set the [Bindable] metatag on the variable in the mxml (like I was supposed to) but what I didn't realize is that the binding I am trying to accomplish has to be on the attributes of that variable as well, so they have to have the [Bindable] tag on them as well. So to fix the warning and get the binding to work properly all I had to do was add the [Bindable] tag to my value object's class declaration and that makes the internal fields of the class "bindable" the compiler is happy and data binding now works in the mxml file like I had hoped. One more rung in the climb out of "Flex novice mode" accomplished.

Here is the new code for the value object:

[Bindable]
public class LoginVO {
public var username: String;
public var password: String;

public function LoginVO(){
}
}

Thursday, July 23, 2009

Configuration and Wiki's

I really hate it when system configuration gets in the way of programming. I've read several books that have recommended using a personal wiki to capture all of your thoughts. And I actually set one up a few years ago, but the data got stale as I didn't keep it up. So when I got my new 64 bit quad core computer, I decided it was time to restart a wiki.

My desire was to keep the deployment fairly simple and use technologies I knew or wanted to learn. That seemed like a simple enough task, so last Friday I looked up "Wiki" on wikipedia and took a look at their comparisons.

My criteria was it had to be either Ruby or Java based, since I already knew those environments and the goal of this effort was to get going quickly, not learn a new technology. It had to use MySQL as the database, since I already had that installed and had backup routines for it. Finally, it had to be simple to install. My main goal was to get a wiki running so I could capture all the is "yellow sticky notes" I had scattered on my desk and in some sort of meaningful way.

I should also note, at my work I use strictly Windows and run a personal wiki there for work stuff only. This has turned out very helpful as I am a big proponent of the "Getting Things Done" process (look up GTD if you don't know what this is) and a wiki fits real well in that method of organizing.

Sooo, one would think that it wouldn't be that hard to set up a wiki server at home. Boy was I wrong. Here it is almost a week later and I have just finally got back to working on my current Flex project.

Anyway, I narrowed down the choices to XWiki Workspaces, instiki, and JSPWiki.
I first tried to get instiki running as it is a Rails based wiki and I knew that would be the easiest. Well out of the box it worked great, except that it defaulted to using SQLite. SQLite is a file based database, and I wanted to only have to maintain one database in a central location. My database of choice is MySQL, mostly because I learned that one first, (Oh and it is free). So I found on the instiki site instructions for setting up MySQL. I configured my database.yml file as recommended and launched the app. Nothing happened.

It was supposed to deploy the database automatically. Ok, duh, I needed to setup the database in MySQL first. So I went back and did that, launched the app again and again nothing happened. After poking around a bit more I realized I needed to use their run script not the normal "ruby script/server" command. Again it failed. Ok, so I must need to migrate the database first. So I ran "rake db:migrate" restarted the application, and again nothing.

Note, when I say nothing, what I mean is no tables were created even though the app came up and seemed to be happy. Also keep in mind that each time it failed, I had to do some serious googling and to try to understand what I should have been doing. So this "quick" project was turning into a bit of a monster.

I ended up poking around in the db directory and I couldn't understand why I got a sqllite_development file (that is the file for the development environment). But this was the clue I needed.

It turned out what was happening was when I ran the instiki startup script it was starting in production mode. That makes sense now, and I guess if I had looked at the log closer . . . Anyway, when I ran the "rake db:migrate" task even though I had set the RAILS_ENV environment variable to be "production" the rake task was using "development" as the default. Soooo, after more googling, I found out what I should have been running was "rake db:migrate RAILS_ENV=production". Once I did that, things began working.

That was Friday's effort (5 hours shot).

On Saturday it was XWiki's turn. It requires an app server. But comes with a prepacked version. So I tried that first. Nope didn't work. Did I mention I was running a 64-bit machine. Incidentally, 64-bit machines come with 64-bit binaries and more importantly a 64-bit jdk.

Not to worry, I've used JBoss before so I figured I'd just load that up and drop the war version of XWiki into the deploy directory and off I go. So I dutifully loaded up the latest version of JBoss, (5.1.0). Nope, class not found exceptions. Google, google, google.

Ok, finally, even though I didn't like it, it felt like I needed to drop back to JBoss 4, since that's what the install documents recommended. So I grudgingly loaded up JBoss 4.2.3. Being a geek at heart, I feel on my home server I want to be little more on the cutting edge than normal. My mistake. Since it had been a while since my last JBoss project (4 years), I had to relearn how to setup the datasource. But by Sunday I finally had XWiki running. . . locally. Next I had to make it available globaly. I'll leave that to a future post.

Sunday, July 19, 2009

Introduction

I've been told the best way to learn something is to do it, and then write about it, so that's the point of this blog.

Particularly I intend to write about my journey with programming technologies I use or am learning, projects I am building and systems I work with. This will primarily include my experiences with Java, Ruby, Flex, Windows and Linux, as these are the technologies I have chosen to spend my time on.

I am by no means an expert in any one of these, but have been in this field for many years and (as any IT worker does) I find I have to keep up my skills, even if it at times is frustrating, hopeless, and aggravating. Occasionally, we get lucky and something works like it was originally designed.

I hope to document my accomplishments and struggles in these very broad areas over the course of time

That was where I found myself at 1:30 this morning trying to install my third option for a personal wiki on my brand new 64 bit Fedora Core 11 machine. And that was after about five hours of messing with it prior to that. So that's where I will begin with my next blog entry.