2016-12-02 7 views
-2

私は、クラウドベースのSAP Webideツールを使用してHCPに展開されたsapui5従業員退職アプリケーションを開発するビジネス要件を持っています。従業員のcontroller.xmlのsapui5アプリケーションURLから値を取得するには

二種類のパラメータのいずれかのIT 'または「BPO」を持つ2つの異なるURLを使ってこのアプリケーションにアクセスします:

https://webidetesting453789-inf98834.dispatcher.int.sap.hana.ondemand.com/webapp/index.html#/IT 

https://webidetesting453789-inf98834.dispatcher.int.sap.hana.ondemand.com/webapp/index.html#/BPO 

バックエンド:私は私の従業員の詳細を与えているRESTサービスを開発しています

/irc.com/ircit/empleave/rest/empleave/item/requestor/IT 

または

/irc.com/ircit/empleave/rest/empleave/item/requestor/BPO 
:JSONフォーマット私はどちらかのようなITやBPO特定の従業員については、次のURLを使用してGET要求を行うとき

閲覧: 私はXML形式のビューMyRequestListを使用しています。これは、ITとBPOの両方の要求を表形式で表示します。

要件:

私は以下のURLにユーザーがクリック、MyRequestViewのタイトルは従業員だけITに対する要求ITであるべきときurl.For例に渡されたパラメータに基づいてデータをフェッチする必要があります従業員はBPOに登場し、同じでなければなりません。

https://webidetesting453789-inf98834.dispatcher.int.sap.hana.ondemand.com/webapp/index.html#/IT

質問:

アプリケーションURLからパラメータ「IT」や「BPO」を取得し、コントローラからビューに渡す方法。

Jquery.sap.GetURIParameter.Get( "MyParam")は、 'IT'または 'BPO'というURLパラメータを取得していません。どのメソッドを使用する必要がありますか。

RouterConfig:

{ 
    "_version": "1.1.0", 
    "sap.app": { 
     "_version": "1.1.0", 
     "id": "ircit.irc", 
     "type": "application", 
     "i18n": "/webapp/i18n/i18n.properties", 
     "title": "{{appTitle}}", 
     "description": "{{appDescription}}", 
     "applicationVersion": { 
      "version": "1.0.0" 
     } 
    }, 
    "sap.ui": { 
     "_version": "1.1.0", 
     "technology": "UI5", 
     "deviceTypes": { 
      "desktop": true, 
      "tablet": false, 
      "phone": false 
     }, 
     "supportedThemes": [ 
      "sap_bluecrystal" 
     ] 
    }, 
    "sap.ui5": { 
     "_version": "1.1.0", 
     "rootView": "ircit.irc.view.App", 
     "dependencies": { 
      "minUI5Version": "1.30", 
      "libs": { 
       "sap.m": {} 
      } 
     }, 
     "contentDensities": { 
      "compact": true, 
      "cozy": true 
     }, 
     "models": { 
      "i18n": { 
       "type": "sap.ui.model.resource.ResourceModel", 
       "settings": { 
        "bundleName": "ircit.irc.i18n.i18n" 
       } 
      } 
     }, 
     "resources": { 
      "css": [ 
       { 
        "uri": "/webapp/css/style.css" 
       } 
      ] 
     }, 
     "routing": { 
      "config": { 
       "routerClass": "ircit.generic.utils.CustomRouter", 
       "viewType": "XML", 
       "viewPath": "ircit.irc.view", 
       "controlId": "app", 
       "fullWidth": true, 
       "controlAggregation": "pages", 
       "bypassed": { 
        "target": [ 
         "notFound" 
        ] 
       } 
      }, 
      "routes": [ 
       /*{ 
        "pattern": "", 
        "name": "myRequests", 
        "target": "myRequests" 
       },*/ 
{ 
        "pattern": "/{id}", 
        "name": "myRequests", 
        "target": "myRequests" 
       }, 

       { 
        "pattern": "/create", 
        "name": "create", 
        "target": "create" 
       }, 
       { 
        "pattern": "/create/{id}", 
        "name": "copy", 
        "target": "create" 
       }, 
       { 
        "pattern": "/id={id}", 
        "name": "Display", 
        "target": "display" 
       } 
      ], 
      "targets": { 
       "myRequests": { 
        "viewName": "MyRequests", 
        "viewId": "myRequests", 
        "viewLevel": 1 
       }, 
       "display": { 
        "viewName": "Display", 
        "viewId": "display", 
        "viewLevel": 2 
       }, 
       "create": { 
        "viewName": "Create", 
        "viewId": "create", 
        "viewLevel": 2 
       }, 
       "copy": { 
        "viewName": "Create", 
        "viewId": "create", 
        "viewLevel": 2 
       }, 
       "notFound": { 
        "viewName": "NotFound", 
        "viewId": "notFound" 
       } 
      } 
     } 
    }, 
    "sap.platform.hcp": { 
     "uri": "webapp", 
     "_version": "1.1.0" 
    } 
} 

MyRequestController:

onInit: function() { 
      // set create option (cteate and copy button) 
      var bValue = jQuery.sap.getUriParameters().get("showCreate"); 
      var oBtn = this.byId("btnCreate"); 
      oBtn.setVisible(bValue !== "false"); 
      var oColumn = this.byId("colCopy"); 
      oColumn.setVisible(bValue !== "false"); 

      this.getRouter().attachRouteMatched(jQuery.proxy(this.onRouteMatched, this)); 
     }, 
+0

ルーターの設定を貼り付けてください。また、ハッシュベースのルーティングを使用している場合は、メソッドを調べることもできます。attachPatternMatched(https://help.sap.com/saphelp_uiaddon20/helpdata/en/23/66345a94f64ec1a80f9d9ce50a59ef/content.htm) –

答えて

0

私は2つの以上のルート宣言します:1. ITと2 BPOを。明らかに、あなたは 'myRequests'にナビゲートしたいので、それらのための新しいターゲットを作成するのをスキップします。したがって、2つのルート:

{ 
        "pattern": "IT", 
        "name": "IT", 
        "target": "myRequests" 
       }, 
       { 
        "pattern": "BPO", 
        "name": "BPO", 
        "target": "myRequests" 
       }, 

次に、どのルートがヒットしたかを知ってそれに応じて処理します。

onInit: function() { 
     var oComponent = this.getOwnerComponent(); 
     this._router = oComponent.getRouter(); 
     this._router.getRoute("IT").attachPatternMatched(this._routePatternMatchedForIT, this); 
     this._router.getRoute("BPO").attachPatternMatched(this._routePatternMatchedForBPO, this); 

    }, 
    _routePatternMatchedForIT: function (oEvent) { 
     console.log('Shout for IT'); 
     var sRouteName = oEvent.getParameter('name'); 
     // Call the service : /irc.com/ircit/empleave/rest/empleave/item/requestor/IT 
    }, 
    _routePatternMatchedForBPO: function (oEvent) { 
     console.log('Shout for BPO'); 
     // Call the service : /irc.com/ircit/empleave/rest/empleave/item/requestor/BPO 
     var sRouteName = oEvent.getParameter('name'); 
    } 

2つの異なるパスに2つの異なるハンドラがあることに注意してください。ルートをフェッチし、ハンドラを関連付ける。どのハンドラが呼び出されるかは、URLがどのように形成されたか(ITかBPOか)に完全に基づいています。

これが役立つかどうか教えてください。

+0

ありがとうございます。これを実装し、結果を知らせます。 – Smith

+0

ルーティングから離れて、こんにちはRahul、私はそれに応じてmyRequestViewのタイトルを設定するためにクリックしたURLからパラメータを/ bpoが必要になります。どのように同じをフェッチするか? – Smith

+0

ありがとう、Rahul、私はこれを実装し、あなたに知らせます。 – Smith

関連する問題