Package org.richfaces.component

Examples of org.richfaces.component.UIMenuItem


     * @param parent
     *            parent component for created item
     * @throws IOException
     */
    protected void buildGroupMenuItem(UIComponent parent) throws IOException {
        UIMenuItem menuItem = (UIMenuItem) context.getApplication()
                .createComponent(UIMenuItem.COMPONENT_TYPE);

        menuItem.setSubmitMode("none");
        menuItem.setId(getId("group"));
        String actionScript = null;
        StringBuilder actionScriptBuilder = new StringBuilder();
        boolean isGroupingColumn = column.getId().equalsIgnoreCase(
                table.getGroupByColumnId());
        if ((Boolean) column.getAttributes().get("sortable")) {
            if (groupFunction != null) {
                if (prepareFunction != null) {
                    actionScriptBuilder.append(prepareFunction.toScript()).append("; ");
                }
                actionScriptBuilder.append(groupFunction.toScript());
                actionScript = actionScriptBuilder.toString();
                if (actionScript.contains("{columnId}")) {
                    String columnClientId = (String) column.getAttributes().get("columnClientId");
                    if (columnClientId == null)
                        columnClientId = column.getClientId(context);
                    if (isGroupingColumn) {
                        columnClientId = "";
                    }
                    actionScript = actionScript.replace("{columnId}", columnClientId);
                }
            }
        } else {
            menuItem.setDisabled(true);
        }

        menuItem.setValue(ComponentMessageUtil.getMessage(context,
                (isGroupingColumn ? MSG_GROUP_OFF : MSG_GROUP_ON),
                new Object[] {}).getSummary());
        menuItem.setIcon(iconGroupURI);
        if (menuItem instanceof HtmlMenuItem) {
            ((HtmlMenuItem) menuItem)
                    .setOnclick(actionScript == null ? "return false;"
                            : actionScript);
        }
View Full Code Here


     */
    protected void buildMenuItem(UIComponent parent, UIColumn col)
            throws IOException {
     
        if (col.isRendered(false)) {
            UIMenuItem menuItem = (UIMenuItem) context.getApplication()
                    .createComponent(UIMenuItem.COMPONENT_TYPE);
            menuItem.setId(parent.getId() + '_' + col.getId());
            menuItem.setSubmitMode("none");
            menuItem.setStyle("text-align: left;");

            String label = (String)col.getAttributes().get("label");
            menuItem.setValue(label == null ? "" : label);

            boolean columnVisible = col.isVisible();

            String actionScript = null;
            if (!columnVisible || (visibleColumnsCount > 1)) {
                if (changeColumnVisibilityFunction != null) {
                    StringBuilder actionScriptBuilder = new StringBuilder();
                    if (prepareFunction != null) {
                        actionScriptBuilder.append(prepareFunction.toScript()).append("; ");
                    }
                    actionScriptBuilder.append(changeColumnVisibilityFunction.toScript());
                    actionScript = actionScriptBuilder.toString();
                    if (actionScript.contains("{columnId}"))
                        actionScript = actionScript.replace("{columnId}", col.getId());
                }
            }// if

            menuItem.setIcon(columnVisible ? iconCheckedURI : iconUncheckedURI);
            if (menuItem instanceof HtmlMenuItem) {
                ((HtmlMenuItem) menuItem).setOnclick(actionScript == null ? "return false;" : actionScript);
            }

            // add item to menu
View Full Code Here

    String itemId = null;
    int flcloseonclick = 1;
    int flagGroup = 0;
    boolean disabled = false;
    if (kid instanceof UIMenuItem) {
      UIMenuItem menuItem = (UIMenuItem) kid;
      itemId = kid.getClientId(context);
      disabled = menuItem.isDisabled();
      if (disabled) {
        flcloseonclick = 0;
      }
    } else if (kid instanceof UIMenuGroup) {
      UIMenuGroup menuGroup = (UIMenuGroup) kid;
View Full Code Here

        Map rqMap = exCtx.getRequestParameterMap();
        Object clnId = rqMap.get(component.getClientId(context));
        if (clnId == null) {
            clnId = rqMap.get(component.getClientId(context) + ":hidden");
        }
        UIMenuItem menuItem = (UIMenuItem) component;
        if (clnId != null) {

            // enqueue event here for this component or for component with Id
            // taken from forId attribute

            String mode = resolveSubmitMode(menuItem);
            if (!MenuComponent.MODE_NONE.equalsIgnoreCase(mode)) {

                ActionEvent actionEvent = new ActionEvent(menuItem);
               
                if(MenuComponent.MODE_AJAX.equalsIgnoreCase(mode)){
                new AjaxEvent(menuItem).queue()
              }
               
                if (menuItem.isImmediate()) {
                  actionEvent.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
                 
                } else {
                    actionEvent.setPhaseId(PhaseId.INVOKE_APPLICATION);
                }
                menuItem.queueEvent(actionEvent);
            }
        }
    }
View Full Code Here

        }
    }
    // find and encode UIParameter's components
    public List encodeParams(FacesContext context, UIMenuItem component) throws IOException {
     
      UIMenuItem menuItem = component;
      List params = new ArrayList();
      StringBuffer buff = new StringBuffer();
     
      List children = menuItem.getChildren();
      for (Iterator iterator = children.iterator(); iterator.hasNext();) {
        UIComponent child = (UIComponent) iterator.next();
       
        if(child instanceof UIParameter){
         
View Full Code Here

     *            sort direction
     * @throws IOException
     */
    protected void buildSortMenuItem(UIComponent parent, boolean asc)
            throws IOException {
        UIMenuItem menuItem = (UIMenuItem) context.getApplication()
                .createComponent(UIMenuItem.COMPONENT_TYPE);

        menuItem.setSubmitMode("none");
        String actionScript = null;
        StringBuilder actionScriptBuilder = new StringBuilder();
        if ((Boolean) column.getAttributes().get("sortable")) {
            if (sortFunction != null) {
                if (prepareFunction != null) {
                    actionScriptBuilder.append(prepareFunction.toScript())
                            .append("; ");
                }

                actionScriptBuilder.append(sortFunction.toScript());
                actionScript = actionScriptBuilder.toString();
                if (actionScript.contains("{columnId}")) {
                    String columnClientId = (String) column.getAttributes()
                            .get("columnClientId");
                    if (columnClientId == null)
                        columnClientId = column.getClientId(context);
                    actionScript = actionScript.replace("{columnId}",
                            columnClientId);
                }
                if (actionScript.contains("{sortDirection}"))
                    actionScript = actionScript.replace("{sortDirection}",
                            asc ? "asc" : "desc");
            }
        } else {
            menuItem.setDisabled(true);
        }
        menuItem.setValue(ComponentMessageUtil.getMessage(context,
                (asc ? MSG_SORT_ASC : MSG_SORT_DESC), new Object[] {})
                .getSummary());
        menuItem.setIcon((asc ? iconSortAscURI : iconSortDescURI));
        if (menuItem instanceof HtmlMenuItem) {
            ((HtmlMenuItem) menuItem)
                    .setOnclick(actionScript == null ? "return false;"
                            : actionScript);
        }
View Full Code Here

     * @param parent
     *            parent component for created item
     * @throws IOException
     */
    protected void buildGroupMenuItem(UIComponent parent) throws IOException {
        UIMenuItem menuItem = (UIMenuItem) context.getApplication()
                .createComponent(UIMenuItem.COMPONENT_TYPE);

        menuItem.setSubmitMode("none");
        String actionScript = null;
        StringBuilder actionScriptBuilder = new StringBuilder();
        boolean isGroupingColumn = column.getId().equalsIgnoreCase(
                table.getGroupingColumnId());
        if ((Boolean) column.getAttributes().get("sortable")) {
            if (sortFunction != null) {
                if (prepareFunction != null) {
                    actionScriptBuilder.append(prepareFunction.toScript())
                            .append("; ");
                }
                actionScriptBuilder.append(groupFunction.toScript());
                actionScript = actionScriptBuilder.toString();
                if (actionScript.contains("{columnId}")) {
                    String columnClientId = (String) column.getAttributes()
                            .get("columnClientId");
                    if (columnClientId == null)
                        columnClientId = column.getClientId(context);
                    if (isGroupingColumn) {
                        columnClientId = "";
                    }
                    actionScript = actionScript.replace("{columnId}",
                            columnClientId);
                }
            }
        } else {
            menuItem.setDisabled(true);
        }

        menuItem.setValue(ComponentMessageUtil.getMessage(context,
                (isGroupingColumn ? MSG_GROUP_OFF : MSG_GROUP_ON),
                new Object[] {}).getSummary());
        menuItem.setIcon(iconGroupURI);
        if (menuItem instanceof HtmlMenuItem) {
            ((HtmlMenuItem) menuItem)
                    .setOnclick(actionScript == null ? "return false;"
                            : actionScript);
        }
View Full Code Here

     */
    protected void buildMenuItem(UIComponent parent, UIColumn col)
            throws IOException {
        if (col instanceof UIColumn) {
            UIColumn dataColumn = (UIColumn) col;
            UIMenuItem menuItem = (UIMenuItem) context.getApplication()
                    .createComponent(UIMenuItem.COMPONENT_TYPE);

            menuItem.setSubmitMode("none");
            Boolean v = dataColumn.isVisible();
            boolean columnVisible = (v == null ? Boolean.TRUE : v);
            String actionScript = null;
            StringBuilder actionScriptBuilder = new StringBuilder();

            menuItem.setStyle("text-align: left;");

            if ((!columnVisible) || (visibleColumnsCount > 1)) {
                if (changeColumnVisibilityFunction != null) {
                    if (prepareFunction != null) {
                        actionScriptBuilder.append(prepareFunction.toScript())
                                .append("; ");
                    }
                    actionScriptBuilder.append(changeColumnVisibilityFunction
                            .toScript());
                    actionScript = actionScriptBuilder.toString();
                    if (actionScript.contains("{columnId}"))
                        actionScript = actionScript.replace("{columnId}",
                                dataColumn.getId());
                }
            }// if
            String label = (String)dataColumn.getAttributes().get("label");
            menuItem.setValue(label == null ? "" : label);
            menuItem.setIcon(columnVisible ? iconCheckedURI : iconUncheckedURI);
            if (menuItem instanceof HtmlMenuItem) {
                ((HtmlMenuItem) menuItem)
                        .setOnclick(actionScript == null ? "return false;"
                                : actionScript);
            }
View Full Code Here

        Map rqMap = exCtx.getRequestParameterMap();
        Object clnId = rqMap.get(component.getClientId(context));
        if (clnId == null) {
            clnId = rqMap.get(component.getClientId(context) + ":hidden");
        }
        UIMenuItem menuItem = (UIMenuItem) component;
        if (clnId != null) {

            // enqueue event here for this component or for component with Id
            // taken from forId attribute

            String mode = resolveSubmitMode(menuItem);
            if (!MenuComponent.MODE_NONE.equalsIgnoreCase(mode)) {

                ActionEvent actionEvent = new ActionEvent(menuItem);
               
                if(MenuComponent.MODE_AJAX.equalsIgnoreCase(mode)){
                new AjaxEvent(menuItem).queue();
               
                    if (AjaxRendererUtils.isAjaxRequest(context)) {
                       
                        AjaxContext.getCurrentInstance(context)
                            .addAreasToProcessFromComponent(context, menuItem);
                    }
              }
               
                if (menuItem.isImmediate()) {
                  actionEvent.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
                } else {
                    actionEvent.setPhaseId(PhaseId.INVOKE_APPLICATION);
                }
                menuItem.queueEvent(actionEvent);
            }
        }
    }
View Full Code Here

        }
    }
    // find and encode UIParameter's components
    public List encodeParams(FacesContext context, UIMenuItem component) throws IOException {
     
      UIMenuItem menuItem = component;
      List params = new ArrayList();
      StringBuffer buff = new StringBuffer();
     
      List children = menuItem.getChildren();
      for (Iterator iterator = children.iterator(); iterator.hasNext();) {
        UIComponent child = (UIComponent) iterator.next();
       
        if(child instanceof UIParameter){
         
View Full Code Here

TOP

Related Classes of org.richfaces.component.UIMenuItem

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.