Use o:cache / p:cache for p:menu

Forum rules
Please note that response time for technical support is within 3-5 business days.
vished
Posts: 479
Joined: 02 Feb 2014, 17:38

26 Apr 2021, 16:31

@rider, did you got an update from Primetek???
PF 8.0

siris
Posts: 322
Joined: 29 Jul 2019, 13:57

04 May 2021, 12:29

Hi,

Sorry for delayed response! We released new update. Please check with new version and sample p:cache:

firstly add this dependency to the your pom.xml

Code: Select all

        <dependency>
            <groupId>net.sf.ehcache</groupId>
            <artifactId>ehcache</artifactId>
            <version>2.10.6</version>
        </dependency>
after than add these lines to your web.xml file

Code: Select all

    <context-param>
        <param-name>primefaces.CACHE_PROVIDER</param-name>
        <param-value>org.primefaces.cache.EHCacheProvider</param-value>
    </context-param>
create new file as src/main/webapp/WEB-INF/ehcache.xml with these sample codes:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true"
         monitoring="autodetect" dynamicConfig="true">
    
    <diskStore path="java.io.tmpdir" />

    <!-- Sample cache named myCache
         This cache contains a maximum in memory of 10000 elements, and will expire
         an element if it is idle for more than 5 minutes and lives for more than
         10 minutes. If there are more than 10000 elements it will overflow to the
         disk cache -->
    <cache name="myCache"
           statistics="true"
           maxEntriesLocalHeap="10000"
           maxEntriesLocalDisk="1000"
           eternal="false"
           diskSpoolBufferSizeMB="20"
           timeToIdleSeconds="300" timeToLiveSeconds="600"
           memoryStoreEvictionPolicy="LFU"
           transactionalMode="off">
        <persistence strategy="localTempSwap" />
    </cache>
</ehcache>
You are ready for use p:cache. So add p:cache tag whatever you want! Especially to the tabMenu:

Code: Select all

<p:cache region="myCache">
        <pm:tabMenu id="tabMenu">
        	.
        	<!-- Some menu codes-->
        	.
        </pm:tabMenu>
</p:cache>
Best Regards,

rider
Posts: 497
Joined: 05 Mar 2010, 13:17

05 May 2021, 10:12

Thanks for the update. I´ve updated to PF 10 and this template (version 3.0)

I´ve tried that, but it´s still not working for me:

Code: Select all

<p:cache region="myCache">
<h:form>
		<pm:tabMenu id="tabMenu" stateful="true" >

			<pm:tab id="dashboardTab" icon="fa fa fa-tachometer"
				title="ALLGEMEIN">		

					<pm:menu>
						<p:menuitem value="Dashboard" icon="fa fa-fw fa-tachometer"
							onclick="PF('statusDialog').show()" outcome="/portal/dashboard" />

						<p:menuitem value="Alle Dashboards" icon="fa fa-fw fa-list"
							rendered="#{checkPermissionController.checkPermission('dashboard:showAll')}"
							onclick="PF('statusDialog').show()"
							outcome="/portal/dashboardList" />
					</pm:menu>
		
			</pm:tab>
As soon I´ve clicked than on a pm:tab / or menu, my url changed to: http://localhost:8080/portal/dashboard.jsf# (with a "#").
Seems like also other ajax menus are not working like the menu in the right corner from the template.

How can this be fixed?
Primefaces 12.0, WildFly 21

siris
Posts: 322
Joined: 29 Jul 2019, 13:57

05 May 2021, 15:12

Hi,

Sorry but I could not reproduce your issue. Please try without "<h:form>" component. As far as I know, there should not be nested forms and I think you have already defined a menuform to create a menu. As in the Template project. Because nesting forms is illegal in HTML, so also in JSF since all it does is just generating HTML. You need to put them next to each other. Also, a config in your web.xml file or project settings or server version or what server software you use may be causing this. If you try the above codes with tag folder in the new version, you can see that there is no issue. If you want, if you create a test project with this issue and send me an e-mail via "m.buunsal@gmail.com", I can examine it in detail.

I also noticed that you are using the ".jsf" page extension. The issue may also be caused by this. Submitting a test project will provide the fastest solution.

Best Regards,

Post Reply

Return to “Morpheus - PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests