the menu in sidebar does not work with ajax it only works with ajax false.
I tested it in your own application.
<pc:menu widgetVar="me" >
<p:menuitem id="om_dashboard" value="Dashboard" icon="fa fa-fw fa-home" outcome="/dashboard"/>
<p:submenu id="om_themes" label="Themes" icon="fa fa-fw fa-paint-brush">
<f:attribute name="badge" value="20" />
<p:submenu id="om_themes_flat" label="Solid" icon="fa fa-fw fa-paint-brush">
<p:submenu id="theme1" label="Blue" icon="fa fa-fw fa-paint-brush">
<p:menuitem id="blue_custom0" value="Light" icon="fa fa-fw fa-square-o" actionListener="#{mainUserCtrlSBean.setMenuMode(false, false, 'blue')}" process="@this" ajax="true"/>
<p:menuitem id="blue_custom1" value="Dark" icon="fa fa-fw fa-square" actionListener="#{mainUserCtrlSBean.setMenuMode(true, false, 'blue')}" ajax="false"/>
<p:menuitem id="blue_custom2" value="Gradient" icon="fa fa-fw fa-square" actionListener="#{mainUserCtrlSBean.setMenuMode(true, true, 'blue')}" ajax="false"/>
</p:submenu>
can you help me
Thank you
Running on PrimeFaces 6.1.13
Running GlassFish Version: GlassFish Server Open Source Edition 5.0 (build 25)
Initialisation de Mojarra 2.3.2
sidebar menu doesn't work with ajax
Forum rules
Please note that response time for technical support is within 3-5 business days.
Please note that response time for technical support is within 3-5 business days.
-
- Posts: 5281
- Joined: 29 Jun 2013, 12:38
The default value of ajax attribute in Menuitem is "true".
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>california-#{guestPreferences.theme}</param-value>
</context-param>
it is very difficult to do so using ajax="true".
Regards,
- It is an expected behavior. You need to re-render all files related to #{guestPreferences.theme}. Exp;the menu in sidebar does not work with ajax it only works with ajax false.
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>california-#{guestPreferences.theme}</param-value>
</context-param>
it is very difficult to do so using ajax="true".
Regards,
Github Profile: https://github.com/mertsincan
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
To change the theme with ajax without updating whole page, you need to do an ajax command but at oncomplete, change the path of the style tag;
Code: Select all
<h:outputStylesheet id="theme-link" name="css/layout-#{guestPreferences.theme}.css" library="california-layout" />
Code: Select all
<p:menuitem id="blue_custom0" value="Light" icon="fa fa-fw fa-square-o" actionListener="#{mainUserCtrlSBean.setMenuMode(false, false, 'blue')}" process="@this" ajax="true"
onComplete="changeTheme('blue')"/>
[code]
[code]
changeTheme(theme) {
var link = document.getElementById('theme-link');
var currentHref = link.attr('href'); //something like '"/california/javax.faces.resource/css/layout-blue.css.xhtml?ln=california-layout"';
var newHref = //change the layout-blue.css with layout-{theme}.css
themeLink.attr('href', newHref);
}
[code]
-
- Information
-
Who is online
Users browsing this forum: No registered users and 9 guests