Friday, June 26, 2009

Embedding Skins in CSS - Flex

For a flex application, skinning our components, is a common and a very useful way to add some zing to the application that is being built. However, care has to be taken while creating skins for our components, for it could easily shoot the size of the CSS, that is packaged with the application, resulting in somewhat higher loading times.

One such example could be that, we should not extend a UIComponent while creating skins, extend ProgrammaticSkin instead. That itself can reduce the size of the css, by around 20KB.

I'll keep a lookout for more such factors and try and post them here as soon as possible. :)

Cheers.

Thursday, June 18, 2009

FTP File Transfer - Not Logged In Exception

When I found this error, I did a google search on it and found that most of the queries have been replied as something to do with the XML data.
But then, what the heck, I don't have any XML data in my code. Very soon however, I found the answer. I was trying to set the mode for the FTP Data Transfer even before logging into the FTP Server. Changed that and everything is set right. :)

Before:


FtpClient ftp = null;
try
{
ftp = new FtpClient();


ftp.openServer(FTP_SERVER);


if (filename.endsWith(".txt") || filename.endsWith(".csv"))
{
ftp.ascii();
}
else
{
ftp.binary();
}

ftp.login(FTP_USER, FTP_PASSWORD);
if (REMOTE_DIR != null) ftp.cd("REMOTE_DIR);

// Rest Of the Code Here

}
catch (Exception e)
{
throw e;
}


After:


FtpClient ftp = null;
try
{
ftp = new FtpClient();
ftp.openServer(FTP_SERVER);
ftp.login(FTP_USER, FTP_PASSWORD);
if (REMOTE_DIR != null) ftp.cd("REMOTE_DIR);

if (filename.endsWith(".txt") || filename.endsWith(".csv"))
{
ftp.ascii();
}
else
{
ftp.binary();
}
// Rest Of the Code Here

}
catch (Exception e)
{
throw e;
}


Very simple indeed, but it did put me in a fix for a while and I found out one more thing for sure.. GOOGLE SEARCH might not be the best thing at all times. :)

Tuesday, June 16, 2009

jXls

To those who don't know, jXls is a welcome java tool (read library), for easy conversion of raw data into an excel file. Nice tool and simple to use.

One thing to take care of while using this is not to use same names for the key in your map as present in the Object fieldName or part of the fieldname.
If present, the result does not print those particular fields in the excel sheet

For those who are unclear
We were sending customer data combined with the address data for the customer. Doing something like:

private List customerL = new ArrayList();
private List addressL = new ArrayList();

private void createLists()
{
// Add all that you want to the lists.
}

private void createCustomerFile(Map beans, XLSTransformer transformer) throws IOException
{
beans.put("customer", this.customerL);
beans.put("address", this.addressL); transformer.transformXLS(this.configM.get("CUSTOMER_XLS_TEMPLATE"), beans, (FOLDER_NAME + "/" + "Customer.xls")); beans.remove("customer");
beans.remove("address");
}


My excel sample file contains fields like name, id, loginId, hobbies, customerClass [these come from customer record] and address, city, pincoce [these come from address record].

In this case the customerClass and the address fields were not populated in the result excel sheet.

The solution: simple change the Map keys: customer to customerRecord and address to addressRecord.

All solved.

For more information on jXls pleas visit: http://jxls.sourceforge.net/index.html