I have the following entity relationship in my structure:
ParentJob
(Shared Attributes)
Child: Job, Child: DraftJob
They are all basically the same (the only difference is D-Type).
I am trying to create one editor screen that can be used for all types of Job (as long as they extend ParentJob)
Is this possible?
I have extended ParentJobEdit and called it JobEdit - the xml extends fine but the screen controller still thinks it’s a ParentJob instead of the child class. (GetEditedEntity returns ParentJob instead of Job)
I have already looked at the documentation and it doesn’t document properly the use case I mention above.
When you extend an edit screen - getEditedEntity returns the parent object rather than the new entity type you are extending the screen to be used with.
My question is whether that return type can be specified somewhere to return the new entity to be edited.
Thanks for the demo project.
In my opinion, you did everything right, and getEditedEntity() in JobEdit actually returns an instance of Job (descendant).
Try to add the following code to JobEdit:
@Subscribe
public void onAfterShow(AfterShowEvent event) {
ParentJob editedEntity = getEditedEntity();
if (editedEntity instanceof Job) {
System.out.println("editedEntity is actually Job");
} else {
System.out.println("editedEntity is " + editedEntity.getClass());
}
}