chfoong
(FOONG CHEE HAO)
May 28, 2025, 12:27am
1
Hi ,
I have issue on Tabs component. There are child components <tab> in <tabs>. I’m able to inject the <tab> into controller. Eg.
@ViewComponent
private Tabs carouselTabs;
@ViewComponent("carouselTabs.newRequestTab")
private Tab carouselTabsNewRequestTab;
<tabs id="carouselTabs" width="100%" themeNames="centered">
<tab id="newRequestTab">
<div>
<p id="newRequestCount"/>
<p text="msg://newRequest"/>
</div>
</tab>
</tabs>
But , It always complain that “this.carouselTabsNewRequestTab” is null when I open the screen.
Jmix version: 2.5.1
Jmix Studio Plugin Version: 2.5.1-243
Thank you for your help ~
Hi
Can it be a typo ?
carouselTabsNewRequestTab
this.carouselTabsDraftRequestTab
NewRequest != DraftRequest
Regards
Felix
chfoong
(FOONG CHEE HAO)
May 28, 2025, 7:39am
3
Hi ,
This is the correct code below:
<tabs id="carouselTabs" width="100%" themeNames="centered">
<tab id="newRequestTab">
<div>
<p id="newRequestCount"/>
<p text="msg://newRequest"/>
</div>
</tab>
</tabs>
@ViewComponent("carouselTabs.newRequestTab")
private Tab carouselTabsNewRequestTab;
carouselTabsNewRequestTab.setVisible(true);
Caused by: java.lang.NullPointerException: Cannot invoke “com.vaadin.flow.component.tabs.Tab.setVisible(boolean)” because “this.carouselTabsNewRequestTab” is null
It is not typo. Same error as above.
Thank you for ur help ~
Hi
A small testproject would help ;/
I don’t see in which context you use carouselTabsNewRequestTab.
Did you check with the https://demo.jmix.io/ui-samples/sample/tabs-orientation?tab=TabsOrientationSample.java ?
Regards
Felix
krivopustov
(Konstantin Krivopustov)
May 28, 2025, 1:18pm
6
I can confirm that the tab of a Tabs component cannot be injected into view controller.
Created issue: Tab of Tabs component is not injected into view controller · Issue #4476 · jmix-framework/jmix · GitHub
As a workaround, you can find the tab programmatically, for example:
@ViewComponent
private Tabs carouselTabs;
@Subscribe
public void onReady(final ReadyEvent event) {
carouselTabs.getTabAt(0).setEnabled(false);
}
Also, consider using the TabSheet layout: tabSheet :: Jmix Documentation .
Regards,
Konstantin