Output to different edit screen

I am following the tutorial, download and run the git project on https://www.cuba-platform.com/guides/intro-working-with-data-in-cuba. On the method
" private void openVisitDetails(Visit visit) {
screenBuilders
.editor(Visit.class, this)
.editEntity(visit)
.withLaunchMode(OpenMode.NEW_TAB)
.build()
.show();

}

of public class CreateVisitForPet extends Screen

I want to create a second edit screen for Visit class which can be used for creating a Pet visit (Now it seems editing a pet visit and creating a pet visit using the same form. How can i pass data to that second edit screen ? I tried this but fails

screenBuilders
.editor(Visit.class, VisitEdit2.class)
.editEntity(person)
.withLaunchMode(OpenMode.NEW_TAB)
.build()
.show();

It shows error : VisitEdit2 is not compatible to the frameowner
"

Hi,

You need to pass a reference to the owner, not the class name. For example, if you have three screens: VisitBrowse, VisitEdit and PersonEdit, then when you need to call PersonEdit from VisitEdit like this:

screenBuilders.editor(Person.class, this).editEntity(person)...

The first parameter - is an entity class name and the second - reference to the screen that invokes the editor.

My situation is not like that. I created two different screens for same entity. PersonEdit and PersonEdit2. On the PersonBrowser, i want pass the data of one person instance to the person edit screen 2

screenBuilders.editor(Person.class, this).editEntity(person)

That code above works when two screens are from totally different Entities. Anyway i found this way to work. I don’t know it has any side effects though

screenBuilders
.editor(Person.class, this).withScreenClass(PersonEdit2.class)
.editEntity(person)
.withLaunchMode(OpenMode.NEW_TAB)
.build()
.show();

2 Likes