Rendered and ajax

UI Components for JSF
Post Reply
pejovica
Posts: 4
Joined: 03 Apr 2010, 03:11

07 Apr 2010, 18:27

Hi. I'm trying to use rendered attribute to show/hide parts of UI with ajax, but I couldn't quite get it to work. I'm using something like this:

Code: Select all

<h:panelGroup id="menuPlaceholder" layout="block">
    <h:panelGroup layout="block" rendered="#{someBean.isRendered}">
        <h:form>
            <p:menu>
                ...
            </p:menu>
        </h:form>
    </h:panelGroup>
</h:panelGroup>
Basically, showing/hiding of menu is working, but the problem is that after a cycle of show-hide-show, the dynamic behavior/styling of menu is gone (for example when I move mouse over a menu item it doesn't get highlighted). Is this a bug or I'm doing something wrong?
primefaces-2.0.2 / mojarra-2.0.2 / glassfish v3.0.1

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

08 Apr 2010, 11:07

As I know, menus don't like getting updated with ajax. I remember a similar issue with p:menubar.

Still you can manipulate menus using client side api like getItems, addItem, removeItem eg.

In future version, we'll look into this.

User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

08 Apr 2010, 13:58

cagatay.civici wrote:As I know, menus don't like getting updated with ajax. I remember a similar issue with p:menubar.

Still you can manipulate menus using client side api like getItems, addItem, removeItem eg.

In future version, we'll look into this.
By the way, how can we disable a menuitem - make it not clickable? I have tried with

Code: Select all

mbWidget.getItem(0).cfg.setProperty("disabled", true);
Menuitem gets grey, but it's still clickable and causes an ajax request. YUI documentation says:
Disabled Menu items are dimmed and will not respond to user input or fire events.
Disabled PrimeFaces menuitems fire events. An issue?
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin


User avatar
Oleg
Expert Member
Posts: 3805
Joined: 02 Oct 2009, 09:41
Location: Germany, Black Forest

08 Apr 2010, 21:35

cagatay.civici wrote:There is one already;

http://code.google.com/p/primefaces/iss ... ail?id=713
Yes, sure, I'm aware of this ticket. I meant another issue - not upcoming "disabled" attribute, but JS manipulation. According to the YUI docu the following construct

Code: Select all

menubarWidget.getItem(index).cfg.setProperty("disabled", true);
should prevent onclick event. But it doesn't that. I can click on disabled (dimmed) menuitem and an Ajax request will be sent. The same situation with p:commandLink. I couldn't prevent onclick event per JavaScript and activate it again.

You can try to use jQuery unbind('click') / bind('click', function() {...}) or attr('onclick') and manipulate inline onclick with "return false;" or "event.preventDefault();". Nothing helps, because PrimeFaces writes Ajax call in onclick attribute and the default behavior stays href="javascript:void(0)". It would help if the Ajax call stood in href. Disabling for pure YUI menuitems works as specified because URL resides in href. I spent a whole day and found a workaround - a tricky solution how I can prevent ajax calls with JavaScript and activate them again (original onlick listener). Namely for both cases - PrimeFaces menuitem and command link.
PrimeFaces Cookbook (2. edition): http://ova2.github.io/primefaces-cookbook/ Learning Angular UI Development with PrimeNG: https://github.com/ova2/angular-develop ... th-primeng Blog: https://medium.com/@OlegVaraksin

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 24 guests