Saturday 17 November 2012

Implementing Multi select component using Palette in Tapestry5

Yes it's tough if you try to implement Palette  or multi select component in Tapestry5. I learned it the hard way, so thought of sharing it.
The example provided by Tapestry is using enum object. Practically we may need to create Select lists for any type of Object.  Here find some sample code of one implementation for a users list



First the AssociateUsers.tml



Page Bean

@AuthorizePage
public class AssociateUsers extends SessionContextPageImpl {

    @Inject
    private ComponentResources resources;
    private int selectedButton;
    @Persist
    private List users;
    @Persist
    private List initialAssociatedusers;
    @Inject
    private Messages messages;
    @Inject
    private TypeCoercer typeCoercer;
    @Inject
    private SelectModelFactory selectModelFactory;
    @Property
    @Persist
    private int staffUserId;
    @Property
    @Persist
    private SelectModel userSelectModel;
    @Inject
    private FriendManager frndMgr;
    @Inject
    private UserManager userMgr;
    @InjectPage
    private UserDashboard userDashboard;
    @Property
    private FullUserProfile userProfile;
    public static final int SELECTED_BUTTON_CANCEL = -1;
    public static final int SELECTED_BUTTON_SUBMIT = 1;

    @Override
    public void onActivate() throws Exception {
        super.onActivate();
        super.canLoadPage(this.getClass());
    }

    public void onActivate(int staffUserId) throws Exception {
        this.staffUserId = staffUserId;
        userProfile = userMgr.getUserProfileOfInvestor(staffUserId);
        setupRender();
    }

    public List getUsers() {
        return users;
    }

    public void setUsers(List selected) {
        users = selected;
    }

    public SelectModel getUserModel() throws Exception {
        return userSelectModel;
    }

    public void onSelectedFromCancel() {
        selectedButton = SELECTED_BUTTON_CANCEL;

    }

    void setupRender() throws Exception {
        users = new ArrayList();
        initialAssociatedusers = frndMgr.getPeopleListMutualFollowersForUser(staffUserId, getCurrentFirmId());
        // invoke service to find all users in the firm
        List usersSelectlist = frndMgr.getPeopleListByFirmId(getCurrentFirmId());
        //add alredy associated users to list
        for (FriendProfile profile : usersSelectlist) {
            if (initialAssociatedusers.contains(profile)) {
                users.add(profile);
            }
        }
        //remove present Assign user from list
            for (FriendProfile profile : usersSelectlist) {
                if (profile.getUserId() == staffUserId) {
                    usersSelectlist.remove(profile);
                    break;
                }
            }
        // create a SelectModel from my list of users
        userSelectModel = selectModelFactory.create(usersSelectlist, "FullName");
    }

    @SuppressWarnings("unchecked")
    public UserValueEncoder getUserEncoder() {
        return new UserValueEncoder(typeCoercer, FriendProfile.class, frndMgr);
    }

    public Object onSubmitFromAssociateUsers() throws Exception {
        switch (selectedButton) {
            case SELECTED_BUTTON_CANCEL:
                return userDashboard;
            default:
               //your code based on the selected users
...........................................
                return userDashboard;

        }


    }
}


New Encoder class for your object. In my case it's a user object


public class UserValueEncoder implements ValueEncoder, ValueEncoderFactory{

    @Inject
    private FriendManager friendMngr;

    @Override
    public String toClient(FriendProfile user) {
        return String.valueOf(user.getUserId());
    }

    public UserValueEncoder(TypeCoercer typeCoerce, Class obj, FriendManager friendMngr) {
        this.friendMngr = friendMngr;
    }

    @Override
    public FriendProfile toValue(String id) {
        try {
            return friendMngr.getFriendProfileByUserId(Integer.parseInt(id));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public ValueEncoder create(Class type) {
        return this;
    }

}

App Module changes


 public static void contributeValueEncoderSource(MappedConfiguration                                                    ValueEncoderFactory> configuration) {
        configuration.addInstance(User.class, UserValueEncoder.class);
    }


If you have any questions...please post it as comments.

Ajith.




Thursday 6 September 2012

Idea Cellular Kerala Customer care and contact numbers for service, complaints, prepaid and postpaid plans.


Idea Cellular Kerala Customer care and contact numbers for service, complaints, prepaid and postpaid plans.
Kerala – Idea Cellular
Customer Care | queries | Complaints | Activation – Deactivation Service |
4th Floor, Mercy Estate, Ravipuram. Cochin, Kerala - 682015
Contact No - 98470 12345 (Postpaid) 98471 12345 (Prepaid)
Fax - 0484 - 2382 121 / 2382 324
Email - ccare.kerala@idea.adityabirla.com
Idea Grievance :  grievance.kerala@idea.adityabirla.com 
Incase if your complaint is not redressed to satisfaction, you can escalate the complaint to Idea Nodal Officer.
Idea Kerala
Nodal Officer
IDEA Cellular Limited, Mercy Estate, 3rd Floor, Ravipuram, M G Road, Cochin- 682015
Contact No - 91 9656006680
Fax -
Email - grievance.kerala@idea.adityabirla.com
Still the complaint not resolved, there is an option to escalate the complaint to concerned Appellate Authority
Idea Kerala 
Appellate Authority
IDEA Cellular Limited, Mercy Estate, 3rd Floor, Ravipuram, M G Road, Cochin- 682015
Contact No - +91 9656006690
Fax -
Email - appellate.kerala@idea.adityabirla.com 
Other income keywords: Idea 3G, Idea nodal officer, Idea download, Idea sms, Idea mms, Idea number portability, Idea offers, Idea roaming, international calling, international sms enquiry, activation, queries and complaints.

Tuesday 24 July 2012

Err in favor of users



Andy Hunt and  Dave Thomas  once wrote a debit card transaction switch. A major requirement was that the user of a debit card shouldn't have the same transaction applied to their account twice. In other words, no matter what sort of failure mode might happen, the error should be on the side of not processing a transaction rather than processing a duplicate transaction. So, they wrote it on their shared whiteboard in big letters: Err in favor of users.


It joined about half-a-dozen other maxims. Jointly, these guided all those tricky decisions you make while building something complex. Together, these laws gave our application strong internal coherence and great external consistency.

Source -Dave Thomas, The Pragmatic Programmers

Wednesday 18 July 2012

Don’t follow the leader



Marketers (and all human beings) are well trained to follow the leader. The natural instinct is to figure out what’s working for the competition and then try to outdo it – to be cheaper than your competitor who competes on price, or faster than the competitor who competes on speed. 

The problem is that once a consumer has bought someone else’s story and believes that lie, persuading the consumer to switch is the same as persuading him to admit he was wrong. And people hate admitting that they’re wrong.
Instead, you must tell a different story and persuade listeners that your story is more important than the story they currently believe.

If your competition is faster, you must be cheaper. If they sell the story of health, you must sell the story of convenience. Not just the positioning x/y axis sort of “We are cheaper” claim, but a real story that is completely different from the story that’s already being told.

Inspired by(Getting Real 37signals.com)

Saturday 26 May 2012

How to handle a new feature request for your product?



The most common problem with product development / maintenance is on how to handle a new feature request for your product.

37signals.com answers this in the book "Getting Real"
The goal is to minimize the number of features and to make the features we choose to build, perfect ones.

For every new feature you need to...
1. Say no.
2. Force the feature to prove its value.
3. If “no” again, end here. If “yes,” continue...
4. Sketch the screen(s)/ui.
5. Design the screen(s)/ui.
6. Code it.
7-15. Test, tweak, test, tweak, test, tweak, test, tweak...
16. Check to see if help text needs to be modified.
17. Update the product tour (if necessary).
18. Update the marketing copy (if necessary).
19. Update the terms of service (if necessary).
20. Check to see if any promises were broken.
21. Check to see if pricing structure is affected.
22. Launch.
23. Hold breath.

What you guys think about this approach?

Friday 30 March 2012

സന്തോഷകരമായ കുടുംബ ജീവിതത്തിനു, ചില മാര്‍ഗരേഖകള്‍

Got this as an Email forward...funny!!

സന്തോഷകരമായ
 കുടുംബ ജീവിതത്തിനുചില മാര്ഗരേഖകള്‍...

1. 
ഭാര്യയെ 'എടി', 'നീഎന്നൊ...ക്കെ വിളിക്കുന്നതിനു പകരം 'കുട്ടാകുട്ടാഎന്ന് മാത്രമേ വിളിക്കാവൂസംതൃപ്ത ദാമ്പത്യത്തിനുശ്രീമാന്‍ കാലച്ചന്ദ്ര മേനോന്‍ എഴുതിയ 'ഏപ്രില്‍ പതിനെട്ട്എന്ന മനശാസ്ത്ര നോവലില്‍ ഇത് പരാമര്ശിക്കുന്നുണ്ട്.


2. 
രാവിലെ എഴുന്നേറ്റു പല്ലുപോലും തേയ്ക്കാതെ ഇഡലിയും ചമ്മന്തിയും അടിച്ചു കേറ്റുമ്പോള്‍ 'കുട്ടാ എന്നെവിളിക്കാതിരുന്നതെന്താചട്ടിനിയ്ക്ക് തേങ്ങ ഞാന്‍ തിരുമ്മി തരുമായിരുന്നല്ലോഎന്ന് പറയുകനിങ്ങള്‍ യഥാര്ത്ഥത്തില്‍ തേങ്ങതിരുമ്മേണ്ട യാതൊരു ആവശ്യവുമില്ലപൊട്ടിയായ ഭാര്യ  കമെന്റു കൊണ്ട് തന്നെ ത്രിപ്തയായിക്കൊള്ളും.

3. 
പത്രം വായിക്കുമ്പോള്‍, മുഴുവനും പേജും ഇറുക്കിപ്പിടിചോണ്ടിരിക്കാതെ  മെട്രോ മനോരമയുടെ പേജെങ്കിലും ഭാര്യയ്ക്ക്കൊടുക്കുകരണ്ടു മിനിട്ട് കൊണ്ട് വായന കഴിഞ്ഞു തിരിച്ചു കിട്ടുംഇല്ലെങ്കില്‍, ' വീട്ടില്‍ എനിക്ക് പത്രം പോലുംവായിക്കാന്‍ കിട്ടുന്നില്ലഎന്ന് തുടങ്ങുന്ന ഒരു രണ്ടു മണിക്കൂര്‍ വഴക്ക് പ്രതീക്ഷിക്കാം.

4. 
സത്യസന്ധതയ്ക്ക് ദാമ്പത്യ ജീവിതത്തില്‍ വലിയ പ്രാധാന്യമില്ലഭാര്യുണ്ടാക്കിയ കാശ്മീരി ചില്ലി കൊപ്പെന്‍ ചിക്കെന്വായിവെക്കാന്‍ പോലും കൊള്ളില്ലെങ്കിലും  കാര്യം മിണ്ടിപ്പോകരുത്‌. നിങ്ങള്ക്ക് തീരെ കഴിക്കാന്‍ സാധിക്കുന്നില്ലെങ്കില്‍ 'ഇത്ഞാന്‍ പൊതിഞ്ഞു ഓഫിസില്‍ കൊണ്ടുപോകാംസുഹൃത്തുക്കള്ക്കും നല്കാമല്ലോഎന്ന് പറയുകഓഫിസിലേക്കുള്ള വഴിയില്ഇത് ഭാര്യയറിയാതെ കളയാംഅതല്ലഇനി നിങ്ങള്ക്ക് ഇഷ്ടമില്ലാത്ത ആരെങ്കിലും ഉണ്ടെകില്‍ ഇതെന്റെ ഭാര്യയുണ്ടാക്കിയകാശ്മീരി ചില്ലി കൊപ്പെന്‍ ചിക്കെന്‍ ആണെന്ന് പറഞ്ഞു അവര്ക്ക് കൊടുത്തേക്കുകഭാര്യയേയും പ്രീതിപ്പെടുതാം,പ്രതികാരവുമാകാം.

5. 
ഭാര്യ തടിച്ചു വീപ്പക്കുറ്റി പോലെയാനിരിക്കുന്നതെങ്കിലും, 'കുട്ടാ നീ വല്ലാതെ മെലിഞ്ഞു പോയിഎന്നിടയ്ക്കിടെ പറയുകതാന്കെട്ടിയവനെക്കാളും തടിച്ചുവെന്ന തോന്നലുള്ള ഭാര്യമാര്‍ കൂടുതല്‍ കുടുംബ വഴക്കുകള്‍ ഉണ്ടാക്കുന്നവരാനെന്നു തെളിഞ്ഞിട്ടുണ്ട്.


6. 
നിങ്ങള്‍ പരീക്ഷയ്ക്ക് പഠിക്കുന്ന കൊണ്സേന്ട്രെഷനില്‍  പി എല്‍ കാണുമ്പോള്‍ അവള്‍ ഓഫിസിലെ കണകുണ കാര്യങ്ങള്പറയുകയാണെങ്കില്‍ 'നീ ഒന്ന് ചിലയ്ക്കാതിരിക്കാമോഎന്നാവരുത് നിങ്ങളുടെ പ്രതികരണംപറയുന്ന കാര്യങ്ങള്ക്ക് നിങ്ങള്മറുപടി പറയണംന്ന് ഭാര്യയ്ക്ക് ഒരു നിര്ബന്ധവുമില്ലെന്നു മനസിലാക്കുകഇടയ്ക്കിടയ്ക്ക് മൂളിക്കൊടുതാല്‍ ധാരാളം മതിയാവും.ഇനി അതും നിങ്ങളുടെ ശ്രദ്ധ കളയുമെന്നുന്ടെങ്കില്‍ ഇടവിട്ടുള്ള മൂളലുകള്‍ ഒരു ടേപ്പില്‍ പകര്ത്തി ഭാര്യ സംസാരിക്കാന്തുടങ്ങുമ്പോള്‍ ഓണ്‍ ചെയ്തു വെച്ചേക്കുകടേപ്പിന്റെ കാര്യം ഭാര്യ അറിയാന്‍ പാടില്ലെന്ന് പ്രതേയ്കം പറയേണ്ടല്ലോ.


7. 
ഒരുമിച്ചിരുന്നു ടി വി കാണുമ്പോള്‍, വല്ലപ്പോഴും  ടി വി റിമോട്ട് പിടിക്കാന്‍ ഭാര്യയെ അനുവദിക്കുകസ്ത്രീ പുരുഷസമത്വത്തിന്റെ പ്രതീകമായിട്ടാണ് മിക്ക ഭാര്യമാരും ടി വി റിമോട്ടിനെ കാണുന്നത്അത് കൊണ്ട് ഇത് വളരെപ്രാധാന്യമര്ഹിക്കുന്നുപിടിക്കാന്‍ മാത്രം അനുവദിച്ചാല്‍ മതിചാനെല്‍ മാറ്റുന്നത് നിങ്ങള്ക്ക് തന്നെയാവാം.

8. 
വല്ലപ്പോഴും ഭാര്യയോടൊപ്പം ഒരു സില്ലി റൊമാന്റിക് സിനിമാ കാണുകഇത് നിങ്ങള്ക്ക് വളരെ പ്രയാസമുള്ളകാര്യമാണെങ്കിലും കുടുംബ ഭദ്രതയ്ക്ക് ഇതാവശ്യമാണ്വല്ലാതെ ബോറടിക്കുന്നുടെങ്കില്‍ ചെറുതായി മയങ്ങാവുന്നതാണ്.ഇടവേളയ്ക്കു പോപ്‌ കോണ്‍, പഫ്സ്തുടങ്ങിയവ വാങ്ങുന്നതും ഭാര്യയുടെ മനസ്സില്‍ നിങ്ങളുടെ ഇമേജു വര്ദ്ധിപ്പിക്കും.

9. 
ഭാര്യയുടെ സുഹൃത്തുക്കള്‍ വീട്ടില്‍ വരുമ്പോള്‍, കുശുംബികള്‍ 'എന്റെ ഭര്ത്താവോ നിന്റെ ഭര്ത്താവോ മെച്ചംഎന്ന്അളക്കാന്‍ വരുന്നതാണെന്ന് മനസിലാക്കി ബുദ്ധിപൂര്വ്വം പ്രവര്ത്തിക്കുക. 'കുട്ടനില്ലെങ്കില്‍ എന്റെ ജീവിതകൊഞ്ഞാട്ടയായിപ്പോയേനെഎന്ന ലൈനില്‍ കത്തി വയ്ക്കുകകൂട്ടത്തില്‍ സുന്ദരികള്‍ ഉണ്ടെങ്കില്‍ അവരെ അവഗണിച്ചുവിരൂപകളോട് മാത്രം സംസാരിക്കുകഓര്ക്കുകനൈമിഷിക സുഖമല്ല ജീവിതകാലം മൊത്തമുള്ള സമാധാനമാണ് നിങ്ങളുടെലക്ഷ്യം.

10. 
ഇടയ്ക്കിടയ്ക്ക്, 'കുട്ടാ സഹായിക്കണോകുട്ടാ സഹായിക്കണോഎന്ന് അങ്ങോട്ട്‌ ചോദിച്ചെക്കുക . നിങ്ങളുടെ സ്നേഹത്തില്പുളകം കൊണ്ട് ഭാര്യ എല്ലാ പണികളും പൂര്വാധികം ഉത്സാഹത്തോടെ തന്നെ ചെയ്തോളുംഓര്ക്കുകസ്ത്രീകളുടെസൈകോളജി പ്രകാരം പ്രവര്ത്തിയല്ലവാചകമാണ് കുടുംബ ഭദ്രതയ്ക്ക് ആവശ്യം.


11. 
അന്തിമമായിഭാര്യയ്ക്ക് നിങ്ങളെ ഉപദേശിക്കാനും നല്ലവഴിക്കു നടത്താനുമുള്ള അവകാശമുണ്ടെങ്കിലും നിങ്ങള്ക്ക് തിരിച്ചു അവകാശമില്ല എന്ന് മനസിലാക്കുകവിവരക്കേടുകൊണ്ടു പോലും 'കുട്ടാ നീ ചെയ്തത് തെറ്റായിപ്പോയിഎന്ന് പറയാതിരിക്കുക.കാരണംസ്ത്രീകളുടെ സൈകോളജി പ്രകാരം അവര്‍ ഒരിക്കലും തെറ്റ് ചെയ്യില്ല.