Serenity dynamic menu not working after migrating to 2.0.1

Forum rules
Please note that response time for technical support is within 3-5 business days.
Post Reply
User avatar
Zurcus
Posts: 3
Joined: 25 Feb 2020, 12:04

07 Aug 2020, 11:52

The application that I am working on is running JSF 2.3 and PrimeFaces 8.0. It had been running on Serenity 2.0.0 for quite some time, but after updating PrimeFaces from 7.0 to 8.0 we started having trouble with the schedule component and that got fixed with a Serenity update. We jumped from 2.0.0 to 2.1.1 and then the menu went static. There was no action happening on mouse hover and whatever I tried the layout-sidebar-active was never added to the XHTML element.
After examining the SerenityMenuRenderer inside of the jar file I saw there was only one difference between the two versions.
2.0.0

Code: Select all

    protected void encodeScript(FacesContext context, AbstractMenu abstractMenu) throws IOException {
        SerenityMenu menu = (SerenityMenu)abstractMenu;
        String clientId = menu.getClientId(context);
        WidgetBuilder wb = this.getWidgetBuilder(context);
        wb.init("Serenity", menu.resolveWidgetVar(), clientId).attr("closeDelay", menu.getCloseDelay()).finish();
    }
2.1.1

Code: Select all

    protected void encodeScript(FacesContext context, AbstractMenu abstractMenu) throws IOException {
        SerenityMenu menu = (SerenityMenu)abstractMenu;
        String clientId = menu.getClientId(context);
        ResponseWriter rw = context.getResponseWriter();
        rw.startElement("script", (UIComponent)null);
        rw.writeAttribute("id", clientId + "_s", (String)null);
        rw.writeAttribute("type", "text/javascript", (String)null);
        rw.write("PrimeFaces.cw(\"Serenity\",\"");
        rw.write(menu.resolveWidgetVar());
        rw.write("\",{id:\"");
        rw.write(clientId);
        rw.write("\",");
        rw.write("closeDelay:\"");
        rw.write(Integer.toString(menu.getCloseDelay()));
        rw.write("\"");
        rw.write("});");
        rw.endElement("script");
    }
The solution I found was to take the old renderer class and put it inside the new jar file and make some kind of Frankenstein serenity jar from both versions. Could someone tell me what was the cause of this and If there is a better solution regarding the problem? I guess the problem lies in the usage of the response writer instead of the widget builder, but my knowledge took me so far.

Thank you in advance.

mert.sincan
Posts: 5281
Joined: 29 Jun 2013, 12:38

12 Sep 2020, 14:49

Sorry for the delayed response! Unfortunately, I couldn't replicate this issue with the dynamic menu in our sample project. Could you please try our sample project? Also, due to the menu flickering issues reported by Serenity Users, we changed it.

Best Regards,

Post Reply

Return to “Serenity - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests