Hi,
I was trying to use PaperStack add one published recently. However I have a requirement to keep the same layout object but change its data when the page is flipped. I even tried to wrap my layout so that PaperStack takes all 3 as new elements. That also does not help and I dont see anything on screen. How can I re-use the same layout for all the pages in the PaperStack
PaperStack p = new PaperStack();
MyLayout m = new MyLaput();
p.addComponent(new MyWrapper(m));
p.addComponent(new MyWrapper(m));
p.addComponent(new MyWrapper(m));
I want to see 3 pages with the same layout object ‘m’ on them.
However if I do this, it works as expected
PaperStack p = new PaperStack();
p.addComponent(new MyWrapper(new MyLaput()));
p.addComponent(new MyWrapper(new MyLaput()));
p.addComponent(new MyWrapper(new MyLaput()));
p.addComponent(new MyWrapper(new MyLaput()));
please let me know how can I achieve this. I tried to make equals & hashCode unique that also doesn’t seem to help.
You can’t do that. You can’t put the same component instance in two places in the UI. You have to do it as you do it in the second example.
I don’t know why you would need to use the same layout instance multiple times, but I’m sure that you can find a workaround. If the layouts share some parameters, for example, you should make a mechanism to communicate them between them. They can always share a regular Java object by reference, although you may need to communicate (with an event) changes to the object to each component (listener).
My use case is very simple (and probably most common).
I want to use this PaperStack to show the record in a simple layout. That means I have the same layout and every flip is change the data in the fields of this layout. Will that not be possible at all?
Hi Dheeraj
That is unfortunately not possible. PaperStack displays two components at the same time as the view is being changed but those two cannot be the same exact component.
Moreover, one Vaadin component can’t have two different states at the same time (view2 containing the updated version of the same component on view1).
You can however place a temporary component after view1, and on page change update view1, remove it form the PaperStack and then add it back to be displayed next.