Package org.openfaces.component.command

Examples of org.openfaces.component.command.CommandButton


    private static final String ATTR_AJAX_REQUIRED = "_ajaxRequired";

    @Override
    public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
        ResponseWriter writer = context.getResponseWriter();
        CommandButton btn = (CommandButton) component;
        String tagName = getTagName(btn);
        writer.startElement(tagName, btn);
        Rendering.writeIdAttribute(context, component);
        Rendering.writeNameAttribute(context, component);
        String type = btn.getType();
        if (!("submit".equals(type) || "reset".equals(type) || "button".equals(type)))
            type = "submit";
        if ("input".equals(tagName)) {
            String image = btn.getImage();
            if (image != null)
                type = "image";
            writer.writeAttribute("src", Resources.applicationURL(context, image), "image");
        }
        if ("submit".equals(type) && Environment.isExplorer6()) {

        }
        writer.writeAttribute("type", type, "type");
        if (btn.isDisabled())
            writer.writeAttribute("disabled", "disabled", "");

        Rendering.writeAttributes(writer, btn,
                "accesskey",
                "tabindex",
                "lang",
                "title",
                "alt",
                "dir");
        Object value = btn.getValue();
        if (value == null) value = "";
        writer.writeAttribute("value", value, "value");

        Rendering.writeStyleAndClassAttributes(writer, btn);

        if (!btn.isDisabled()) {
            boolean ajaxJsRequired = writeEventsWithAjaxSupport(context, writer, btn);
            if (ajaxJsRequired)
                btn.getAttributes().put(ATTR_AJAX_REQUIRED, Boolean.TRUE);
        }
    }
View Full Code Here


    }

    @Override
    public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
        ResponseWriter writer = context.getResponseWriter();
        CommandButton btn = (CommandButton) component;
        writer.endElement(getTagName(btn));
        if (btn.getAttributes().remove(ATTR_AJAX_REQUIRED) != null)
            AjaxUtil.renderJSLinks(context);

    }
View Full Code Here


    private CommandButton createAddButton(FacesContext context, UIComponent rowContainer, CompositeFilter compositeFilter) {
        HtmlPanelGroup addButtonContainer = (HtmlPanelGroup) Components.createChildComponent(context, rowContainer, HtmlPanelGroup.COMPONENT_TYPE, ADD_BUTTON_CONTAINER_SUFFIX);
        addButtonContainer.setStyleClass(DEFAULT_ROW_ITEM_CLASS);
        CommandButton addButton = (CommandButton) Components.createChildComponent(context, addButtonContainer, CommandButton.COMPONENT_TYPE, BUTTON_SUFFIX);
        addButton.setType("button");
        addButton.setValue("+");
        addButton.setOnclick("O$('" + compositeFilter.getClientId(context) + "').add(); return false;");
        addButtonContainer.setValueExpression("rendered", new ValueExpressionImpl() {
            public Object getValue(ELContext elContext) {
                return lastRow;
            }
        });
        addButton.setStyleClass(DEFAULT_ADD_BUTTON_CLASS);
        return addButton;
    }
View Full Code Here

    }

    private CommandButton createDeleteButton(FacesContext context, UIComponent rowContainer, CompositeFilter compositeFilter) {
        HtmlPanelGroup deleteButtonContainer = (HtmlPanelGroup) Components.createChildComponent(context, rowContainer, HtmlPanelGroup.COMPONENT_TYPE, DELETE_BUTTON_CONTAINER_SUFFIX);
        deleteButtonContainer.setStyleClass(DEFAULT_ROW_ITEM_CLASS);
        CommandButton deleteButton = (CommandButton) Components.createChildComponent(context, deleteButtonContainer, CommandButton.COMPONENT_TYPE, BUTTON_SUFFIX);
        deleteButton.setType("button");
        deleteButton.setValue("-");
        deleteButton.setOnclick("O$('" + compositeFilter.getClientId(context) + "').remove(" + index + "); return false;");
        deleteButton.setStyleClass(DEFAULT_DELETE_BUTTON_CLASS);

        return deleteButton;
    }
View Full Code Here

TOP

Related Classes of org.openfaces.component.command.CommandButton

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.