Hi
I would like to change the Editor screen caption depending on the item properties (see code below), but this has no effect.
@Override
protected void initNewItem(Customer item) {
setCaption(item.getInternalCode());
rules.initNewItem(item);
}
EDIT : it works if called from init() method see below, but why caption can not be changed afterwards ?
@Override
public void init(final Map<String, Object> params) {
Customer item = WindowParams.ITEM.get(params);
setCaption(item.getInternalCode());
}
Mike
kxb_pro
(Kirill Khoroshilov)
December 27, 2017, 11:11pm
#2
Hey!
See sources AbstractWindow (AbstractEditor extends AbstractWindow)
* Set the screen caption. If called in {@link #init(java.util.Map)}, overrides the value from XML.
Use postInit() method
@Override
protected void postInit(){
Customer item= getItem();
String caption = messages.formatMessage(getClass(), “customerEditor.caption”, (item.getInternalCode()!= null) ? " ‘" + item.getInternalCode() + "’" : “”);
getFrame().setCaption(caption);
}
and add new entry to screen messages:
customerEditor.caption=Customer%s
Thanks for the tip, it works. Calling setCaption in init() was also working but it is limited by a minimal item.
Looking to AbstractEditor.setItem() implementation I’m stil not clear why it does not work in initNewItem(), but, hey, job done, and this is cleaner.
1 Like
kxb_pro
(Kirill Khoroshilov)
December 28, 2017, 11:23am
#4
Hey, @michael.renaud
Mark post as solution, please