Search in sources :

Example 1 with MethodBinding

use of javax.faces.el.MethodBinding in project acs-community-packaging by Alfresco.

the class UISidebar method encodeBegin.

@SuppressWarnings("unchecked")
@Override
public void encodeBegin(FacesContext context) throws IOException {
    if (!isRendered())
        return;
    ResponseWriter out = context.getResponseWriter();
    out.write("<div id='sidebar' class='sidebar'>");
    // render the start of the header panel
    String cxPath = context.getExternalContext().getRequestContextPath();
    out.write("<table cellspacing='0' cellpadding='0' style='background-color: #ffffff;' width='100%'>" + "<tr valign='top'><td width='20%'><table cellspacing='0' cellpadding='0' width='100%'>" + "<tr><td style='width: 5px; background-image: url(");
    out.write(cxPath);
    out.write("/images/parts/sidebar_top_grey_begin.gif)' valign='top'>" + "<img src=\"");
    out.write(cxPath);
    out.write("/images/parts/sidebar_grey_01.gif\" width='5' height='5' alt=''></td>" + "<td style='height: 24px; background-image: url(");
    out.write(cxPath);
    out.write("/images/parts/sidebar_top_grey_bg.gif)'>");
    // generate the required child components if not present
    if (this.getChildCount() == 1) {
        // create the mode list component
        UIModeList modeList = (UIModeList) context.getApplication().createComponent("org.alfresco.faces.ModeList");
        modeList.setId("sidebarPluginList");
        modeList.setValue(this.getActivePlugin());
        modeList.setIconColumnWidth(2);
        modeList.setMenu(true);
        modeList.setMenuImage("/images/icons/menu.gif");
        modeList.getAttributes().put("itemSpacing", 4);
        modeList.getAttributes().put("styleClass", "moreActionsMenu");
        modeList.getAttributes().put("selectedStyleClass", "statusListHighlight");
        MethodBinding listener = context.getApplication().createMethodBinding("#{SidebarBean.pluginChanged}", new Class[] { ActionEvent.class });
        modeList.setActionListener(listener);
        // create the child list items component
        UIListItems items = (UIListItems) context.getApplication().createComponent("org.alfresco.faces.ListItems");
        ValueBinding binding = context.getApplication().createValueBinding("#{SidebarBean.plugins}");
        items.setValueBinding("value", binding);
        // add the list items to the mode list component
        modeList.getChildren().add(items);
        // create the actions component
        UIActions actions = (UIActions) context.getApplication().createComponent("org.alfresco.faces.Actions");
        actions.setId("sidebarActions");
        actions.setShowLink(false);
        setupActionGroupId(context, actions);
        // add components to the sidebar
        this.getChildren().add(0, modeList);
        this.getChildren().add(1, actions);
    } else {
        // update the child UIActions component with the correct
        // action group id and clear it's current children
        UIActions actions = (UIActions) this.getChildren().get(1);
        actions.reset();
        setupActionGroupId(context, actions);
    }
}
Also used : ResponseWriter(javax.faces.context.ResponseWriter) ValueBinding(javax.faces.el.ValueBinding) UIListItems(org.alfresco.web.ui.common.component.UIListItems) UIModeList(org.alfresco.web.ui.common.component.UIModeList) MethodBinding(javax.faces.el.MethodBinding)

Example 2 with MethodBinding

use of javax.faces.el.MethodBinding in project acs-community-packaging by Alfresco.

the class UIDialogButtons method generateButtons.

/**
 * Generates the buttons for the dialog currently being shown.
 *
 * @param context Faces context
 */
@SuppressWarnings("unchecked")
protected void generateButtons(FacesContext context) {
    // generate the OK button, if necessary
    if (Application.getDialogManager().isOKButtonVisible()) {
        UICommand okButton = (UICommand) context.getApplication().createComponent(HtmlCommandButton.COMPONENT_TYPE);
        okButton.setRendererType(ComponentConstants.JAVAX_FACES_BUTTON);
        FacesHelper.setupComponentId(context, okButton, "finish-button");
        // create the binding for the finish button label
        ValueBinding valueBinding = context.getApplication().createValueBinding("#{DialogManager.finishButtonLabel}");
        okButton.setValueBinding("value", valueBinding);
        // create the action binding
        MethodBinding methodBinding = context.getApplication().createMethodBinding("#{DialogManager.finish}", null);
        okButton.setAction(methodBinding);
        // create the binding for whether the button is disabled
        valueBinding = context.getApplication().createValueBinding("#{DialogManager.finishButtonDisabled}");
        okButton.setValueBinding("disabled", valueBinding);
        // setup CSS class for button
        String styleClass = (String) this.getAttributes().get("styleClass");
        if (styleClass != null) {
            okButton.getAttributes().put("styleClass", styleClass);
        }
        // add the OK button
        this.getChildren().add(okButton);
    }
    // generate the additional buttons
    generateAdditionalButtons(context);
    // generate the OK button
    UICommand cancelButton = (UICommand) context.getApplication().createComponent(HtmlCommandButton.COMPONENT_TYPE);
    cancelButton.setRendererType(ComponentConstants.JAVAX_FACES_BUTTON);
    FacesHelper.setupComponentId(context, cancelButton, "cancel-button");
    // create the binding for the cancel button label
    ValueBinding valueBinding = context.getApplication().createValueBinding("#{DialogManager.cancelButtonLabel}");
    cancelButton.setValueBinding("value", valueBinding);
    // create the action binding
    MethodBinding methodBinding = context.getApplication().createMethodBinding("#{DialogManager.cancel}", null);
    cancelButton.setAction(methodBinding);
    // setup CSS class for button
    String styleClass = (String) this.getAttributes().get("styleClass");
    if (styleClass != null) {
        cancelButton.getAttributes().put("styleClass", styleClass);
    }
    // set the immediate flag to true
    cancelButton.getAttributes().put("immediate", Boolean.TRUE);
    // add the Cancel button
    this.getChildren().add(cancelButton);
}
Also used : ValueBinding(javax.faces.el.ValueBinding) MethodBinding(javax.faces.el.MethodBinding) UICommand(javax.faces.component.UICommand)

Example 3 with MethodBinding

use of javax.faces.el.MethodBinding in project acs-community-packaging by Alfresco.

the class PanelTag method setProperties.

/**
 * @see javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent)
 */
protected void setProperties(UIComponent component) {
    super.setProperties(component);
    setStringProperty(component, "label", this.label);
    setStringProperty(component, "border", this.border);
    setBooleanProperty(component, "progressive", this.progressive);
    setStringProperty(component, "bgcolor", this.bgcolor);
    setStringProperty(component, "titleBorder", this.titleBorder);
    setStringProperty(component, "titleBgcolor", this.titleBgcolor);
    setStringProperty(component, "expandedTitleBorder", this.expandedTitleBorder);
    setBooleanProperty(component, "expanded", this.expanded);
    setStringProperty(component, "facetsId", this.facetsId);
    if (expandedActionListener != null) {
        if (isValueReference(expandedActionListener)) {
            MethodBinding vb = getFacesContext().getApplication().createMethodBinding(expandedActionListener, ACTION_CLASS_ARGS);
            ((UIPanel) component).setExpandedActionListener(vb);
        } else {
            throw new FacesException("Expanded Action listener method binding incorrectly specified: " + expandedActionListener);
        }
    }
}
Also used : UIPanel(org.alfresco.web.ui.common.component.UIPanel) MethodBinding(javax.faces.el.MethodBinding) FacesException(javax.faces.FacesException)

Example 4 with MethodBinding

use of javax.faces.el.MethodBinding in project acs-community-packaging by Alfresco.

the class GenericPickerTag method setProperties.

/**
 * @see javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent)
 */
protected void setProperties(UIComponent component) {
    super.setProperties(component);
    setBooleanProperty(component, "showFilter", this.showFilter);
    setBooleanProperty(component, "showContains", this.showContains);
    setBooleanProperty(component, "showAddButton", this.showAddButton);
    setBooleanProperty(component, "filterRefresh", this.filterRefresh);
    setBooleanProperty(component, "multiSelect", this.multiSelect);
    setStringProperty(component, "addButtonLabel", this.addButtonLabel);
    setStringProperty(component, "searchButtonLabel", this.searchButtonLabel);
    setActionProperty((UICommand) component, this.action);
    setActionListenerProperty((UICommand) component, this.actionListener);
    setIntProperty(component, "width", this.width);
    setIntProperty(component, "height", this.height);
    setStringBindingProperty(component, "filters", this.filters);
    if (queryCallback != null) {
        if (isValueReference(queryCallback)) {
            MethodBinding b = getFacesContext().getApplication().createMethodBinding(queryCallback, QUERYCALLBACK_CLASS_ARGS);
            ((UIGenericPicker) component).setQueryCallback(b);
        } else {
            throw new FacesException("Query Callback method binding incorrectly specified: " + queryCallback);
        }
    }
}
Also used : MethodBinding(javax.faces.el.MethodBinding) UIGenericPicker(org.alfresco.web.ui.common.component.UIGenericPicker) FacesException(javax.faces.FacesException)

Example 5 with MethodBinding

use of javax.faces.el.MethodBinding in project acs-community-packaging by Alfresco.

the class UIGenericPicker method broadcast.

/**
 * @see javax.faces.component.UIComponentBase#broadcast(javax.faces.event.FacesEvent)
 */
public void broadcast(FacesEvent event) throws AbortProcessingException {
    if (event instanceof PickerEvent) {
        PickerEvent pickerEvent = (PickerEvent) event;
        // set component state from event properties
        this.filterIndex = pickerEvent.FilterIndex;
        this.contains = pickerEvent.Contains;
        this.selectedResults = pickerEvent.Results;
        // delegate to appropriate action logic
        switch(pickerEvent.Action) {
            case ACTION_ADD:
                // call super for actionlistener execution
                // it's up to the handler to get the results from the getSelectedResults() method
                super.broadcast(event);
                break;
            case ACTION_CLEAR:
                this.contains = "";
                this.filterIndex = 0;
                this.selectedResults = null;
                this.currentResults = null;
                break;
            case ACTION_FILTER:
            // filter changed then query with new settings
            case ACTION_SEARCH:
                // query with current settings
                MethodBinding callback = getQueryCallback();
                if (callback != null) {
                    // use reflection to execute the query callback method and retrieve results
                    Object result = callback.invoke(getFacesContext(), new Object[] { this.filterIndex, this.contains.trim() });
                    if (result instanceof SelectItem[]) {
                        this.currentResults = (SelectItem[]) result;
                    } else {
                        this.currentResults = null;
                    }
                }
                break;
        }
    } else {
        super.broadcast(event);
    }
}
Also used : SelectItem(javax.faces.model.SelectItem) MethodBinding(javax.faces.el.MethodBinding)

Aggregations

MethodBinding (javax.faces.el.MethodBinding)10 FacesException (javax.faces.FacesException)6 ValueBinding (javax.faces.el.ValueBinding)3 UICommand (javax.faces.component.UICommand)2 ResponseWriter (javax.faces.context.ResponseWriter)1 SelectItem (javax.faces.model.SelectItem)1 DialogButtonConfig (org.alfresco.web.config.DialogsConfigElement.DialogButtonConfig)1 UIGenericPicker (org.alfresco.web.ui.common.component.UIGenericPicker)1 UIListItems (org.alfresco.web.ui.common.component.UIListItems)1 UIModeList (org.alfresco.web.ui.common.component.UIModeList)1 UIPanel (org.alfresco.web.ui.common.component.UIPanel)1 UIClipboardShelfItem (org.alfresco.web.ui.repo.component.shelf.UIClipboardShelfItem)1 UIRecentSpacesShelfItem (org.alfresco.web.ui.repo.component.shelf.UIRecentSpacesShelfItem)1 UIShelf (org.alfresco.web.ui.repo.component.shelf.UIShelf)1 UIShortcutsShelfItem (org.alfresco.web.ui.repo.component.shelf.UIShortcutsShelfItem)1