File tree 6 files changed +52
-19
lines changed
6 files changed +52
-19
lines changed Original file line number Diff line number Diff line change 1
1
sap . ui . define ( [
2
- "com/mrb/UI5-Navigation-and-Routing/controller/BaseController"
3
- ] , function ( BaseController ) {
4
- "use strict" ;
5
-
6
- return BaseController . extend ( "com.mrb.UI5-Navigation-and-Routing.controller.Home" , { } ) ;
7
- } ) ;
8
-
2
+ "com/mrb/UI5-Navigation-and-Routing/controller/BaseController"
3
+ ] , function ( BaseController ) {
4
+ "use strict" ;
5
+
6
+ return BaseController . extend ( "com.mrb.UI5-Navigation-and-Routing.controller.Home" , {
7
+ onDisplayNotFound : function ( ) {
8
+ /*
9
+ alternative ways of getting the `sap.m.routing.Targets` Object
10
+ this.getOwnerComponent().getRouter().getTargets() or
11
+ this.getOwnerComponent().getTargets().
12
+ */
13
+ //display the "notFound" target without changing the hash
14
+ this . getRouter ( ) . getTargets ( ) . display ( "notFound" , {
15
+ fromTarget : "home"
16
+ } ) ;
17
+
18
+ }
19
+ } ) ;
20
+ } ) ;
Original file line number Diff line number Diff line change 1
1
sap . ui . define ( [
2
- "com/mrb/UI5-Navigation-and-Routing/controller/BaseController"
2
+ "com/mrb/UI5-Navigation-and-Routing/controller/BaseController"
3
3
] , function ( BaseController ) {
4
- "use strict" ;
5
- return BaseController . extend ( "com.mrb.UI5-Navigation-and-Routing.controller.NotFound" , {
6
- onInit : function ( ) {
7
- }
8
- } ) ;
9
- } ) ;
4
+ "use strict" ;
5
+ return BaseController . extend ( "com.mrb.UI5-Navigation-and-Routing.controller.NotFound" , {
6
+ onInit : function ( ) {
7
+ var oRouter , oTarget ;
8
+ oRouter = this . getRouter ( ) ;
9
+ oTarget = oRouter . getTarget ( "notFound" ) ;
10
+ oTarget . attachDisplay ( function ( oEvent ) {
11
+ this . _oData = oEvent . getParameter ( "data" ) ; // store the data
12
+ } , this ) ;
13
+ } ,
14
+
15
+ // override the parent's onNavBack (inherited from BaseController)
16
+ onNavBack : function ( ) {
17
+ // in some cases we could display a certain target when the back button is pressed
18
+ if ( this . _oData && this . _oData . fromTarget ) {
19
+ this . getRouter ( ) . getTargets ( ) . display ( this . _oData . fromTarget ) ;
20
+ delete this . _oData . fromTarget ;
21
+ return ;
22
+ }
23
+
24
+ // call the parent's onNavBack
25
+ BaseController . prototype . onNavBack . apply ( this , arguments ) ;
26
+ }
27
+ } ) ;
28
+ } ) ;
Original file line number Diff line number Diff line change @@ -5,4 +5,5 @@ iWantToNavigate=I want to navigate
5
5
homePageTitle =Home
6
6
NotFound =Not Found
7
7
NotFound.text =Sorry, but the requested resource is not available.
8
- NotFound.description =Please check the URL and try again.
8
+ NotFound.description =Please check the URL and try again.
9
+ DisplayNotFound =Display Not Found
Original file line number Diff line number Diff line change @@ -5,4 +5,5 @@ iWantToNavigate=I want to navigate
5
5
homePageTitle =Home
6
6
NotFound =Not Found
7
7
NotFound.text =Sorry, but the requested resource is not available.
8
- NotFound.description =Please check the URL and try again.
8
+ NotFound.description =Please check the URL and try again.
9
+ DisplayNotFound =Display Not Found
Original file line number Diff line number Diff line change 4
4
xmlns : mvc =" sap.ui.core.mvc" >
5
5
<Page title =" {i18n>homePageTitle}" class =" sapUiResponsiveContentPadding" >
6
6
<content >
7
- <Button text =" {i18n>iWantToNavigate} " class =" sapUiTinyMarginEnd" />
8
- </content >
7
+ <Button id = " displayNotFoundBtn " text =" {i18n>DisplayNotFound} " press = " .onDisplayNotFound " class =" sapUiTinyMarginEnd" />
8
+ </content >
9
9
</Page >
10
10
</mvc : View >
Original file line number Diff line number Diff line change 7
7
text =" {i18n>NotFound.text}"
8
8
description =" {i18n>NotFound.description}"
9
9
showNavButton =" true"
10
- navButtonPress =" onNavBack" />
10
+ navButtonPress =" onNavBack" />
11
11
</mvc : View >
You can’t perform that action at this time.
0 commit comments