Hello,
Why getEditedEntity()
or mycompDc.getItem()
throws IllegalStateException: Current item is null, (under onInit
event)?
It works only if I put them inside of a Listener.
How such behavior?
Best Regards,
-n
Hello,
Why getEditedEntity()
or mycompDc.getItem()
throws IllegalStateException: Current item is null, (under onInit
event)?
It works only if I put them inside of a Listener.
How such behavior?
Best Regards,
-n
@neutrino You can use the AfterShowEvent
- this works for me.
public void onAfterShow(AfterShowEvent event) {}
Hello!
getEditedEntity()
- when the screen is shown, returns an instance of the entity being edited.
In InitEvent and AfterInitEvent listeners, this method returns null. In BeforeShowEvent listener, this method returns the instance passed to the screen for editing.
Best Regards,
Mariya
Hello Marya,
Thank you for your kind answer.
I have a many-to-many relation A and B.
Let say I need to edit entity A and I have a list:
List<B> lp = getEditedEntity().getB();
if (!lp.isEmpty()) {
//logic
}
When I Create a new A entity it throws NullPointerException.
If I edit A it’s fine.
I used with try catch (NullPointerException) but is temporary solution.
What should be != null
in this case?
Hi,
Could you provide a full stacktrace for the error?