Hi
Like we use @windowParam in CUBA, I tried to use the same from JMIX menu to a screen but it is not running.
<item screen="pf_BankCashEntry.browse"
caption="msg://com.inteacc.pf.entity.bankcashentry/bankCashEntryBrowse.menu" id="pf_BankCashEntry.browse">
<properties>
<property name="tranSource" value="general"/>
</properties>
</item>
In Controller:
@WindowParam(name = "tran-source")
private String tranSource;
I also tried this way:
@WindowParam()
private String tranSource;
However, this is returning the null value on the screen.
Is this API still valid or what is the best alternative?
gorelov
(Gleb Gorelov)
March 23, 2022, 8:04am
2
Hi
It has been several months this issue is not fixed yet in Jmix without which I can’t migrate or develop the application I want to develop in Jmix. Can this be prioritized?
krivopustov
(Konstantin Krivopustov)
September 6, 2022, 12:16pm
4
Fixed in 1.3.0 several months ago. See the related issue:
opened 02:22PM - 01 Mar 22 UTC
closed 01:07PM - 21 Jun 22 UTC
size: S
in: ui
As it was in CUBA.
Now `io.jmix.ui.menu.MenuItemCommands#loadParams` always ret… urns an empty collections.
----
### Changes
#### Jmix API
1. Parameters in the screen. It works as described in the documentation: https://docs.jmix.ru/jmix/ui/menu-config.html#item-properties.
I.e. define setter in your screen:
```
@UiController("DemoScreen")
@UiDescriptor("demo-screen.xml")
public class DemoScreen extends Screen {
protected int integerValue;
public void setIntegerValue(int integerValue) {
this.integerValue = integerValue;
}
}
```
And in the menu define parameter:
```
<item screen="DemoScreen" caption="Demo screen">
<properties>
<property name="integerValue" value="99"/>
</properties>
</item>
```
2. Parameters in class or bean. Create Spring Bean:
```
@Component("MenuItemLinkBean")
public class MenuItemLinkBean {
private static final Logger log = LoggerFactory.getLogger(MenuItemLinkBean.class);
public void openParams(Map<String, Object> params) {
log.info("Invoked openParams with map size: " + params.size());
}
}
```
And define parameters in the menu:
```
<item id="openWithParams" bean="MenuItemLinkBean" beanMethod="openParams" caption="Open with params">
<properties>
<property name="count" value="2"/>
<property name="entity" entityClass="com.company.cubamaster.entity.User" entityId="60885987-1b61-4247-94c7-dff348347f93"/>
</properties>
</item>
```
#### Legacy API
1. Create legacy screen in the migrated project:
```
public class DemoWindow extends AbstractWindow {
@Override
public void init(Map<String, Object> params) {
super.init(params);
showNotification("Params size: " + params.entrySet().size());
}
}
```
Add to the menu parameters:
```
<item id="demoWindow" caption="Demo window">
<param name="val" value="2"/>
<param name="entity" value="sec$User-60885987-1b61-4247-94c7-dff348347f93"/>
</item>
```
`@WindowParam` also works but values from the menu has the String type (excluding Boolean and entity types).
### QA
Check above cases.
Thank you. But I tried before posting but didn’t work.
krivopustov
(Konstantin Krivopustov)
September 9, 2022, 10:58am
6
Please give us a reproducible case of what is not working.