Set initial view in SAPUI5 - sapui5

How do I change the initial view in an SAPUI5 project? I want to change the view that is being displayed when the route pattern is ""
Should I change the rootView property in manifest?
"rootView": {
"viewName": "namespace.view.App",
"type": "XML",
"id": "app"
}
Kindly help

Thank you for everyone's assistance and suggestions.
Since the application I was editing used routing and the navigation target resolution service was configured to resolve the empty location hash to the application, I made changes to its routing configuration.
I changed the values in the "routing" configuration's "routes" where pattern was set as "" to the values of the view I wanted to display when I run the application.

Yes, You can change it there.
Replace viewName with new existing view :)

Change namespace.view.App to namespace.view.NewInitialViewName.
You can also delete App.view.xml and App.controller.js if you are not using them.

Related

How to fix Blocking screen with content On my quick app pages?

On my quick app pages, some
content may be blocked by the app menu. For example, the sign-in entry is blocked by the app menu in the following figure.
Although the menu is configured to be movable, users do not know that they can move it.
How can I solve this problem?
The following solutions are provided to solve your problem:
Separating the menu from any content displayed
Hiding the menu
Adding a message indicating that the menu is movable
For Detail,pls kindly refer this link : What if some content is blocked by the app menu?
You can separate the menu from any content displayed by changing the value of titleBar to true in the manifest.json file.
e.g.
"display": {
"fullScreen": false,
"titleBar": "true",
"menu": false,
"menuBarData": {
"draggable": true
},
There is a good example with other solutions. Please check link

UI5 Router destroying cached views

I have a Master Details Page App where we configured the Router for the same to navigate between pages.
App.view.xml
<SplitApp id="rootControl" detailNavigate="onDetailNavigation">
</SplitApp>
manifest.json
"routing": {
"config": {
"routerClass": "sap.m.routing.Router",
"viewPath": "master",
"controlId": "rootControl",
"viewType": "XML",
"async":"true"
},
"routes": [
{
....
},
...
"targets": {}
...
App is simple Employee CRUD app, i have configured the router with 2 routes 1 for Create/Edit and another one for Dispaly
I need to destroy the view if i navigate from one view to another view, like on start of the page show the Master Page with all the employees and detail page show display view of the employee1.
i have Edit button on the Display view, on press i navigate details page from Display view to Edit View, on this point i need to destroy the Display view from the router, which is cached.
How to achive this? or do i need to take different approch to solve the cacheing? or I should not think of Memory
tried calling destroy onDetailNavigate of SplitApp
onDetailNavigation : function(oEvent){
console.log("Split app onDetailNavigation");
oEvent.getParameter('from').destroy();
}
Which gives Error next time go back to same view again
Error: The object with ID __xmlview4 was destroyed and cannot be used anymore.
According to the comments you destroy views to save the memory allocated by your two views. I do not think this brings any real benefit. There are three possible solutions:
Stick with the current solution.
Use a single view and switch between a display and a edit fragment. An example can be found here.
Use a single view with a form with input fields. Bind the editable attribute against a model (e.g. view model) property reflecting edit or display state of the whole form or per property.
<Input value="{applicationModel>/propertyName}" editable="{viewModel>/editable}"/>
I'm using a version of the third solution. My application model (extending JSONModel) holds the application data plus a state controlling the property. The controller just calls setEditable on the application model which computes the state. Using this approach I avoid to spread the logic accross to many parts of the application.
<Input value="{applicationModel>/propertyName}" editable="{applicationModel>/Attributes/propertyName/editable}"/>
Since my Question is about the destroying the view from Router which are cached, i have followed the #boghyon comment and made some changes in my code as below which removes the pages after navigation of detail page as below
var splitApp = this.getView().byId('rootControl');
splitApp.removeDetailPage(oEvent.getParameter('from'));
and to remove the cached view from router i have wrote some logic
var router = this.getOwnerComponent().getRouter();
for(var view in router._oViews._oViews){
if( router._oViews._oViews[view].sId === oEvent.getParameter('fromId'){
delete router._oViews._oViews[view];
}
}
Which destroy the view.
By doing this which loads the views multiple times and this is not proper ways for my requirement we have follow the #matbtt answer.
Thank you both for the valueable input.

What is metadata in Component.js?

I am creating an app using Navigation and Routing concept and was unable to understand the metadata which needs to be specified in Component.js
What is the meaning of below :-
"controlId": "app",
"controlAggregation": "pages",
When I am checking the documentation Component.js it is mentioned as -
targetParent: "myViewId",
targetControl: "app",
targetAggregation: "pages",
Can someone explain the difference between the above two and it will be helpful what exactly it means?
With below XML view code as an example, I will elaborate about the metadata configuration.
<core:View xmlns:core="sap.ui.core" xmlns="sap.m" controllerName="Demo.view.Main" displayBlock="true" height="100%">
<App id="app">
</App>
</core:View>
App control is the root element for UI5 mobile application. It has pages aggregation as it extends from NavContainer.
targetControl: "app",
targetAggregation: "pages"
targetControl is specified with ID of control which is used to display the pages. In above XML, App control has "app" as it's ID.
So, all your views will be placed in pages aggregation of App control.
Now, you might be wondering how views can be placed in pages aggregation.
If you look at type of controls allowed in pages aggregation is Control. Any control which extends Control class can be placed in pages of App. As View is also Control it is valid to be added in pages aggregation.
So, all views in application are placed in App.
"targetParent": "myViewId"
targetParent is nothing but the view in which App control is placed.
Regarding difference between above and this
"controlId": "app",
"controlAggregation": "pages"
In newer version of SAPUI5, we specify configuration in manifest.json file instead of Component.js file. So, you will find this configuration their.
They are one and same but only with different names.
Following are the Configuration Parameters for Navigation
routes :- The routes parameter defines an array of route configurations.
config :- The config parameter defines the default values for route configuration.
view :- The view parameter contains the name of the view that is created on the first time a route is matched. To place the view in a control, use targetAggregation and targetControl. Views are only created once.
targetParent :- The target parent parameter defines the ID of the parent of the targetControl parameter.
targetControl :- Views are put into a container control, for example a shell control or a NavContainer for mobile applications, or into any other container. The targetControl parameter contains the ID of this control.
targetAggregation :- The target application parameter contains the name of an aggregation of the target control that contains views. A NavContainer, for example, has an aggregation called Pages and the shell container has Content.
subroutes :- The subroutes parameter contains an array of routes and can contain the complete route configuration. Routes that are added to subroutes may have subroutes themselves.
callback :- The callback parameter is an optional function that is executed after the route has matched.

Remove navigation menu item for model without removing ability to manage in RailsAdmin and CanCan?

So I have a model (Image) that belongs to another model (Product), and I want to allow a user to manage both of these two types of models, but I don't want to list the model in the navigation menu in RailsAdmin.
Basically of these two I only want Product to be visible in the navigation menu, while allowing the user to still crud their images within the edit/add form of a Product.
Is this possible with CanCan? Or do I need to use CSS to hide these navigation items?
config.model Team do
visible false
end
According to this issue, and this issue your only valid approach would be the CSS approach
I had the same issue, and unfortunately I haven't found any proper solution. The only workaround was to hack Rails Admin using javascript.
So, to hide the model Image from the navigation menu I added this code in 'app/assets/javascripts/rails_admin/custom/ui.js':
$(document).on('rails_admin.dom_ready', function() {
$('ul.nav-pills li[data-model="image"]').hide();
});
I had same issue. fixed using this css
li[data-model="event_date"] {
display:none !important;
}
in your model:
rails_admin do
visible false
end
no need to edit your rails_admin.rb file.

Zend Framework: Hide navigation item in menu by show in breadcrumbs

i am using Zend_Navigation i want to show the nav item in the breadcrumbs but hide it in my menu, how can i do that?
There are many choices, e.g.
You may set visible parameter to false (eg. in xml config file), then use setRenderInvisible(true/false) on the navigation helper,
You may use separate containers,
You may modify the container on the fly (getContainer(), getItemBy()…)
When using an XML config file, use an integer instead of a boolean value:
<visible>0</visible>
An issue has already been logged for this problem here.