Wicket AjaxTabbedPanel with tab content panels that defer rendering until tab is activated - wicket

I have a page with an AjaxTabbedPanel with lots of tabs with content like charts, reports, etc., whose content is quite expensive to produce. Most users spend most of their time on the first panel and don't need to venture to the tabs with charts, reports etc.,
To avoid unnecessary work on the back end and provide a faster initial page render I thought it would be advantageous to avoid doing the work to populate a tab's contents until (and only if) the user clicks on a tab to activate and thus render that tab's content.
Of course the first tab will always load during initial page load as that is the one that is active by default but the other tabs' contents will lay dormant until the user clicks on the corresponding tab, avoiding doing any work for those dormant panels until necessary.
Is that possible?
I thought that I could possibly employ the AjaxLazyLoadedPanel but it seems to be designed for a different purpose and the lazy loaded panel is regularly polled until it is 'ready' but that's not what I need in my case: there's no need for polling, we will know when to render a panel's content i.e. when activation of the panel occurs.

TabbedPanel does not need a tab's content as long at is isn't shown.
Make sure that you implement ITab#getPanel() 'lazy', i.e. the panel is created only when that method is called the first time. See PanelCachingTab for inspiration.

Related

Web-site with two Composite per page. Due to bad design?

I'm creating a web-site using GWT for the first time. The aplication has two Composite class, one of them is a menu and the other one is where I show de info about the specific menu that has been clicked. I'm using MVP, the class History and the interface ChangeValueHandler to switch among different pages.
I have one pair presenter-view for each Composite. The app begins well creating the menu and the section info. When you click in the menu it works fine showing the information and the token browser is changed. The thing is that if you load a page(eg: myapp.com#register) without loading the home page, it doesn't show you the menu. It loads the Composite section info, but not the Composite menu (the Composite menu is load with myapp.com#home).
I think it's because of a bad design of the application, but I don't know how to do that in other way. If the app only had one Composite it wouldn't be a problem, but when there are 2 or more Composite per page I don't know how to manage the whole thing to work properly.
It's difficult to tell what exactly is wrong, because of the lack of code. So I'm guessing. You should design to act on the PlaceChangeEvent instead of the ValueChangeEvent. That means a menu click should fire the place change and then the application will handle this event. That way you unbind the menu actions from your content pages. And think more of each page as a separate entity. Also take a look at the GWT Activity mechanism and how it helps having a main page that is always the same and on that main page a content area that changes depending on the page actually shown.
You should include your menu in each page instead of creating it once in the home page and then keeping it on screen. I assume you create the menu and add it to the DOM via
RootPanel.get().add(myMenuWidget);
If you are using UIBinder it should be pretty straightforward to include the menu in each page, just a matter of adding the corresponding tag in each .ui.xml file of your pages.

forms showing in runtime as soon as they are created

In runtime when the forms are being created, 2 forms constantly keep appearing when I haven't programmed them to show as soon as they are created, and my system runs. I was wondering why this happened and whether there is anything to solve this? I don't think I need to show my code here since it's pretty basic and there is none for the OnCreate event.
From the main menu, use Project->Options->Forms, and remove the forms you don't want to see from the Auto-create list. (Click the >> button to move them from the left side to the right side.)
(It's worth mentioning that you can also affect the order in which any autocreated forms or datamodules are created from that dialog by just dragging them up or down in the list. Note that the first form to be created becomes the application main form, so when it is closed the application will close as well; this means that the only thing above your main form in the autocreate list should be datamodule(s) that are accessed by the main form.)
If you never want any forms auto-created, go to Tools->Options->Environment Options->Form Designer, and uncheck the very last item labeled Auto create forms & data modules at the bottom. Note that your main form will always be auto-created, as it's what controls the application's lifetime for form based applications.
By default delphi creates all the forms in the beginning. You can open the .dpr file and delete the ones that you don't need. You could also do that from the UI.
For the forms that you don't want to appear at the start of runtime, go to the properties of the form (lower left hand side) and uncheck Visible. This should do the trick

How to get the present object in an Eclipse RCP view?

I'm starting with the coding of an Eclipse RCP and be relatively new to the RCP-World.
Currently i have one perspective with two views. One is a list with a tableViewer which shows a few names of workers.
The second view is a "single view" with a few textboxes. I use the ISelectionListener to notify when i have selected another entry in the list, so i can set the text boxes in the "single view" wiht the current selected worker objetc.
I didn't wrote the code on my own, and i used this page (Vogella) to learn all the stuff behind RCP.
My question is: How can i get the current Object showed by the active view? I mean, i have it
because of the SelectionListener, but i want to click on my own "save"
button to update changes to the object.
I want the object in the single view, so do i need another change listener, or is the object stored in the view and can i get it with the ISelection Interface?
Can someone tell me in one or two sentences how it works? Or is it
just too simple, because i couldn't find anything elsewhere.
This can be done, but is not very easy, because the behaviour is not very standard. You are treating the two views as one usually deals with linked controls of a dialog or window. That's not necessarily wrong, but i smells bad (I cannot recall an example in the Eclipse IDE). Are you sure you are not confusing the roles of Views and Viewers? A View, in Eclipse, is a "Part" of a Workbench (you have basically Views and Editors), each view shows information and/or performs actions, but they are typically quite decoupled, you should be able open and close freely and independently each View, they rarely interact with each other directly (they typically display information or modify objects in the workspace). Further, you should not have a "Save" button in a View (again, look at the Eclipse IDE as an example), changes done throught a view should be direct.
It is very doubtful for me that your design here in sound, perhaps you should instead use a single View, or a dialog. I suggest you to read more about Views.

Lose events for extjs form

I have a big form on extjs which opens in window, and, for speed reasons, i cache it in hidden panel. There is can be only one window at time, so the cached form is single too. On show event i add form to window, with no rendering and with suspendLayout option for form. On close event i move the form to hidden panel, with panels add method. I do not use remove method not for window not for panel. So, for several times all perfect, but after 3- 5 window openings form lose all of its events: buttons, comboboxes, triggers and other controls are not responding. Where is the problem? Thank you.
It is difficult to know for certain but my theory is that the observable object that your listeners are setup on is garbage collected at some indeterminate time period of inactivity.
I have seen this occur on an object representing the body of an iframe that is watched from the parent window. Click events from the body will work for some time and then all events will stop.
One way to test the theory is to store object reference in a global variable - this is NOT what you want to do in any app but worth a try just to test. Global vars are never garbage collected.

Positioning ListViews in WinJS Metro apps using scrollIntoView

I am building a jscript-based Windows 8 Metro app. The main screen of this application is a scrolling "panorama" view with several list views showing various aspects of the app's state. In some cases the user will select something on the page which results in a navigation to another page (using the WinJS.Navigation.navigate method.
When the user hits the back arrow on the other page, it returns to the main screen, and I use "scrollIntoView" on to position the screen to the section that the user was working on before the navigation occurred.
Unfortunately this hardly ever results in correctly positioning the view. It seems random. I suspect that the page isn't finished being built yet and that the scroll values are set based on the state at some snapshot in time.
Now the question:
Is there some what to be notified by WinJS ListView objects that they are completely rendered and layed out? Or is this the job of the page's ready function?
Thanks for any insight!
Putting multiple list views side by side is Not A Good Idea(TM). I would recommend putting one list view, and placing your content in a grouped data source to get the groups. If the items have different templates, then you can use a custom item Template selector to dynamically select a template.
Additionally, to ensure that the list view is scrolled to the right position, you need to use the indexOfFirstVisible to set the items the name suggests.