java.lang.IllegalArgumentException:

I have this error:

"java.lang.IllegalArgumentException: Trying to navigate to an unknown state 'user' and an error view provider not present"

I want to navigate to ‘user’ throught editing the url and I always failed doing that. So is there any way to delete that error? or redirect me to the main page instead? how can I catch that error?

btw: I am using navigator in all of my pages.

Hello Lance,

Have you registered varioiu views wiht navigator in UI?

Some thing like this has to be done in your UI class
Navigator navigator = new Navigator(this,subLayout); ui.setNavigator(navigator); navigator.addView("", new [b] DefaultView [/b]());// register your default view navigator.addView("user", new [b] UserView [/b]());// register your user view

Yes, I did… but when I try to edit it on my url address at my web browser I got an error.

Hi Lance,

It should certainly work just by typing the “user” url manually. Could you attach a simple test UI that exhibits the problem you’re having?

About catching the “not found” error, the exception message gives a hint: you have to set an error view using Navigator.setErrorView(), or if you want more flexibility, a dedicated ViewProvider via Navigator.setErrorViewProvider().

Wow… this really works… Thank you Johannes…

I have another question… I want that my url to be “project/#user” NOT “project/#!user”. It’s not a big deal but it’s a little annoying everytime I saw ‘!’… :slight_smile:

I have here now are my my addView(“user”, new User())… and it returns ‘#!’.
I am planning to use setUriFragment(“user”) because it returns # only. How can use it? How can I call the class User?

Yes, it is possible. The reason we use the so-called “hashbang” URIs is that they enable the site to be
crawlable by Google
- although not unless the application also has some special support for crawlable views.

Anyway, you’ll want to write a custom UriFragmentManager and pass it as the Navigator’s NavigationStateManager:

public class BanglessFragmentManager extends Navigator.UriFragmentManager {
        @Override
        public String getState() {
            return getFragment() != null ? getFragment() : "";
        }

        @Override
        public void setState(String state) {
            setFragment(state);
        }
}

Wow this is really amazing…It did work with just a flick of my hand… :3 :smiley: Thank you very much…

here you said that using ViewProvider is much flexible… actually I use the setErrorView() because this is much easier than ViewProvider. I research online about ViewProvider but got no sample program. When do I need to use ViewProvider?

Thank you Johannes for immediate reply… You’re a big help… :slight_smile: