Injecting styles - check if style already exists? Or clear/remove existing page styles?

Hi Cuba Support,

I am injecting css styles into CalendarEvents to style the events how we would like.

Page.Styles styles = Page.getCurrent().getStyles();
                ".%s { background-color: %s!important; color:%s!important; border: %s 2px solid!important;}",
                styleName, backgroundColor, fontColor, borderColor));

This works fine except the same styles get injected multiple times - is there any way around this?

Can styles be checked before being added or can they be cleared/removed in some way?

Any help is appreciated.

Kind Regards



Styles has check only for Resource type styles. You can try to move your CSS code to the file and place it in the theme folder.

public void onInit(InitEvent event) {
    Page.Styles styles = Page.getCurrent().getStyles();
    styles.add(new ThemeResource(""));