How to plan your own tour-My Experience

Who don’t like traveling! 🙂 I love traveling. I won’t mind, spending my rest of life just visiting new places. 🙂

When we (me and my friend Ashwini) thought of going on a tour, first thing came in our mind was budget. We started exploring package tours, which in my opinion were bit expensive. So we dropped that idea and planned our trip ourselves. I would like to share my experience of the same.

I was living in Bangalore city at that time and one of my friend and I decided to go on south tour instead of visiting our hometowns during Diwali vacations. Package tours arranged by travel companies were not in our budget. So we decided to plan on our own. Only two of us were going on a vacation, so obviously had to convince our families.

Next step was to Google and decide visiting places. So we picked up few places from south India, we listed those. We had around 10 days in our hand. First thing we did was to book a train to and from for our first day and last day of tour. Then next thing was to arrange in between destinations as per traveling time. So, where ever it was possible to have a overnight journey , we did not plan for halt. This saved us few bucks as there was no need to book a hotel. On the other hand where overnight journey was not possible we booked hotel. We booked hotel from Bangalore itself and two months in advance. We paid via checks and asked explicit confirmation over mail from respective hotel admins to avoid last minute chaos. Again Google helped us to find hotels in our budget.

So hotel booking and train ticket booking for first and last day , were the two things we did on priority , two months in advance. Now next question was how to plan in-between traveling. We decided we will do it on run-time. Because based on local conditions, we could have booked auto or hire a car or go with local package tour as per our convenience and budget!

So all set to go and we had a wonderful tour of South and Kerala. 🙂

Places visited:

1. Madurai- Meenakshi temple.

2. Trivendrum(Thiruvananthapuram) : Padmnabhswamy temple, Kovalam beach

3. Munnar: Tea gaurdens, Mattupetty lake and dam

4. Thekkady: Periyar National Park

5. Alappey: Backwater safari

6. Cochin: Antique market, beaches.

And many more…. I have snaps but those are not digital… 🙂 but will post if possible..

Food:- We prepared some food items which we could eat for two days. We also tried lot many local south Indian dishes.

I will never forget experience of trying out a fish dish which we actually did not try and left without trying it 🙂 .

What we learned/gained from this tour:

1. Planing :- considering our budget, risk factors as only two ladies, weather at that time , which places to visit in night and which one during day time.

2. Confidence : yes it is possible to go on your own and have safe travel.

3. Decision making: Where to spend extra , where to save, what to avoid be it hotel or destination in our list, Shopping which is generally weak point of ladies 🙂

4. Adjustments: Since two of us sharing hotel rooms, food etc, ( we both are different in nature) She was very talkative and I am a bit shy. :-). She preferred to go for Spa and I decided to go for jungle walk. So we adjusted accordingly and manged to go on with other tourists.

5. Life is beautiful : It gave us different perspective about life. Life is as beautiful as God’s own country – Kerala 🙂

This travel gave me lot of confidence and I never hesitated to go on my own when I went abroad. I will cherish those moments forever.

Next time I will share my first experience of traveling in Germany.

Until then keep jaunting. 🙂

Custom Console in Eclipse RCP Application

I was working on RCP application and there was a requirement to customize the console view by removing PIN Console, Open Console toolbar buttons.

Let’s learn today how we can do so.

First create a RCP application using Mail Template.

Then create an extension for “org.eclipse.ui.console.consolePageParticipants”.

extension

PageParticipant

This class implements IConsolePageParticipant and override method init()

Now get reference to toolbar manager in console view and remove unwanted buttons.

IPageSite pageSite = page.getSite();

IWorkbenchPage workbenchPage = pageSite.getPage();

IViewPart viewPart =

workbenchPage.findView( IConsoleConstants.ID_CONSOLE_VIEW );

IViewSite viewSite = viewPart.getViewSite();

IActionBars actionBars = viewSite.getActionBars();

IToolBarManager toolBarManager = actionBars.getToolBarManager();

IContributionItem[] contributionItems = toolBarManager.getItems();

contributionItems = toolBarManager.getItems();

toolBarManager.remove( contributionItems[5] );

toolBarManager.remove( contributionItems[6] );

toolBarManager.remove( contributionItems[7] );

 

This will remove Pin Console, Display Selected Console and Open Console buttons from the toolbar in console view.

There could be better way of removing tool bar buttons from console view but this is what I know so far.

Complete source code for this example can be found here.

Internationalization with Wicket

In last article we discussed  how to localize mark-up files in wicket. It would be very annoying having 14 different html files if we have 14 different languages that we should support for that particular page/component.

In this article we are going to learn how to use resource bundles instead of localizing mark-up files. Imagine your application contains so many texts that need i18n. In this situation it is very difficult to put a wicket:id on all of these, and then add a Label to each.

Wicket provides a simple way to provide i18n support for your applications.

You can use the wicket:message element in the HTML file directly

<wicket:message key=”staticMessage” >Message</wicket:message>

The property files are

DisplayPage.properties:

staticMessage= Message

For Germany

DisplayPage_de.properties:

staticMessage= Nachricht

For Netherland

DisplayPage_nl.properties:

staticMessage= Bericht

The key “staticMessage” is used to lookup the message in the property files. The default text Message is used when the message could not be found. Wicket framework provides getString(String key) method in Component class which search for a property by given key in resource bundles.

Localized pages and panel can have their own bundle files having as base name the class name of the related component and placed in the same package.

So in our example we have DisplayPage.java class. We have created our resource bundles based on name of this class for. E.g DisplayPage_de.properties. Note all these resource files are located in same place where out DisplayPage.java class resides.

Alternatively if you want to use text from properties file in wicket components like labels etc. simply use getString(“key”) method provided by Component class in wicket.

How lookup algorithm works:

Wicket will search all resource files with the names equal to the components in your component hierarchy, starting from application level at top to component defaults as a last place to look.

So when Wickets wants to look up a message used in MyPanel, where MyPanel is contained within MyPage, and the application is called MyApplication,

Wicket will look in:

  1. MyApplication_locale.properties, …, and then MyApplication.properties (..)
  2. MyPage_locale.properties, …, and then MyPage.properties
  3. MyPanel_locale.properties, …, and then MyPanel.properties

And what if it has same key in all these hierarchy properties files?

The lookup algorithm gives priority to the bundles of the containers (parents) of the component that is requesting a localized resource. The more a container is higher in the hierarchy, the bigger is its priority over the other components. In other words properties inside the resource bundle of a page will have the priority over the properties with the same key defined in the bundles of children components.

So for example in our sample code if we have HomePage which is container for DisplayPage, have a property with same key i.e. staticMessage with some other value in its resource bundle then it will be displayed instead of property in DisplayPage resource bundles. HomePage.properties staticMessage= Title Message.

So here text “Title Message” will be displayed instead of DisplayPage.

Also note that for DisplayPage component DisplayPage.properties is a default resource bundle.

So for e.g. your locale is set to “de” and there is no resource bundle for that locale (DisplayPage_de.properties is missing) then lookup algorithm will fall back to default resource bundle in this case DisplayPage.properties

To display languages like Chinese, Japanese etc, which need UTF-8 encoding you need to just append resource bundles with .utf8.properties extension.

Finally how to change locale?

To manually switch the locale in wicket:

Session.get().setLocale(new Locale(Locale.GERMAN));

Isn’t it pretty easy to i18n wicket applications. 🙂

A complete source code for sample example could be found here.

Localizing markup files in apache wicket

In this article we are going to see how we can localize markup files in wicket with an example.

We will be using DropDownChoice from previous article “Customizing display of choice in apache wicket”.

We need to create different markup files for different locale settings. All files have following format for naming.

YourFileName_<language code>[ <COUNTRY_CODE> ].html

Note <COUNTRY_CODE> could be optional.

So here is an example for markup file for displaying content in Chinese language.

LocaleSpecificPanel_zh_CN.html

<html xmlns:wicket=http://wicket.apache.org&#8221;S>

<head>

<meta http-equiv=“Content-Type” content=“text/html; charset=UTF-8”/>

<title>TestForm</title>

<link rel=“stylesheet” type=“text/css” href=“style.css”/>

</head>

<body>

<wicket:panel>

歡迎來到中國

</wicket:panel>

</body>

</html>

In similar way we have to create markup files containing text in that particular language.

When the current locale is set to country China(language code zh_CN), markup file LocaleSpecificPanel_zh_CN.html will be used in place of the default one.

Complete source code for above example could be found here.

In next article we will see how to internationalization works in wicket. This time we will create separate resource bundles (.properties) files instead of markup files.

Customizing display of choice in apache wicket.

Many times we come across a requirement where we need to bind a key-value pair to a Drop Down component. i. e. we need to customize dropdown choice to show some display values and upon selection of that value we need to use key (some other value) for some business logic.

Let’s see how we can bind a key-value structure i.e. HashMap to a DropDownChoice component in wicket.

In this example we are going to bind a key value pair for Locale-ID and Country with DropDownChoice. i.e. we are going to display different countries in drop down and based on selection of country we will set Locale.

So first we will create a HashMap for holding key-value pairs of locale-id and country.

Map<String, String> localeMapTemp = new HashMap<String, String>();

localeMapTemp.put(“en_US”, “United States”);

localeMapTemp.put(“de_DE”, “Germany”);

localeMapTemp.put(“nl_NL”, “Netherlands”);

localeMapTemp.put(“zh_CN”, “China”);

Now we will create a helper class which will hold the above key-value pairs for the DropDownChoice.

public class SelectOption implements Serializable {

/**

*

*/

private static final long serialVersionUID = 1L;

private String key = null;

private String value = null;

public SelectOption(String key, String value) {

super();

this.key = key;

this.value = value;

}

public String getKey() {

return key;

}

public void setKey(String key) {

this.key = key;

}

public String getValue() {

return value;

}

public void setValue(String value) {

this.value = value;

}

}

We need to create a DropDownChoice object.

DropDownChoice<SelectOption> localeChoice = new DropDownChoice<SelectOption>(“dropDwonChoice”,

new PropertyModel<SelectOption>(localeModel, “selectedLocale”),

getLocaleList(),

new ChoiceRenderer<SelectOption>(“value”, “key”)){

/**

*

*/

private static final long serialVersionUID = 1L;

@Override

protected boolean wantOnSelectionChangedNotifications() {

return true;

}

@Override

protected void onSelectionChanged(Object newSelection) {

selectedLocale = ((SelectOption)newSelection).getKey();

super.onSelectionChanged(newSelection);

}

};

Now let’s understand all attributes of DropDownChoice constructor in above code snippet.

  1. First argument is id of choice element in html markup.

<select wicket:id=“dropDwonChoice”>

<option value=“en”>English</option>

<option value=“de”>German</option>

</select>

  1. Second argument i.e. new PropertyModel<Object>(localeModel, “selectedLocale”), in above code represents model object SelectOption helper class. Model class for your page in which drop down is added must use SelectOption.
  1. Third argument returned by getLocaleList() a list of SelectOption objects.

Note that the type of object returned by the model in second argument and the type of objects in the list in third argument must be the same, in this case SelectOption.

  1. And last argument is The ChoiceRenderer will use the value of the ‘key’ property of SelectOption object in the ‘value’ attribute in the rendered HTML (e. g. ‘key’ property value will be used as the option id). The ‘value’ property will be used as a display value for the given option.

If you want to customize further the values rendered in option then use your own customized choice renderer.

For e.g. if you want to use something like value-key (“German-de”) as display value in above example then you can write your own ChoiceRenderer.

class CustomChoiceRenderer implements IChoiceRenderer<SelectOption> {

/**

*

*/

private static final long serialVersionUID = 1L;

@Override

public Object getDisplayValue(SelectOption object) {

return object.getValue()+”-“+object.getKey();

}

@Override

public String getIdValue(SelectOption object, int index) {

return object.getKey();

}

}

Complete source code for above example can be found here.