cancel
Showing results for 
Search instead for 
Did you mean: 

Reusable Projects

Former Member
0 Kudos

Hi

I have a project with a couple of views in it.

I would like each and every view of it

to act as a reusable view.

My question:

1) Is it possible to put this project on the server

    and just refer to it from other projects

    whenever they require its functionality?

2) Must this reusable view be a part

    of each and every new project

    that requires it?

3) I read about component containers

     but I am not sure where exactly to put them

regards

Yuval

Accepted Solutions (1)

Accepted Solutions (1)

santhu_gowdaz
Active Contributor
0 Kudos

1. It's possible to put that project and access through the url . and add those url in your index.html using <script>.

2. May be navigation from Application to application concept you can use.

3. In my organization, we create the util BSP application and put all the reusable things here. in same package we are deployed ui5 as bsp application.

And i'm sure it will access from outside package also.

Qualiture
Active Contributor
0 Kudos

IMO, the cleanest way indeed is to define the local resource roots in your script tag.

Lets say you have application 'app1' running from <host>/app1, and you want to embed a view from a second application 'reusable' running from <host>/reusable.

Both applications have their views defined in sub folder ./views

You then specify your bootstrap script as follows:


<script src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"

  id="sap-ui-bootstrap"

  data-sap-ui-libs="sap.m"

  data-sap-ui-theme="sap_bluecrystal"

  data-sap-ui-resourceroots='{"app1": "./", "reusable": "/reusable/views" } '>

You now call your view 'myreusableview' inside 'reusable' from 'app1' as follows:


var reusableView = sap.ui.view({id:"idSomeExternalView", viewName:"reusable.myreusableview", type:sap.ui.core.mvc.ViewType.XML});

former_member182372
Active Contributor
0 Kudos

p.1 to add, there is an API method which does the same

jQuery.sap.registerResourcePath(sResourceNamePrefix, vUrlPrefix)

so when you do jQuery.sap.require (for fragments or views) it uses it as

mUrlPrefixes[sResourceNamePrefix] = vUrlPrefix;

p.2 declare a reusable fragment and use it in every view you need

p.3 component container is to use component (suprise!), component can have bunch of views, it's on nav container(s) and so on.

santhu_gowdaz
Active Contributor

Answers (1)

Answers (1)

Private_Member_15166
Active Contributor
0 Kudos