zacheeye / vaadin-appfoundation

Automatically exported from code.google.com/p/vaadin-appfoundation
0 stars 0 forks source link

ViewHandler should allow null and empty values #16

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Steps to reproduce the problem
1. ViewHandler.addView(FrontPage.class, this);
2. ViewHandler.addUri("", FrontPage.class);

Currently the above code doesn't work, it throws an exception "Uri must be 
defined" :(

It would be great if the above code did work, because then it would be possible 
to set a default view to show when the uriFragement is removed/deleted (i.e. 
set to just "/myApp/#")

There are various places in ViewHandler where uris of null and "" are trapped, 
I believe it's safe to remove them - HashMaps handle null/empty keys ok.

appfoundation 1.3.5

btw, great library! :)

Original issue reported on code.google.com by jim.groo...@gmail.com on 22 Nov 2010 at 6:01

GoogleCodeExporter commented 9 years ago
BTW, the workaround looks like this:-

    uriFragmentUtil = ViewHandler.getUriFragmentUtil();
    uriFragmentUtil.addListener(new FragmentChangedListener() {
        public void fragmentChanged(FragmentChangedEvent e) {
            String fragment = e.getUriFragmentUtility().getFragment();
            if (fragment.length() == 0) {
                ViewHandler.activateView(FrontPage.class);
            }
        }
    });
    addComponent(uriFragmentUtil);

...but it would be good not to do that! ;)

Original comment by jim.groo...@gmail.com on 22 Nov 2010 at 6:10

GoogleCodeExporter commented 9 years ago
You do have a point, however, I'm not very fond of magic null values. I think 
I'll rather introduce default vies which can be defined with separate methods.

Original comment by kimp...@gmail.com on 8 Jan 2011 at 11:21

GoogleCodeExporter commented 9 years ago

Original comment by kimp...@gmail.com on 17 Jun 2011 at 11:27