Package org.primefaces.model.menu

Examples of org.primefaces.model.menu.DefaultMenuItem


        }
    }

    private void buildStateModel() {
        stateModel = new DynamicMenuModel();
        DefaultMenuItem homeItem = new DefaultMenuItem();
        homeItem.setAjax(false);
        homeItem.setValue("home");
        homeItem.setId(FacesContext.getCurrentInstance().getViewRoot()
                .createUniqueId()
                + "_state_home");
        homeItem.setImmediate(true);
        homeItem.setCommand("#{stateController.clearStateAndGoHome}");
        stateModel.addElement(homeItem);
        for (StateItem stateItem : stateItens) {
            DefaultMenuItem item = new DefaultMenuItem();
            item.setAjax(stateItem.isAjax());
            item.setGlobal(stateItem.isGlobal());
            item.setResetValues(stateItem.isResetValues());
            item.setTitle(stateItem.getTitle());
            item.setImmediate(stateItem.isImmediate());
            item.setValue(getItemValue(stateItem.getValue()));
            if (stateItem.getOncomplete() != null && !"".equals(stateItem.getOncomplete())) {
                item.setOncomplete(stateItem.getOncomplete());
            }
            item.setId(FacesContext.getCurrentInstance().getViewRoot()
                    .createUniqueId()
                    + "_state");
            if (stateItem.getOutcome() != null && !"".equals(stateItem.getOutcome())) {
                item.setIncludeViewParams(true);
                StringBuilder url = new StringBuilder(stateItem.getOutcome());
                if (stateItem.isAddEntityIdParam()) {
                    url.append("?id=").append(((BaseEntity) stateItem.getEntity()).getId());
                }
                if (url.toString().contains("?")) {
                    url.append("&pullState=true");
                } else {
                    url.append("?pullState=true")//tell statePusher to not call preRenderView event
                }
                url.append("&itemIndex=").append(stateItens.indexOf(stateItem));
                item.setUrl(url.toString());
            } else {//if has not outcome set command, note that they are muttually exclusive: http://stackoverflow.com/questions/16437336/using-both-setactionexpression-and-seturl-on-menuitem-object-is-not-working
                item.setCommand("#{stateController.pullStateItem("
                        + stateItens.indexOf(stateItem) + ")}");
            }
            if (!"".equals(stateItem.getUpdate())) {
                item.setUpdate(stateItem.getUpdate());
            }

            if (stateItens.indexOf(stateItem) == stateItens.size() - 1) {
                item.setDisabled(true);
                item.setStyleClass("ui-state-disabled");
            }
            stateModel.addElement(item);

        }
View Full Code Here

TOP

Related Classes of org.primefaces.model.menu.DefaultMenuItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.