cancel
Showing results for 
Search instead for 
Did you mean: 

How to make js.view title visible?

0 Kudos
246

Hi all,

a created a small webapp using sapui5. In my app I created a js view with this code:

sap.ui.jsview("XXXXX.view.MantainRepository", {

  title: "Mantain Repository",

  getControllerName: function() {

  return "XXXXX.controller.MantainRepository";

  },

  createContent: function(oController) {

...

The createContent method is returning an instance of sap.m.Panel.

Nevertheless the title: "Mantain Repository" value is not showing up at the pages header like I would expect it if I am running my app.

No errors in consol,

How to solve this ?

thanks a lot.

best regards

Wolfgang

View Entire Topic
Former Member
0 Kudos

Hi Wolfgang,

you have to set the title property inside the page of the createContent method. At the moment you are setting the title inside the view and not in the page.

For example:

createContent: function(oController) {

     return new sap.m.Page({

          title: "Mantain Repository",

          //Other settings...

     });

}

Regards,

Daniel

0 Kudos

Hi Daniel,

thanks a lot for responding quickly.

One question at the beginning: why does the js.view class have a title attribute if it is no displayed?

If I follow your advise and return sap.m.page, which has the title property, my webpage stays empty. The created content is not shown at all. Thatswhy I am using sap.m.Panel which is unluckily lacking the title property.

How am I able to set the title then?

best regards

Wolfgang

Former Member
0 Kudos

To answer your question: views do not have a property for title. See SAPUI5 SDK - Demo Kit

I think you meant sap.m.Page, am I right?

For me, returning a page works well. Are you calling the page directly from index or are you deploying them to a container? If not, that could be the reason why the page does not display the content.

The panel has the property "headerText". You can use it as your title.

0 Kudos

Thank you for your response. It is still not working with my App. No, I am not calling the side directly. I am using navigation with Router for this. It works with Panel, but not with Page. All sap.m. I'll check with headerText.

Former Member
0 Kudos

When you are using routing, how do you define the routes or targets? What is your controlId?

0 Kudos

Here is my Routing configuration including controllId from manifest.json:

    "routing": {
"config": {
"routerClass": "sap.m.routing.Router",
"viewType": "XML",
"viewPath": "artfctyssrvc.view",
"controlId": "rootControlAFSS",
"controlAggregation": "pages",
"transition": "slide"
},
"routes": [{
       "pattern": "",
       "name": "appHome",
       "target": "home"
           },
           {
       "pattern": "MantainRepository",
       "name":    "MantainRepository",
       "target": "mantainRepository"
           },
           {
       "pattern": "Login",
       "name":    "Login",
       "target": "login"
           }           
],
"targets": {
"home": {
"viewName": "AFSSLogin",
"viewType": "JS",
"viewLevel": 0
},
"mantainRepository" : {
"viewName": "MantainRepository",
"viewType": "JS",
"viewLevel": 1   
},
"login" : {
"viewName": "AFSSLogin",
"viewType": "JS",
"viewLevel": 0   
}
}
    }
Former Member
0 Kudos

What type of control is "rootControlAFSS"? Where is it defined?

Why do you have to targets (login and home) with the same parameters?

0 Kudos

It is the id of the App control defined in the rootView

<mvc:View

  id="_xmlMainViewAFSS"

  controllerName="artfctyssrvc.controller.xmlVArtFctySSrvcMain"

  xmlns:html="http://www.w3.org/1999/xhtml"

  xmlns:mvc="sap.ui.core.mvc"

  xmlns="sap.m">

  <App id="rootControlAFSS">

  <pages>

  <Page id="_LoginAFSS">

             <content>

                <mvc:JSView id="_jsAFSSLogin" viewName="artfctyssrvc.view.AFSSLogin"/>

             </content>

  </Page>

  </pages>

  </App>

</mvc:View>

MarcinPciak
Active Contributor
0 Kudos

In your routing config you have:

"controlId": "rootControlAFSS",

"controlAggregation": "pages",

which means that your target control for the views is rootControlAFSS (which is your app) and target aggregation is its pages. Having this defined you should place your page _LoginAFSS inside your view, not outside it. Here you can apply title to your page, which is now the topmost control in your view and is always visible when the view is displayed.

Also remove everything that goes to pages aggregation in your App.view.xml. This part will get populated once the routing hits the corresponding target (here login).

Regards

Marcin

0 Kudos

Hi Marcin,

thanks a lot for your input. I tried to apply your proposals, but it ends up in syntax errors in my xml view, containing the js view for login. It is not possible to omit the <pages> and the <page> elements in the view definition. Can you please provide the correct code for this based on my xml code provided earlier in here?

In regards of the root issue, I adressed at the beginning of this thread: It is about making the title visible for the view/page, which the app is navigating to from the login screen using navigation. If I return a page in the CreateContent of that view, it is not shown at all. The header attribute value of that view is not shown either, if createContent is returning a panel.

Wolfgang

0 Kudos

It is of course the title attribute and not the header one, I filled in the jsview, like you can see in the code example above.

Former Member
0 Kudos

Hi Wolfgang,

in the xml view you can add a property called "title".

<Page id="yourID" title="MyTitle">

</Page>

Regards,

Daniel

0 Kudos

Sure. I know this. This is not the problem. The problem is, that I can only return sap.m.Panel from the CreateContent method of the jsView which is instantiated by navigation. If the method returns sap.m.page, none of the created content is visible. It is not about setting the title Attribute for the main xml View. It would be great if we could continue to search for a solution for the initially described problem. Thanks a lot.

MarcinPciak
Active Contributor
0 Kudos

Well, try this way. The app view should be an empty "container" like this one:


<mvc:View

  id="_xmlMainViewAFSS"

  controllerName="artfctyssrvc.controller.xmlVArtFctySSrvcMain"

  xmlns:html="http://www.w3.org/1999/xhtml"

  xmlns:mvc="sap.ui.core.mvc"

  xmlns="sap.m">

  <App id="rootControlAFSS"/>

</mvc:View>

Define your view like:


sap.ui.jsview(...,{

  createContent : function(){

      return sap.m.Page({

           title : "...",

           content : ...

      });
  });

});

When the target is hit, your view should get instantiated and embeded in the app <pages> aggregation.

Regards

Marcin