cancel
Showing results for 
Search instead for 
Did you mean: 

Force Reload

italo_naia
Participant
0 Kudos

Hi All,

I have a problem with dynamic View.

I have a Page with list when select an item go to a second page to show some fields.

The second Page fields is create dynamic, so before I do .to(secondpage) I destroy the page (if its created).

  The problem is: when I destroy the page and create its again, the controller is load twice, the sapui5 pass through onInit(), onBeforeRenderer(), onAfterRender() twice, and I have some problems because I create the fields dynamic.

  One problem is with Table, on second call the table gets smaller, like this pics:

First Call:

http://i.imgur.com/AGoe9Dy.png

Second Call:

http://i.imgur.com/k9fcUjY.png

How I can force reload/re-render the Page without problems?

Thank You

Accepted Solutions (0)

Answers (4)

Answers (4)

italo_naia
Participant
0 Kudos

someone???

thankyou!!!!

italo_naia
Participant
0 Kudos

My scenario is to show reports on first View is a list of reports and second view is the report with Header and Table with data.

All content in second view is dynamic, header fields, table columns, table odata source.

But the application not only this, I have a App that start with a Tile Container

http://i.imgur.com/ypSQFHp.png

When click on container to reports, I do App.to(firstview) to show a list of reports when choose the report I do App.to(secondview), but in this case before App.to I destroy the page because I have to pass through createcontent again.

But in this case the Table with visibleRowCountMode="Auto" get smaller.

Qualiture
Active Contributor
0 Kudos

But why do you need to go to createContent again?

The normal procedure is to simply fire an event when you do some action, and have your view respond to that event; in your case, it will rebuild your UI I guess

Generally, there should absolutely be no need for destroying content

italo_naia
Participant
0 Kudos

So Let me see if I got it.

  I have to on createcontent create only my default components, and in the controller (onBeforeRendering) call some method on view to rebuild?

Like this.getView().rebuildTable()

Thank you

Qualiture
Active Contributor
0 Kudos

Yes that's correct, but you don't call a method in your xxxx.view.js, but it should be in your xxxx.controller.js instead -- you shouldn't have any functions in your view file, and XMLViews and HTMLViews don't allow for any code ayway

this.getView().rebuildTable() thus in effect calls a function 'rebuildTable()' which is defined in your controller

italo_naia
Participant
0 Kudos

OK, My view was JS, I will change to XML.

But How I force recall of Controller OnBeforeRendering?

Because if I only do App.to(pageid) the method is not called.

I tried page.removeAllContent(), that's work, but I get error after OnBeforeRenderingon, on Render of Page Bar.

THank Yoy

Qualiture
Active Contributor
0 Kudos

You may leave it to JSView if you want, but I have a personal preference for XMLViews since they tend to be cleaner and easier to read

You don't need to call the controller's onBeforeRendering I guess. In your target view, subscribe to a certain event:


var oEventBus = sap.ui.getCore().getEventBus();

oEventBus.subscribe("some.unique.channel","someEventId", rebuildTable);

Then, when you navigate, you fire that event:


oEventBus.publish("some.unique.channel","someEventId",params);

where 'params' are maybe some extra contextual information you want to send to your function, for instance:


{someParam: "Hello", someOtherParam : aSomeArray}

Now, when that event is fired, the function rebuildTable is called:


rebuildTable : function(sChannelId, sEventId, oData){

    alert(oData.someParam + oData.someOtherParam[0]); // do whatever you like to rebuild your view 😉

};

See https://sapui5.netweaver.ondemand.com/sdk/#docs/api/symbols/sap.ui.core.EventBus.html for more info

Hope this explains, happy coding!

italo_naia
Participant
0 Kudos

OK,

This work I don't need to destroy page. But de Table still get smaller after first call.

It should be a component bug?

Qualiture
Active Contributor
0 Kudos

Upon rerendering, can you find any differences between the generated DOM elements?

italo_naia
Participant
0 Kudos

Apparently the dom is the same.

My view structure is:

-Page

     -content

          -ObjectHeader

          -Table (VisibleRowCountMode = 'Auto')

     -footer

          -Bar

               -Button

In this case when table get the parent component height it return of the page component, ignoring the ObjectHeader and the table get greater than Screen.

In second call show the table smaller for 1 second and then redraw bigger.

So I changed structure to:

-Page

     -content

          -ObjectHeader

          -Panel

               -Table (VisibleRowCountMode = 'Auto')

     -footer

          -Bar

               -Button

In this case in second call the panel get smaller . I don't found why yet. I see in HTML that the panel create a <section> and a <div>, the section get the right Height but the div dont.

Thank you

former_member182372
Active Contributor
0 Kudos

is it absolutely necessary to destroy page? eventhough it is dynamic. clear content of the container

what`s your scenario

italo_naia
Participant
0 Kudos

How to clear content?

I Tried removeAllContent and destroyContent both remove all content, but don't pass through createcontent again, only show the page with no content.

Thanks

SergioG_TX
Active Contributor
0 Kudos

Italo,

your views should create your content and your controllers perform actions.

There shouldn't be a reason to destroy anything. the view should load as simple as navigating to it. of course, the first time visiting will be slower than the second time