Tuesday, September 23, 2008

Formatting the Address base object in XAF

By default the base address object displays the FullAddress using the format:

County + State + Street + City + Zip

If your applications are going to be used outside US probably you may want to use another format like this for Spain:

Street + Zip + City + Country

This DevExpress KB article shows you how.

In a XAF web application I do it in the Session Start event:

protected void Session_Start(Object sender, EventArgs e)
{
//...

AddressImpl.FullAddressFormat = "{Street} {ZipPostal} {City}";

}

Windows Vista and its slow start menu

I finally found why my Windows Vista Start Menu was SO SLOW. The problem is an option called "Highlight newly installed programs-OFF".

You'll find the explanation and screenshots here: Windows Vista Start Menu Too Slow? Here’s How To Make It Faster!

I've been hating Vista because of that (among others)

Today I hate Vista a little less.

Saturday, September 13, 2008

Exporting from XAF Win app to Google Earth

In a previous post I build an example showing how to seamlessly integrate a XAF Web app with Google Maps, using the Google API and a custom ListEditor.

For a Winforms application I prefer to export the information to Google Earth using a KML file because it's easier to develop and it offers a much richer experience to the user. 

The sample I'm sharing today does the following: (can be downloaded here)
  • Like in the XAF Web sample, it geolocalizes a customer main address to get it's longitude and latitude. This information is updated and persisted to the database every time the customer is saved.
  • A ViewController called "GoogleEarthController" shows an action to export either All or Selected customers.
  • Using the free and powerful Google Earth KML API for .NET 2.0 (ge-kml) it creates a temporary KML including the information from the Customer object provided by its IPlacemark interface: coordinates, a Title and a HTMLDescription used to show the nice google earth information balloons.
  • Once the KML has been generated, the XAF Application automatically opens it using Google Earth. The exported customers appears in the "Places" section.


And that's all for this basic XAF to KML exportation sample. Feedback will be highly appreciated.



Thursday, September 11, 2008

Dotnetnuke 4.9 fixes problems with Chrome

Dotnenuke 4.9.0 is now available and ships with the new and long awaited FCKEditor provider 2.0.2 which is, btw, compatible with Chrome.

Tuesday, September 9, 2008

Sample: Supply Initial Data in XAF from an Excel Sheet (without Excel)

As described here I usually like to supply some initial data to my XAF applications. However instead of manually I prefer to do it from data stored in Excel sheets because it allows me to load different sets of data for each development phase and even to migrate data from legacy applications.

Looking for a way to import data from an excel file without having Excel or the Office PIA installed on the computer, I found a very nice piece of code that loads a sheet's data into a datatable using only OLEDB.  Once the data is in a Datatable, load it into a XAF application is a piece of cake.

I prepared a basic sample, that can download here, which loads Customers (and their addresses) from a Excel File into XPO objects.

Tip: To avoid file path nightmares I normally place the excel file in at the root level of the "Module" project and configure it to be deployed to the output directory.  See the picture below.



Which technique do you use to load data into your XAF applications? Any feedback will be appreciated.

Monday, September 8, 2008

Editing shared objects (like Addresses) in XAF as non shared

If you are using the BaseImpl.Address object you'll note how, by default, XAF shows a combobox to select an address making them shared and reusable among Persons.

Usually I don't want to reuse addresses for different Persons or parties.  I prefer the MainDemo style where the addresses are not shared and where popup dialog is opened to edit an address using a button with the three dots.

The trick to change this behaviour is to modify the "PropertyEditorType" for the Address1 and Address2 properties in the Party object and use theses values:

In the Module.Win project:
DevExpress.ExpressApp.Win.Editors.ObjectPropertyEditor

In the Module.Web project:
DevExpress.ExpressApp.Web.Editors.ASPx.ASPxObjectPropertyEditor

This is how it looks like before the change (click to enlarge):

And this is after the change:


To change it, open the model in the web or win project go to the party object (or the parent object containing the addresses) and change the PropertyEditorType for the Address field. The model should look like this:



Do you know a better way to do it?

Problem with XAF updating schema in 8.2.3

If you updated XAF to the 8.2.3 release and are using SQL2000 you'll probably get the following error when updating the schema:

"Schema needs to be updated. Contact your system administrator. Sql text: Invalid column name 'dbo'."


Sunday, September 7, 2008

Sample: Displaying XAF objects on a Map

Inspired on the great "Bloggin with XAF" video tutorial I just created a sample showing how to create a custom ListEditor to display objects in a Google Map instead on the default List View.

Using the Google Maps API this sample resolves the Longitude and Latitude of all the customers and render them on a interactive map.

You can download the source code here.

This is how it looks like:



To embed the maps I used the free GoogleMaps.Subgurim.NET control which allows you to integrate a Google Maps into any ASP.NET application handling with all the plumbing for you.

This is how the sample works:
  • The "Customer" object implements an interface called "IPlacemark". This adds the Longitude and Latitude properties to the BO.
  • Every time a "Customer" is saved it contacts the Maps API to geolocalize its address. Using the street, zip code and country the Maps API returns a Longitude and Latitude. This information is stored in two custom properties.
  • A custom view called "Customers on a map" uses a custom Editor to display all the IPlacemark objects on the map.
  • I used the "ViewsVariant" module to allow the user to switch between the normal view (ListView) and the (maps View)


This sample needs to be extended to use paging, error handling, converting it to a module (eg.like the scheduler module), and resolve the address in a more efficient way (only when address changes are detected).

The sample provided uses a Google Maps API key valid for the domain http://localhost:2064. If you want to change the URL you'll need a new API Key (its free) and update the web config.

Please, drop some feedback if you find it interesting to help me improve it.