Skip to main content

Posts

Showing posts from October, 2012

Hands On Review : AOL's Alto Mail

I am a sucker for new online services, specially emails and when AOL announced its new offering Alto Mail, I was really excited as anything coming on the heels of Microsoft's Outlook.com with a premise of making mail arrangement a more visual affair had to be definitely worth a try. So does it really deliver the goods?


First of all let's get this straight: Alto Mail is NOT a new Email service, it is just a new web based email client which you can connect to view your Gmail/Yahoo/AOL/iCloud content. (Only Yahoo.com accounts will work, no ".co.in" or ".co.uk" or any of the other Yahoo local domain names work with Alto). Once you login to Alto with any of your above mentioned accounts, give it a few hours (well it will depend on the size of your inbox and folders) to pull in all the emails/contacts from your account. But even before the import is completed, any emails sent from Alto will reflect in your 'Sent' folder of your linked mail account.

And l…

Javascript : How to setfocus on an element created at runtime?

In my web page, I created a new row in my data table at runtime. The new row consisted of two text boxes and I needed to set focus on first text box in the row.









I got the id of the text box element by inspecting the HTML code and tried to do the following:

In java code:
inputId = ;
executeJavaScript("selectDPTypeRow('"+inputId+"')" );  

('executeJavaScript' is a custom method to execute JS code from Java code)

In JS code:
function selectNewRow(textBoxElementId){
       var textBox = document.getElementById(textBoxElementId);
       textBox.setFocus();
}

But this never worked as 'textBox' always gave null. I was baffled as to why should the element be not found in the page DOM since inputId was always correct. Later I realized that by the time the above code is called, the new elements have not yet been rendered on the page and hence the elements are not found.

To overcome this I introduced a timelag of half a second before the above code is …

Quick Java : How to remove duplicate elements from an ArrayList or Vector

There are various algorithms to do so and if you want to implement any of those you are free to do so, but if you are using java this can be done in two lines!

As you know Sets don't allow duplicate elements, so why not use this property. Convert your ArrayList (or Vector or any other Collection for that matter) to Set and convert it back to your Collection.

In below code snippet, I have an ArrayList of integers named 'listOfNumbers'.


HashSet uniqueNumbers = new HashSet(listOfNumbers);

Using HashSet will mess up the order of your elements, so if you are concerned about the order, use LinkedHashSet.

After conversion to set the duplicates are removed, convert it back to Collection object.

ArrayList listOfUniqueNumbers = new ArrayList(uniqueNumbers);
And you are done! How cool is that :)

ADF: How to remove components at run time!

In an earlier post we saw how to add ADF components in a page at runtime. It is easy enough. After some time I got a bit confused as to how to remove components, either predefined or these dynamically created components at runtime.

This is easy too and I cursed myself for getting stuck over such a trifle issue.

Let's assume that you have a panel group layout whose child components you want to remove and you have bound this panel group layout in your backing bean.

In the event handler method of the action on which you want the components to be removed, do this:

getMyPanelGroupLayout().getChildren().clear();

Simple isn't it? Since ADF exposes children of any component in form of a List, adding and removing any component is as easy as adding or removing to a list. Here I have removed all the child components of the panel group layout using 'clear()'. If you want to selectively remove components, based on id or name or any other property, you can traverse the list and rem…

ADF: Using Input Range Slider (RichInputRangeSlider)

Input Range Slider is one of the coolest components of ADF which is not only very intuitive for users but also gives a 'cool' look to the page :)



So how do we get minimum and maximum values selected on the slider?

Among other properties of this component are 'minimum' and a 'maximum' and then there is 'value'. This causes some confusion as to  how can we get the values selected on the slider. This is not half as complex as it seems!

Let's focus first on the 'value'. The value of this component is returned in form of a oracle.adf.view.rich.model.NumberRange object.

oracle.adf.view.rich.model.NumberRange minMax = (oracle.adf.view.rich.model.NumberRange)getInputRangeSlider().getValue();

You can extract both the minimum and maximum values from this object like this:


        int startValue = minMax.getMinimum().intValue();
        int endValue = minMax.getMaximum().intValue();

and that's it. You have both the values returned by the slider.

&…