-
Notifications
You must be signed in to change notification settings - Fork 66
Question: Who should handle 404 pages? #126
Comments
In general if a sub-route selector fails to match, the element where the selector is defined should handle the 404. So you can use |
@TimvdLippe, thanks for your opinion. |
@TimvdLippe one more thing, which i didn't get so, i've have a I like the idea with decentralized routing items, but i think we should one point to handle misleading pages. |
@ymaz there are no redirects with the componentized router. Therefore each selector handles the 404 on its own, without notifying its parent. This allows you to define a specific 404 handler for each case, as you might want to propagate different information to your user depending on the sub-route. E.g. "This user could not be found" on a users page, or a "This setting does not exist" when you are in a settings view. That said, we might be able to fire an event when a fallback selection is triggered. Then in your root app element you listen for this event and act accordingly. What do you think of updating |
completely agree!
Okay, but if we actually need to have some logic, like if |
So, actually right now i'm understand how to make 404 page for top level nav via |
I am struggling with the same issue. In my top level app element, I have pk-app.html
I am passing in the route tail to the child elements where I also have an
UPDATE: Just realized there is another problem as well. If you have multiple nested sub-elements with |
Can you give a demo of this failure with nested app-routes and iron-pages @chrismbeckett? Here's a jsbin to start: https://jsbin.com/hirore/edit?html,output The issue with them stomping all over each other shouldn't happen unless different routable components each mutually believe that the others' urls are unacceptable. |
Little reminder for myself: to have 1 entry point for handling 403's we could fire an event in iron-selector when a fallback-selection is triggered. You can listen for this event in your app element and handle it there. WDYT? |
@TimvdLippe The Iron-Selector has the |
I have created a new pull request on An example usage of this event can be found in this diff: https://github.com/TimvdLippe/polymer-lazy-application/compare/monolithic-router?expand=1#diff-8177f8e50fd6fc8e66434f5c76f38d98R45 |
Hi, it's not a issue at all, it's more just a questing/best practices manual/discussion.
So, who should handle 404 page in Polymer app, which using
<app-route>
for the routing?I mean, when user typed something incorrect which is not relevant to any page/view. Which element should be responsible for redirect?
For example, I'm using combo
<app-route>
+<iron-pages>
. I've spotted that<iron-pages>
supportfallbackSelection
attr for fallback view.Okay, theoretically, i can do like this:
This solution will work okay for top level navigation, like
/list
,/details
but what if something goes wrong on the second level?
Example
/list/blabla
and etc.?How I should handle this cases?
Or i need to write some kind of
_pageResolver(page)
method which will receive thepage
string, and tries to find that page in already pre-defined router-config object/array, and after that passed the value into<iron-pages>
otherwise set to404
?Many thanks and please feel free to share you opinion regarding that.
The text was updated successfully, but these errors were encountered: