Adding dashboard to screen programatically

Hi

I’ve successfully added the dashboard addon to our application and also created a number of dashboards. I’ve also managed to add a default dash to the ext-mainWindow screen using XML code:

<dashboard:dashboard id=“dashboardId”
code=“FinDash02”
timerDelay=“10”>
<dashboard:parameter name=“role”
type=“string”
value=“Admin”/>
</dashboard:dashboard>

Unfortunately having this hard coded causes login problems if the dashboard no longer exists (ie user has deleted or is on a completely new instance with no dashboards setup. I have not been able to find a suggested workaround for this but think it could be resolved by programmatically adding the dashboard to the ext-mainWindow by looking in the appropriate dashboard data tables to see if and what exists for the logged in user.

Is there a way to add the dashboard component to the screen programmatically? I have tried adding the dashboard using the usual componentsfactory.createcomponent but this has not been successful.

Any help would be appreciated as it is a great addon and really want to be able to use it. Obviously if there is a better way to achieve this than I’ve suggested then please feel free to suggest.

Thanks
David

1 Like

Hi,

Please try to use following code to select correct dashboard in your main window:

public class ReferenceDashboardController extends AppMainWindow {

    @Inject
    protected DashboardFrame dashboard;

    @Override
    public void init(Map<String, Object> params) {
        super.init(params);
        dashboard.setCode("demo-dashboard");
    }
}

Hi
If the application has more than one dashboard, which one will be displayed? Is there any way to set a default dashboard of the user?

Hi,

You will need to write code in main screen controller which will set correct dashboard code depends on your requirements