DefaultMenuItem setCommand doesn't work

jQuery UI Widgets
Post Reply
Peduz
Posts: 3
Joined: 09 Nov 2016, 13:56

09 Nov 2016, 13:59

I followed the the primefaces guide for making a dynamic menu. I need to set an ajax method on every menuItem, so I did this:

Code: Select all

/* Costruttore */
    public MenuBean() {
        this.model = new DynamicMenuModel();
    }    
    @Override
    protected void initBeanData()
    {
        try {
            PrsfgApplicationURLEnum[] tabModel = PrsfgApplicationURLEnum.values();
            DefaultSubMenu firstSubmenu = new DefaultSubMenu();
            for(PrsfgApplicationURLEnum item : tabModel) {
                DefaultMenuItem dmi = new DefaultMenuItem(item.getLabel());
                dmi.setId(item.getLabel());
                dmi.setUrl(item.getUrl());
                dmi.setCommand("#{menuBean.onItemSelect()}");
//                dmi.setParam("appName", new String(item.getLabel()));
//                dmi.setUpdate("@(.fittiziaLayout)");
                firstSubmenu.addElement(dmi);
            }
            model.addElement(firstSubmenu);
        } catch(Exception e) {
            log.error("Errore in fase di creazione del modello del tab menu");
            log.error(e.getMessage());
            e.printStackTrace();
        }
    }

    public void onItemSelect() {
        System.out.println("");
        this.selectedApplication = ""; //event.getMenuItem().getParams().get("appName").get(0);
    }
But it doesn't work. I put a breakpoint on onItemSelect() when I click on one menuItem but it doesn't stop on it, so I think it doesn't work. I also tried to set some parameters, in fact I need to know what's the selected item. I also tried to set a String on setCommand that didn´t have the parentheses but this way it also didn´t work.

Thanks.

Post Reply

Return to “PrimeUI”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 13 guests