Vaadin & Spring Boot, Reset/Refresh a Component - spring

I have many layouts that extends VerticalLayout. I am removing all of them from a main layout add adding one of them to the main layout, to change the "page". First, is there a better option to this ?
My main question is, since I am adding the same component created in another scope, the content of the layouts doesn't change until I refresh. I want it to change after I click the icon in the menu bar.
So what I am looking for is a method like component.refresh() or something like this.
How can I achieve this ?

What your missing is this:
1. You can not add one component to two or more parents. The moment you add a component to parent2, its removed from parent1 (You get to see this when you hit refresh)
2. You are not using #PreserveOnRefresh on your UI class

Related

Angular Material Sidenav inside custom component doesn't render right sidenav properly

I'm having a problem using a mat-sidenav with position="end" inside a mat-sidenav-container that is part of a custom component. The custom component is essentially the mat-sidenav-container, the left side mat-sidenav, plus ng-content slots for the left sidenav content, page content, and an optional right mat-sidenav.
Sample: https://stackblitz.com/edit/angular-fxp7dt
The problem is that the right sidenav backdrop does not display. A DOM inspection shows that the right mat-sidenav is added inside the mat-content element which is probably why the backdrop is missing. If the same kind of layout is set up without a custom component for the mat-sidenav-container, the right side mat-sidenav is a sibling of mat-content and the other mat-sidenav.
Can anybody see what I might be doing wrong? Or does this seem like a bug in Angular Material?
Thanks.
According to https://github.com/angular/material2/issues/9438, this usage isn't supported. The workaround is to to include the second mat-sidenav element in the custom component and provide just the content for it instead of the mat-sidenav itself. This kind of thing:
<mat-sidenav-container>
<mat-sidenav #sidenavStart>
<ng-content select="[sidenavStartContent]"></ng-content>
</mat-sidenav>
<ng-content></ng-content>
<mat-sidenav #sidenavEnd position="end">
<ng-content select="[sidenavEndContent]"></ng-content>
</mat-sidenav>
</mat-sidenav-container>

Show specific presenter instance to flex panel gwt mvp

I'm still learning GWT, yet already have to face some kind of challenge for a work I have to do. Can't show any specific code so I'll try to explain it well.
Here's the situation: A certain class "Navigator" creates and save the Presenter instances of my architecture to allow reusing them. There is a method show() inside that same class that actually displays the view related but that system only works full screen by calling RootPanel.get().
What i'd like to do is showing that presenter instance's view inside of a flex panel element declared in a class myView (related to a class myPresenter) that basically uses Flex Panel to structure it's content.
To make it maybe more clear:
class myView{
...
flexPanel.setWidget(firstWIdget)
flexPanel.setWidget(secondWidget) //secondWidget to be replaced by a "thirdWidget"
...
}
I'd like the secondWidget to be replaced by another one, let's call it thirdWidget, that consists of a specific presenter instance's view.
To resume, I'd like my presenter instance's view to not go full screen but only occupy a certain area of the screen.
The displaying is managed almost entirely programmatically, means very limited use of css files and no use at all of xml ui files.
How can I manage this ?
Thanks
Use a SimplePanel as a container for your views returned by your Navigation class instead of adding them directly to root panel, and use that instance of SimplePanel where ever you want.

AJAX Page Loader navigation bar

My site is:
http://econrespuestas.com.ar
And i'm having trouble with AJAX page loader integration. When you click on a link in "secondary-menu", it adds it the "current-menu-item" class, but it doesn't remove de "current-menu-item" class from the other ones.
I'm trying to do it with this code:
// highlight the current menu item
jQuery('secondary-menu li').each(function() {
jQuery('thiss').removeClass('current-menu-item');
});
jQuery(thiss).parents('li').addClass('current-menu-item');
but it isn't working. There must be something wrong with the removeClass selector. Could you help me?
Firstly, thiss doesn't exist (unless declared somewhere else). It must be this. In addition try something more like...
jQuery('.current-menu-item').removeClass('current-menu-item');
jQuery(this).parents('li').addClass('current-menu-item');
This is saying "Remove the class current-menu-item from any objects with the class current-menu-item, then add the class current-menu-item to the parent li of the clicked item"
In addition, make sure that in your CSS, .current-menu-item{...} appears after any styling for the non-currently selected item.
See Fiddle: http://jsfiddle.net/6hR9K/2/
Also, unless you have a specific conflict with using the $ sign in place of jQuery, I suggest doing exactly that.
$('.current-menu-item').removeClass('current-menu-item');
$(this).parents('li').addClass('current-menu-item');

Flex 4 Alternative to partAdded() in an ItemRenderer

I'm working on an application which uses a List and some itemRenderers. I have a button displayed in the "selected" state automatically set by the List component. This button is supposed to dispatch a custom event when clicked. Problem is, I don't know how to add my event listener, and I don't want to use 'click=""' because it's kinda dirty IMHO.
/
If it was a SkinnableContainer, I could override the partAdded() but I couldn't find anything similar in the ItemRenderer or the DataRenderer.
Any hints?
Thanks !
You may use the button creationComplete event to add the listener.
Or, for complex itemRenderers I usually create my own that extends SkinnableComponent and implements IDataRenderer. You can then override partAdded/partRemoved functions. Note that you will also need to define and support the skin states (hovered, selected...).

prism switch between views in the same region

I have a region named "ActiveModule" and want to re-use it with different views, for example you press the search button and I show the search view in there, etc. etc.
The only way I can ATM do that is to deactivate all the active views in that region and then activate the view I like, this is a bit dirty, is there a "viewManager" or something similar I can use?
If your region is a ContentControl or derives from ContentControl, then there can only be one active view at a time, and you only need to activate the search view on the region.
Did you consider to use a type of contentControl that is able to show multiple views?
For example you can use a TabControl like this:
<TabControl Name="MainRegion" Regions:RegionManager.RegionName="MainRegion"/>
You can now add more than one view to the region. Use INavigationAware and IActiveAware interfaces from Prism to be able to do navigation on the views (activate them, find the correct view etc.).
If you are using a IRegionManager, you can remove all of the views whose types you recognize and then add your own.
foreach (var view in _regionsManager.Regions["MyRegion"].Views.ToArray())
{
if (view is MyType ||
view is MyOtherType)
_regionsManager.Regions["MyRegion"].Remove(view);
}
_regionsManager.AddToRegion("MyRegion", typeof(MyView));
Its by no means ideal, but it works. :)
To my knowledge what you are doing is the only way, theoretically in SCSF the top most view was activated by the framework. You could create ur own ViewManager or a ShowViewService equivalent to get this done. MAtter of fact, thats what i have done!
Not sure how you laid out your framework but if you are using navigation related framework you can simply call
regionManager.RequestNavigate(RegionNames.MainContentRegion, new Uri("your target view" + parameters, UriKind.Relative));
the above line will take care of deactivating other views in the region.
Otherwise if you do view discovery or view injection you can use the approach here
region.Activate(view);

Resources