Archive for October, 2008

Javascript OO with Object Notation

October 29th, 2008

I’ve been digging into javascript more and more to provide a better client side user experience in my asp.net mvc applications.  To help facilitate this, I have some Html.Helper objects that accept javascript functions.

A confusing part of javascript to someone that is a novice is that javascript functions act like, ie. C# functions.  However, javascript functions are ‘objects’

Some of my initial code then is just pure functions, ie.

function  billRateError(XMLHttpRequest, textStatus, errorThrown) {
                var errMsg = "<P>Error Loading: " + XMLHttpRequest.responseText  + "<br/>";
                $("#addStatus").html(errMsg).show();
            }
function billRateSubmitting(formData, jqForm, options) {
    var loading = "<img src=’" + BuildUrl("Content/Images/spinner.gif") + "’>";
    $("#addStatus").html(loading).show("slow");
}
function billRateResponse(response, statusText)  {
        $("#addStatus").html("").show();
        $("#billRatesDiv").html(response).show();
}

Basically I’d have a page ‘BillRate.ascx’ with a corresponding javascript file ‘BillRate.js’ – sorta like a ‘code-behind’.

Within my page I have my helper helper, ie.

<% Html.jQueryAjaxOptions("addBillRateForm", AjaxDataType.html, new Hash(
   target => "’#billRatesDiv’", beforeSubmit => "billRateSubmitting",
   success => "billRateResponse", Error => "billRateError")); %>

(This helper wraps up my jQuery ajax calls)

My next line of thinking though is – ‘let’s move this to a ‘page object’ that handles all the javascript used on that page that is unique to the page.

To do this I use the following javascript OO syntax:

var billRateObj = {
    "target" : "’#billRatesDiv’",
    OnRequest : function(formData, jqForm, options) {
        var loading = "<img src=’" + BuildUrl("Content/Images/spinner.gif") + "’>";
        $("#addStatus").html(loading).show("slow");
    },
    OnResponse : function(response, statusText) {
        $("#addStatus").html("").show();
        $("#billRatesDiv").html(response).show();
    },
    OnError: function(XMLHttpRequest, textStatus, errorThrown) {
        var errMsg = "<P>Error Loading: " + XMLHttpRequest.responseText + "<br/>";
        $("#addStatus").html(errMsg).show();
    }
};

And then I update my Helper:

<% Html.jQueryAjaxOptions("addBillRateForm", AjaxDataType.html, new Hash(
   target => "billRateObj.target", beforeSubmit => "billRateObj.OnRequest",
   success => "billRateObj.OnResponse", Error => "billRateObj.OnError")); %>

I really like this better – it’s all encapsulated.

I’d like to know – is this approach a good approach ?  So far I’ve seen a bit of both.  I also have seen some articles where the programmer doesn’t put the method inside the object.  Maybe it’s my C# background, but I like that encapsulation that it provides.

Let me create some very small examples:

Hybrid Constructor/Prototype:

ie. here is a good way to use the javascript:

MyObject = function(){};

MyObject.prototype.SayHello = function(){
    alert(‘hello’);
}

what is nice here is that ‘SayHello’ isn’t created every time you create MyObject – but rather it is it’s own object (functions are objects in javascript)- and it’s attached to the MyObject. 

This does require this sort of call to it:

new MyObject().SayHello();

Object Notation:

MyObject = {
    SayHello : function(){alert(‘hello’);}
};

Then to use it:

MyObject .SayHello

Comments – recommendations?

UPDATE: Here is a jQuery ‘HowTo’s’ writeup on ‘Javascript Object Notation’ and ‘Anonymous functions‘ : both are showing the use of object notation with objects and functions.

Mozilla Prism

October 25th, 2008

Mozilla Prism, formally know as ‘WebRunner’ provides the capability to run your web application, ‘as an application’.

Prism is a simple XULRunner based browser that hosts web applications without the normal web browser user interface. Prism is based on a concept called Site Specific Browsers (SSB). An SSB is an application with an embedded browser designed to work exclusively with a single web application. It doesn’t have the menus, toolbars and accoutrements of a normal web browser. Some people have called it a "distraction free browser" because none of the typical browser chrome is used. An SSB also has a tighter integration with the OS and desktop than a typical web application running through a web browser.

(from Mozilla Wiki: Prism)

image

Prism is an application that lets users split web applications out of their browser and run them directly on their desktop.

image

image image

They are accessible with Control-Tab, Command-Tab, and Exposé, just like desktop apps. And users can still access these same applications from any web browser when they are away from their own computers.

So what browser ‘engine’ is Prism using?

Prism isn’t a new platform, it’s simply the web platform integrated into the desktop experience. Web developers don’t have to target it separately, because any application that can run in a modern standards-compliant web browser can run in Prism. Prism is built on Firefox, so it supports rich internet technologies like HTML, JavaScript, CSS, and <canvas> and runs on Windows, Mac OS X, and Linux.

Great!  Basically I can develop my application with great tools such as Firebug,  and then deploy my application to the desktop, which then helps ensure it will run as expected.  (I typically make sure my app runs on Firefox/Internet Explorer/Safari anyway).  With FireFox 3.1+ we’re going to see some great new features as well (ie. Offline support which enables web applications to provide offline functionality) – for developers see ‘Firefox 3 for Developers

At first I was trying this out with the new Google Chrome, but a bug in select / combo boxes put it on hold.  The customer basically wants to run their intranet web application in a window that is self contained, without the ‘overhead’ of toolbars, other links, etc…

So, I ran across Prism and setup my test webapp by creating 2 files:

webapp.ini

then creating a ‘zip; of the webapp.ini, naming it <yourAppName>.webapp  (for example: MyApp.webapp )

With Prism installed, you can double click on the .webapp

So, what is Prism then?

Unlike Adobe AIR and Microsoft Silverlight, we’re not building a proprietary platform to replace the web. We think the web is a powerful and open platform for this sort of innovation, so our goal is to identify and facilitate the development of enhancements that bring the advantages of desktop apps to the web platform

Ok, so that is nice, what does it get you?

It includes a simple ‘installer’ that can create all the shortcuts needed -so the user doesn’t need to know URLs.  Also, it gives the ability to control what the user can and can’t do with the browser window – for example, handling ‘forward’ and ‘back’ buttons.

(names removed for now)

image

The .ini can define these properties:

[Parameters]
id=unique-app-id@unique-author-id.whatever
uri=http://localhost/MyApp/Home.mvc
status=yes
location=no
sidebar=no
navigation=no

Here is an example dialog to create the shorcuts to your application:

image

No registry settings, etc… it’s merely creating the shell to run your web application in here.

Chrome user’s might notice – ‘hey this is already built into Chrome’ – which Mozilla recognizes that:

We’re also thinking about how to better integrate Prism with Firefox, enabling one-click “make this a desktop app” functionality that preserves a user’s preferences, saved passwords, cookies, add-ons, and customizations. Ideally you shouldn’t even have to download Prism, it should just be built into your browser. 

We’re working on an extension for Firefox that provides some of this functionality. For more information about the user experience we hope to achieve in Prism, see Alex Faaborg’s blog post.  (I like his future shot image here) For some of the technical details and new features found in Prism, see Mark Finkle’s blog post.

 

(Update : Firefox addon available)

Prism has made it easy to not need to create the .ini / .webapp – simply download and install Prism and run it.  You’ll be greeted with this prompt:

image

I like options, and this is to me, some very innovative and creative ways to run web applications from the desktop, in particular for intranet based application where you want a level of control over the browser and user experience in that environment.

 

UPDATE: http://labs.mozilla.com/2008/03/major-update-to-prism-first-prototype-of-browser-integration/

Today we’re releasing a major update to Prism that includes new desktop integration capabilities and simpler installation. With this update, you can now get Prism simply by installing a small extension to Firefox 3. With the new Prism extension for Firefox 3, users can now split web applications directly out of Firefox without needing to install and manage a separate Prism application. Just install the extension, browse to a web app, then select Tools > Convert Website to Application.

Other new or improved features include:

  • Pick an icon to represent a web app on the desktop: Prism can use the web app favicon or the user can pick a custom image to represent the web app.
  • Run each web app in its own profile: Prism now places each web app into its own process/profile so they don’t interfere with each other, which also makes it possible to install a web app twice and use it simultaneously with two different user accounts.
  • Badge the dock icon: Initial support for adding a badge to the desktop icon has been added. Currently, this can be done through a custom webapp.js file. We’re working on creating and reusing web standards to expose this to content without requiring custom scripts.

ASP.NET MVC Beta – Ajax

October 18th, 2008

I was noticing the asp.net mvc walkthrough has a section on the Beta1 ajax using the Microsoft ajax library.  Although I’m a big fan of jQuery, these two libraries now come with the framework and can be used together quite well.

In the walkthrough the code samples show a simple call to a controller which returns a string.  Let’s take that a step forward and show how it can return different types using the ‘ActionResult’.

First, make sure you include the scripts in your page – I suggest including them in the head of the master page – in the sample this is under Shared/Site.Master.

<script src="<%= Url.Content("~/Scripts/MicrosoftAjax.debug.js") %>"
        type="text/javascript"></script>
<script src="<%= Url.Content("~/Scripts/MicrosoftMvcAjax.debug.js") %>"
        type="text/javascript"></script>

 

(note: in the walkthrough, they are a bit outdated, it should now point to the Scripts folder, not the Content folder – which is what is recommended, as well as a part of the project template install)

Here is the sample – they have added this to the HomeController:

public string GetStatus()
{
    return "Status OK at " + DateTime.Now.ToLongTimeString();
}

public string UpdateForm(string textBox1)
{
    if (textBox1 != "Enter text")
    {
        return "You entered: \"" + textBox1.ToString() + "\" at " + DateTime.Now.ToLongTimeString();
    }  

    return String.Empty;
}
 

In step one of this, I’m going to go ahead and make a change – where I prefer to return an ActionResult here.

Since it’s just returning a string, we can return using ‘Content’. Here is an example:

 

image

Adding Ajax Helpers to The View

The Mvc framework comes with several new Ajax helpers, the two I’m going to use here from the walkthrough  is the Ajax.ActionLink and the Ajax.BeginForm.  There are named identical to the Html.ActionLink and Html.BeginForm (previously this was called ‘Form’ – now in Beta1 it’s BeginForm)

Let’s look at the ActionLink:

<%= Ajax.ActionLink(“Update Status”, “GetStatus”, new AjaxOptions{UpdateTargetId=”status” }) %>

By default, since the the container view is the ‘Home/Index’, it will look for the Action on the HomeController called ‘GetStatus’.  In the AjaxOptions – it is defining the target for the return of the GetStatus action. In this sample it is a span  with id of ‘status’ : <span id=”status”>No Status</span>  This can be a span, div, etc…  Since we have told ‘GetStatus’ above to return ‘Content’ – it will return a string and place the result in the span element.

I prefer the syntax for the helpers that is included in the Microsoft.  You’ll need to get this ‘futures’ assembly separately (here – you can learn more about it at the bottom of Scott Guthrie’s blog post on the beta1) and include it in the references as well as add a the following to the ‘namespace’ section of the web.config:

<add namespace=”Microsoft.Web.Mvc”/>

(personally I wish they would have just included it in the install… but you know how it is… lol)

So, for some reason they didn’t include the same syntax for the Ajax helpers as they did the Html helpers, the strongly typed ActionLink, ie. <%= Html.ActionLink<HomeController>(c => c.GetStatus(), “Update Status”)%>

This is preferred by me, hopefully they will include it, if not… well, I’ll make another post on how to build your own  :)

Let’s get back on track.

When we run the application, we will see the following:

image

Clicking ‘Update Status’ makes a call back to the Action – asynchronously:

image

What is happening is that the helper control is creating the link in the html using the asp.net ajax library, looking at the source, you’ll see the following:

<a href=”/Home/GetStatus” onclick=”Sys.Mvc.AsyncHyperlink.handleClick(this,

new Sys.UI.DomEvent(event), { insertionMode: Sys.Mvc.InsertionMode.replace,

updateTargetId: ‘status’ });”>Update Status</a>

 

Let’s take a brief look at the code here and how we can include some events to the Ajax.ActionLink,

the screenshot below shows the available ‘AjaxOptions’:

image 

Let’s add some functionality and handle the 2 most common events, the ‘OnBegin’ and ‘OnSuccess’:

 
image
 
 

The ‘OnBegin’ is going to handle the event fired before the actual ajax call is made, and the ‘OnSuccess’

will let us handle when the call is done (note: always handle the ‘OnFailure’ as well, in case of any errors!)

In my example I’m adding ‘OnRequest’ and ‘OnResponse’ – these are javascript functions, let’s look here:

 
image 

When the link is clicked, an alert box will open, when it’s done, you’ll get a second alert box. As you might notice I’ve included the ‘content’ in the OnResponse. Using Firebug, we can look at the object in detail:

 
image
 

We can see the xmlHttpRequest object and it’s request to the action ‘GetStatus’. I’m not going to go into more detail into the asp.net ajax library, but you can read more here

I should note, a good way to handle your own validation in javascript is to make validation calls in the ‘OnBegin’ – and if you want to stop the ajax call from continuing, you can return false.

So, let’s go ahead and show a similiar example with a Ajax.BeginForm, as with above, I’m converting the sample that returns a string, to return an ActionResult, using return Content(…):

image

In the view, I’m using the Ajax.BeginForm – (note that I’m wrapping it in a using statement, which I consider to be the best practice):

image

I’ve included handlers for the OnComplete, OnBeing, and OnFailure:

image

(I did manage to sneak in some jQuery goodness, using the $(“#textBox1″) to get the textBox1 element’s value)

Let’s make a minor adjustment here!  Let’s say I want to return some content, outside of ‘just a string’ ?  What I do on my project is have the ActionResult return a control.  Let’s set this up for our grand finale:

Step One:

Create a new Ajax.ActionLink: (you can do this with a form)

image

Step Two:

Create the action on the controller (home):

image

Step Three:

Create a ‘MVC View User Control’ (ascx):

image

image

Step Four:

Add some content to the control:

image

As I show, you can add a model to this control, etc… if you want to see that let me know.

Now, let’s run this add see what our result is:

We added the link at the bottom:

image

When it get’s clicked, it makes an asynchronous call, and then updating just the ‘status’ span (partial page update):

image

This is, imo, much more efficient and clean, then let’s say an ‘UpdatePanel’ in Webforms.  I have full control over the page.  The addition of the asp.net ajax libraries with ajax helpers really helps make this simple to use but extremely powerful.

Example available

The ‘Flavors’ of ASP.NET

October 17th, 2008

Back a year ago when I was preparing for my Monorail presentation at CINNUG (see Monorail: part Ipart II – in particular part II), it was greatly impressed on me that Monorail sat on top of ASP.NET, just like WebForms sits on top of ASP.NET. The key being that Webforms does not equal asp.net – WebForms != ASP.NET

ASP.NET has a great design to it, as it is a the underlying ‘pipeline’, handling the HttpRequest/HttpResponse, and all the core stuff like Authentication, Authorization, Session, Caching, etc.

WebForms, Monorail, MVC, Dynamic Data, etc… all sit on top of asp.net.  This is brilliant, as I’m able to incorporate different parts and pieces – ie. when mvc first came out, I was able to progressively upgrade parts of my webform project – in a hybrid manner.  Some pieces I didn’t really want to upgrade, as it worked fine – other parts made it cleaner and easier to test and maintain.  It made refactoring possible.

Scott Hanselman has been pushing this message, and I’m glad to see it.  In this blog post "Plug-In Hybrids: ASP.NET WebForms and ASP.MVC and ASP.NET Dynamic Data Side By Side" he outlines this:

I wanted to write this post because there seems to be a lot of confusion about how ASP.NET WebForms, MVC and Dynamic Data all fit together. Folks may have WebForms applications and want to start looking at ASP.NET MVC but aren’t sure if they need to start from scratch or not. Folks might look at Dynamic Data but mistakenly assume it’s just for scaffolding administrative sites.

You can (and should) feel free to have Hybrid applications. You can have single Web applications that have all of these inside them (if it makes you happy):

  • ASP.NET MVC
  • ASP.NET WebForms
  • ASP.NET Web Services (ASMX)
  • WCF Services
  • ASP.NET Dynamic Data
  • ASP.NET AJAX

I hope this helps and it’s more clear now that it’s just "an ASP.NET application."

You can feel free to mix and match. Not everyone can (or should) rewrite an existing ASP.NET application, so it is nice that everyone can use some new features in the same ASP.NET application as their existing functionality.

I think all of this is very interesting, and the more one grasps what ‘asp.net’ is – the best underlying of how all of these different ‘frameworks’ work.

ASP.NET MVC Beta Released

October 16th, 2008

Inching forward, the ASP.NET MVC goes beta!  So far, this framework has been great to work with!

Read up on Scott Guthrie’s blog of all the details.  Long live MVC!  :)

From Scott’s blog, a breakdown:

The ASP.NET site has resources available, including, videos, tutorials, quickstarts – and a sample storefront application

Silverlight with ADO Data Services

October 15th, 2008

This is really a fantastic union – after working through the details and binding data to a datagrid, I discovered this excellent MSDN article:

Create Data-Centric Web Applications With Silverlight 2 by Shawn Wildermuth

What is cool is that Ryan just recently sent me a link to a video by the same developer, which is pretty cool, showing off the power of ‘Blend’ (thanks again Ryan)

Rick Stahl on Client Templating with jQuery

October 14th, 2008

Rick Stahl has an excellent post on templating with jQuery

He covers:

  • Manual templating
  • jTemplate
  • John Resig’s Microtemplating engine

Silverlight 2 (Release Tommorow) – Eclipse Plugin

October 13th, 2008

http://silverlight.net/blogs/jesseliberty/archive/2008/10/13/silverlight-2-releases-tomorrow.aspx

eWeek has an article that mentions the release and our funding for an open-source project to create an Eclipse plug-in for Silverlight.  My personal opinion is I can’t imagine using Eclipse for Silverlight development on the PC given the availability of Visual Studio…. but on the Mac, if/when such a thing is available… that would be very different. (Of course, this is a personal preference)

A few guys in the SDS office will like to hear this (we have some with fruits..errrr macs that like Eclipse! Rob?)

One of these days I will dive in, I am currently reading about ‘Prism’ – in an article in the next/recent MSDN magazine, entitled ‘Patterns for Building Composite Applications with Prism’  – very cool stuff.

I hope Silverlight really takes off – the idea of building RIA with XAML and C# is great – I never got into Flash – with the tools in Studio now I think it will make for a great programming environment.

 

Update

It’s tommorow…  :)

Jesse Liberty’s Release Guide:

http://silverlight.net/blogs/jesseliberty/archive/2008/10/14/silverlight-2-release-guide.aspx

ScottGu on the release:

http://weblogs.asp.net/scottgu/archive/2008/10/14/silverlight-2-released.aspx

Silverlight Getting Started:

http://silverlight.net/GetStarted/

.NET 4 Feature Focus: Parallel Programming

October 13th, 2008

A good intro to parallel programming article:

…Microsoft is trying several different approaches in its efforts to find the right abstraction.

The first one announced was Parallel LINQ, also known as PLINQ. Like SQL, parallelization is handled by the language itself without effort by the developer. Simply tack on an AsParallel to the query and everything else just works. Well usually, but just like SQL there are times with additional options need to be specified.

More on ‘PLINQ’ can be found in the MSDN magazine article "Running Queries On Multi-Core Processors":

PLINQ is a query execution engine that accepts any LINQ-to-Objects or LINQ-to-XML query and automatically utilizes multiple processors or cores for execution when they are available. The change in programming model is tiny, meaning you don’t need to be a concurrency guru to use it. In fact, threads and locks won’t even come up unless you really want to dive under the hood to understand how it all works. PLINQ is a key component of Parallel FX, the next generation of concurrency support in the Microsoft® .NET Framework.

This is very cool!

O’s Dangerous Pals

October 13th, 2008

Close your eyes if you don’t like politics or like liberal media bias  :)

From the NY Post:

WHAT exactly does a "community organizer" do? Barack Obama‘s rise has left many Americans asking themselves that question. Here’s a big part of the answer: Community organizers intimidate banks into making high-risk loans to customers with poor credit.

In the name of fairness to minorities, community organizers occupy private offices, chant inside bank lobbies, and confront executives at their homes – and thereby force financial institutions to direct hundreds of millions of dollars in mortgages to low-credit customers.

In other words, community organizers help to undermine the US economy by pushing the banking system into a sinkhole of bad loans. And Obama has spent years training and funding the organizers who do it.

THE seeds of today’s financial meltdown lie in the Commu nity Reinvestment Act – a law passed in 1977 and made riskier by unwise amendments and regulatory rulings in later decades.

CRA was meant to encourage banks to make loans to high-risk borrowers, often minorities living in unstable neighborhoods. That has provided an opening to radical groups like ACORN (the Association of Community Organizations for Reform Now) to abuse the law by forcing banks to make hundreds of millions of dollars in "subprime" loans to often uncreditworthy poor and minority customers.

Any bank that wants to expand or merge with another has to show it has complied with CRA – and approval can be held up by complaints filed by groups like ACORN.

In fact, intimidation tactics, public charges of racism and threats to use CRA to block business expansion have enabled ACORN to extract hundreds of millions of dollars in loans and contributions from America’s financial institutions.

Banks already overexposed by these shaky loans were pushed still further in the wrong direction when government-sponsored Fannie Mae and Freddie Mac began buying up their bad loans and offering them for sale on world markets.

Fannie and Freddie acted in response to Clinton administration pressure to boost homeownership rates among minorities and the poor. However compassionate the motive, the result of this systematic disregard for normal credit standards has been financial disaster.

ONE key pioneer of ACORN’s subprime-loan shakedown racket was Madeline Talbott – an activist with extensive ties to Barack Obama. She was also in on the ground floor of the disastrous turn in Fannie Mae’s mortgage policies.

Long the director of Chicago ACORN, Talbott is a specialist in "direct action" – organizers’ term for their militant tactics of intimidation and disruption. Perhaps her most famous stunt was leading a group of ACORN protesters breaking into a meeting of the Chicago City Council to push for a "living wage" law, shouting in defiance as she was arrested for mob action and disorderly conduct. But her real legacy may be her drive to push banks into making risky mortgage loans.

 

If that sparked your interest, then…

Planting Seeds of Disaster, ACORN, Barack Obama, and the Democratic party

By Stanley Kurtz

‘You’ve got only a couple thousand bucks in the bank. Your job pays you dog-food wages. Your credit history has been bent, stapled, and mutilated. You declared bankruptcy in 1989. Don’t despair: You can still buy a house.” So began an April 1995 article in the Chicago Sun-Times that went on to direct prospective home-buyers fitting this profile to a group of far-left “community organizers” called ACORN, for assistance. In retrospect, of course, encouraging customers like this to buy homes seems little short of madness.

Militant ACORN

At the time, however, that 1995 Chicago newspaper article represented something of a triumph for Barack Obama. That same year, as a director at Chicago’s Woods Fund, Obama was successfully pushing for a major expansion of assistance to ACORN, and sending still more money ACORN’s way from his post as board chair of the Chicago Annenberg Challenge. Through both funding and personal-leadership training, Obama supported ACORN. And ACORN, far more than we’ve recognized up to now, had a major role in precipitating the subprime crisis.
I’ve already told the story of Obama’s close ties to ACORN leader Madeline Talbott, who personally led Chicago ACORN’s campaign to intimidate banks into making high-risk loans to low-credit customers. Using provisions of a 1977 law called the Community Reinvestment Act (CRA), Chicago ACORN was able to delay and halt the efforts of banks to merge or expand until they had agreed to lower their credit standards — and to fill ACORN’s coffers to finance “counseling” operations like the one touted in that Sun-Times article. This much we’ve known. Yet these local, CRA-based pressure-campaigns fit into a broader, more disturbing, and still under-appreciated national picture. Far more than we’ve recognized, ACORN’s local, CRA-enabled pressure tactics served to entangle the financial system as a whole in the subprime mess. ACORN was no side-show. On the contrary, using CRA and ties to sympathetic congressional Democrats, ACORN succeeded in drawing Fannie Mae and Freddie Mac into the very policies that led to the current disaster.
In one of the first book-length scholarly studies of ACORN, Organizing Urban America, Rutgers University political scientist Heidi Swarts describes this group, so dear to Barack Obama, as “oppositional outlaws.” Swarts, a strong supporter of ACORN, has no qualms about stating that its members think of themselves as “militants unafraid to confront the powers that be.” “This identity as a uniquely militant organization,” says Swarts, “is reinforced by contentious action.” ACORN protesters will break into private offices, show up at a banker’s home to intimidate his family, or pour protesters into bank lobbies to scare away customers, all in an effort to force a lowering of credit standards for poor and minority customers. According to Swarts, long-term ACORN organizers “tend to see the organization as a solitary vanguard of principled leftists…the only truly radical community organization.”
ACORN’s Inside Strategy
Yet ACORN’s entirely deserved reputation for militance is balanced by its less-well-known “inside strategy.” ACORN has long employed Washington-based lobbyists who understand very well how the legislative game is played. ACORN’s national lobbyists may encourage and benefit from the militant tactics of their base, but in the halls of congress they play the game with smooth sophistication. The untold story of ACORN’s central role in the financial meltdown is about the one-two punch to the banking system administered by this outside/inside strategy.
Critics of the notion that CRA had a major impact on the subprime crisis ask how a law passed in 1977 could have caused a crisis in 2008? The answer has a lot to do with ACORN — and the critical years of 1990-1995. While the 1977 Community Reinvestment Act did call on banks to increase lending in poor and minority neighborhoods, its exact requirements were vague, and therefore open to a good deal of regulatory interpretation. Banks merger or expansion plans were rarely held up under CRA until the late 1980s, when ACORN perfected its technique of filing CRA complaints in tandem with the sort of intimidation tactics perfected by that original “community organizer” (and Obama idol), Saul Alinsky.
At first, ACORN’s anti-bank actions were relatively few in number. However, under a provision of the 1989 savings and loan bailout pushed by liberal Democratic legislators, like Massachusetts Congressman Joseph P. Kennedy, lenders were required to compile public records of mortgage applicants by race, gender, and income. Although the statistics produced by these studies were presented in highly misleading ways, groups like ACORN were able to use them to embarrass banks into lowering credit standards. At the same time, a wave of banking mergers in the early 1990′s provided an opening for ACORN to use CRA to force lending changes. Any merger could be blocked under CRA, and once ACORN began systematically filing protests over minority lending, a formerly toothless set of regulations began to bite.
ACORN’s efforts to undermine credit standards in the late 1980s taught it a valuable lesson. However much pressure ACORN put on banks to lower credit standards, tough requirements in the “secondary market” run by Fannie Mae and Freddie Mac served as a barrier to change. Fannie Mae and Freddie Mac buy up mortgages en masse, bundle them, and sell them to investors on the world market. Back then, Fannie and Freddie refused to buy loans that failed to meet high credit standards. If, for example, a local bank buckled to ACORN pressure and agreed to offer poor or minority applicants a 5-percent down-payment rate, instead of the normal 10-20 percent, Fannie and Freddie would refuse to buy up those mortgages. That would leave all the risk of these shaky loans with the local bank. So again and again, local banks would tell ACORN that, because of standards imposed by Fannie and Freddie, they could lower their credit standards by only a little.
So the eighties taught ACORN that a high-pressure, Alinskyite outside strategy wouldn’t be enough. Their Washington lobbyists would have to bring inside pressure on the government to undercut credit standards at Fannie Mae and Freddie Mac. Only then would local banks consider making loans available to customers with bad credit histories, low wages, virtually nothing in the bank, and even bankruptcies on record.
Democrats and ACORN
As early as 1987, ACORN began pressuring Fannie and Freddie to review their standards, with modest results. By 1989, ACORN had lured Fannie Mae into the first of many “pilot projects” designed to help local banks lower credit standards. But it was all small potatoes until the serious pressure began in early 1991. At that point, Democratic Senator Allan Dixon convened a Senate subcommittee hearing at which an ACORN representative gave key testimony. It’s probably not a coincidence that Dixon, like Obama, was an Illinois Democrat, since Chicago has long been a stronghold of ACORN influence.
Dixon gave credibility to ACORN’s accusations of loan bias, although these claims of racism were disputed by Missouri Republican, Christopher Bond. ACORN’s spokesman strenuously complained that his organization’s efforts to relax local credit standards were being blocked by requirements set by the secondary market. Dixon responded by pressing Fannie and Freddie to do more to relax those standards — and by promising to introduce legislation that would ensure it. At this early stage, Fannie and Freddie walked a fine line between promising to do more, while protesting any wholesale reduction of credit requirements.
By July of 1991, ACORN’s legislative campaign began to bear fruit. As the Chicago Tribune put it, “Housing activists have been pushing hard to improve housing for the poor by extracting greater financial support from the country’s two highly profitable secondary mortgage-market companies. Thanks to the help of sympathetic lawmakers, it appeared…that they may succeed.” The Tribune went on to explain that House Democrat Henry Gonzales had announced that Fannie and Freddie had agreed to commit $3.5 billion to low-income housing in 1992 and 1993, in addition to a just-announced $10 billion “affordable housing loan program” by Fannie Mae. The article emphasizes ACORN pressure and notes that Fannie and Freddie had been fighting against the plan as recently as a week before agreement was reached. Fannie and Freddie gave in only to stave off even more restrictive legislation floated by congressional Democrats.
A mere month later, ACORN Housing Corporation president, George Butts made news by complaining to a House Banking subcommittee that ACORN’s efforts to pressure banks using CRA were still being hamstrung by Fannie and Freddie. Butts also demanded still more data on the race, gender, and income of loan applicants. Many news reports over the ensuing months point to ACORN as the key source of pressure on congress for a further reduction of credit standards at Fannie Mae and Freddie Mac. As a result of this pressure, ACORN was eventually permitted to redraft many of Fannie Mae and Freddie Mac’s loan guideline.
Clinton and ACORN
ACORN’s progress through 1992 depended on its Democratic allies. Whatever ACORN managed to squeeze out of the George H. W. Bush administration came under congressional pressure. With the advent of the Clinton administration, however, ACORN’s fortunes took a positive turn. Clinton Housing Secretary Henry Cisnersos pledged to meet monthly with ACORN representatives. For ACORN, those meetings bore fruit.
Another factor working in ACORN’s favor was that its increasing success with local banks turned those banks into allies in the battle with Fannie and Freddie. Precisely because ACORN’s local pressure tactics were working, banks themselves now wanted Fannie and Freddie to loosen their standards still further, so as to buy up still more of the high-risk loans they’d made at ACORN’s insistence. So by the 1993, a grand alliance of ACORN, national Democrats, and local bankers looking for someone to lessen the risks imposed on them by CRA and ACORN were uniting to pressure Fannie and Freddie to loosen credit standards still further.
At this point, both ACORN and the Clinton administration were working together to impose large numerical targets or “set asides” (really a sort of poor and minority loan quota system) on Fannie and Freddie. ACORN called for at least half of Fannie and Freddie loans to go to low-income customers. At first the Clinton administration offered a set-aside of 30 percent. But eventually ACORN got what it wanted. In early 1994, the Clinton administration floated plans for committing $1 trillion in loans to low- and moderate-income home-buyers, which would amount to about half of Fannie Mae’s business by the end of the decade. Wall Street Analysts attributed Fannie Mae’s willingness to go along with the change to the need to protect itself against still more severe “congressional attack.” News reports also highlighted praise for the change from ACORN’s head lobbyist, Deepak Bhargava.
This sweeping debasement of credit standards was touted by Fannie Mae’s chairman, chief executive officer, and now prominent Obama adviser James A. Johnson. This is also the period when Fannie Mae ramped up its pilot programs and local partnerships with ACORN, all of which became precedents and models for the pattern of risky subprime mortgages at the root of today’s crisis. During these years, Obama’s Chicago ACORN ally, Madeline Talbott, was at the forefront of participation in those pilot programs, and her activities were consistently supported by Obama through both foundation funding and personal leadership training for her top organizers.
Finally, in June of 1995, President Clinton, Vice President Gore, and Secretary Cisneros announced the administration’s comprehensive new strategy for raising home-ownership in America to an all-time high. Representatives from ACORN were guests of honor at the ceremony. In his remarks, Clinton emphasized that: “Out homeownership strategy will not cost the taxpayers one extra cent. It will not require legislation.” Clinton meant that informal partnerships between Fannie and Freddie and groups like ACORN would make mortgages available to customers “who have historically been excluded from homeownership.”
Disaster
In the end of course, Clinton’s plan cost taxpayers an almost unimaginable amount of money. And it was just around the time of his 1995 announcement that the Chicago papers started encouraging bad-credit customers with “dog-food” wages, little money in the bank, and even histories of bankruptcy to apply for home loans with the help of ACORN. At both the local and national levels, then, ACORN served as the critical catalyst, levering pressure created by the Community Reinvestment Act and pull with Democratic politicians to force Fannie Mae and Freddie Mac into a pattern of high-risk loans.
Up to now, conventional wisdom on the financial meltdown has relegated ACORN and the CRA to bit parts. The real problem, we’ve been told, lay with Fannie Mae and Freddie Mac. In fact, however, ACORN is at the base of the whole mess. ACORN used CRA and Democratic sympathizers to entangle Fannie and Freddie and the entire financial system in a disastrous disregard of the most basic financial standards. And Barack Obama cut his teeth as an organizer and politician backing up ACORN’s economic madness every step of the way.
— Stanley Kurtz is a senior fellow at the Ethics and Public Policy Institute.