Search in sources :

Example 6 with ValueBinding

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

the class UploadInputTag method setProperties.

@SuppressWarnings("unchecked")
protected void setProperties(UIComponent component) {
    super.setProperties(component);
    FacesContext context = getFacesContext();
    if (null != framework) {
        if (isValueReference(framework)) {
            ValueBinding vb = context.getApplication().createValueBinding(framework);
            component.setValueBinding("maxlength", vb);
        } else {
            component.getAttributes().put("framework", framework);
        }
    }
    component.getAttributes().put("immediate", true);
    component.getAttributes().put("style", "display:none;");
}
Also used : FacesContext(javax.faces.context.FacesContext) ValueBinding(javax.faces.el.ValueBinding)

Example 7 with ValueBinding

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

the class WizardManager method determineCurrentPage.

/**
 * Sets up the current page to show in the wizard
 */
protected void determineCurrentPage() {
    // reset the current page config in the state object
    this.currentWizardState.setCurrentPageCfg(null);
    PageConfig currentPageCfg = null;
    // get the config for the current step position
    StepConfig stepCfg = this.currentWizardState.getSteps().get(this.currentWizardState.getCurrentStep() - 1);
    // is the step conditional?
    if (stepCfg.hasConditionalPages()) {
        FacesContext context = FacesContext.getCurrentInstance();
        // test each conditional page in turn
        List<ConditionalPageConfig> pages = stepCfg.getConditionalPages();
        for (ConditionalPageConfig pageCfg : pages) {
            String condition = pageCfg.getCondition();
            if (logger.isDebugEnabled())
                logger.debug("Evaluating condition: " + condition);
            ValueBinding vb = context.getApplication().createValueBinding(condition);
            Object obj = vb.getValue(context);
            if (obj instanceof Boolean && ((Boolean) obj).booleanValue()) {
                currentPageCfg = pageCfg;
                break;
            }
        }
    }
    // if none of the conditions passed use the default page
    if (currentPageCfg == null) {
        currentPageCfg = stepCfg.getDefaultPage();
    }
    if (currentPageCfg == null) {
        throw new AlfrescoRuntimeException("Failed to determine page for step '" + stepCfg.getName() + "'. Make sure a default page is configured.");
    }
    // save the current page config in the state object
    this.currentWizardState.setCurrentPageCfg(currentPageCfg);
    if (logger.isDebugEnabled())
        logger.debug("Config for current page: " + this.currentWizardState.getCurrentPageCfg());
}
Also used : FacesContext(javax.faces.context.FacesContext) ConditionalPageConfig(org.alfresco.web.config.WizardsConfigElement.ConditionalPageConfig) PageConfig(org.alfresco.web.config.WizardsConfigElement.PageConfig) ConditionalPageConfig(org.alfresco.web.config.WizardsConfigElement.ConditionalPageConfig) ValueBinding(javax.faces.el.ValueBinding) StepConfig(org.alfresco.web.config.WizardsConfigElement.StepConfig) AlfrescoRuntimeException(org.alfresco.error.AlfrescoRuntimeException)

Example 8 with ValueBinding

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

the class BaseComponentGenerator method setupAssociation.

/**
 * Sets up the association component i.e. setting the value binding
 *
 * @param context FacesContext
 * @param propertySheet The property sheet
 * @param item The parent component
 * @param associationDef The association definition
 * @param component The component representing the association
 */
@SuppressWarnings("unchecked")
protected void setupAssociation(FacesContext context, UIPropertySheet propertySheet, PropertySheetItem item, AssociationDefinition associationDef, UIComponent component) {
    // create and set the value binding
    ValueBinding vb = context.getApplication().createValueBinding("#{" + propertySheet.getVar() + "}");
    component.setValueBinding("value", vb);
    // set the association name and set to disabled if appropriate
    ((BaseAssociationEditor) component).setAssociationName(associationDef.getName().toString());
    // or if the property sheet is in view mode
    if (propertySheet.inEditMode() == false || item.isReadOnly() || (associationDef != null && associationDef.isProtected())) {
        component.getAttributes().put("disabled", Boolean.TRUE);
    }
}
Also used : ValueBinding(javax.faces.el.ValueBinding) BaseAssociationEditor(org.alfresco.web.ui.repo.component.property.BaseAssociationEditor)

Example 9 with ValueBinding

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

the class BaseComponentGenerator method setupProperty.

/**
 * Sets up the property component i.e. setting the value binding
 *
 * @param context FacesContext
 * @param propertySheet The property sheet
 * @param item The parent component
 * @param propertyDef The property definition
 * @param component The component representing the property
 */
@SuppressWarnings("unchecked")
protected void setupProperty(FacesContext context, UIPropertySheet propertySheet, PropertySheetItem item, PropertyDefinition propertyDef, UIComponent component) {
    // create and set the value binding
    ValueBinding vb = null;
    if (propertyDef != null) {
        vb = context.getApplication().createValueBinding("#{" + propertySheet.getVar() + ".properties[\"" + propertyDef.getName().toString() + "\"]}");
    } else {
        vb = context.getApplication().createValueBinding("#{" + propertySheet.getVar() + ".properties[\"" + item.getName() + "\"]}");
    }
    component.setValueBinding("value", vb);
    // or if the property sheet is in view mode
    if (propertySheet.inEditMode() == false || item.isReadOnly() || (propertyDef != null && propertyDef.isProtected())) {
        component.getAttributes().put("disabled", Boolean.TRUE);
    }
}
Also used : ValueBinding(javax.faces.el.ValueBinding)

Example 10 with ValueBinding

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

the class BaseComponentGenerator method setupMultiValuePropertyIfNecessary.

/**
 * Creates a wrapper component around the given component to enable the user
 * to edit multiple values.
 *
 * @param context FacesContext
 * @param propertySheet The property sheet being generated
 * @param property The property being generated
 * @param propertyDef The data dictionary definition for the property
 * @param component The component representing the property
 * @return A wrapped component if the property is multi-valued or the
 *         original component if it is not multi-valued
 */
@SuppressWarnings("unchecked")
protected UIComponent setupMultiValuePropertyIfNecessary(FacesContext context, UIPropertySheet propertySheet, PropertySheetItem property, PropertyDefinition propertyDef, UIComponent component) {
    UIComponent multiValueComponent = component;
    if (propertySheet.inEditMode() && property.isReadOnly() == false && propertyDef != null && propertyDef.isProtected() == false && propertyDef.isMultiValued()) {
        // if the property is multi-valued create a multi value editor wrapper component
        String id = "multi_" + property.getName();
        multiValueComponent = context.getApplication().createComponent(RepoConstants.ALFRESCO_FACES_MULTIVALUE_EDITOR);
        FacesHelper.setupComponentId(context, multiValueComponent, id);
        // set the renderer depending on whether the item is a 'field' or a 'selector'
        if (getControlType() == ControlType.FIELD) {
            multiValueComponent.setRendererType(RepoConstants.ALFRESCO_FACES_FIELD_RENDERER);
            // set flag to indicate the wrapped field is multilingual, if necessary
            if (propertyDef.getDataType().getName().equals(DataTypeDefinition.MLTEXT)) {
                multiValueComponent.getAttributes().put("mltext", Boolean.TRUE);
            }
        } else {
            multiValueComponent.setRendererType(RepoConstants.ALFRESCO_FACES_SELECTOR_RENDERER);
            // set the value binding for the wrapped component and the lastItemAdded attribute of
            // the multi select component, needs to point somewhere that can hold any object, it
            // will store the item last added by the user.
            String expr = "#{MultiValueEditorBean.lastItemsAdded['" + property.getName() + "']}";
            ValueBinding vb = context.getApplication().createValueBinding(expr);
            multiValueComponent.setValueBinding("lastItemAdded", vb);
            component.setValueBinding("value", vb);
        }
        // add the original component as a child of the wrapper
        multiValueComponent.getChildren().add(component);
    }
    return multiValueComponent;
}
Also used : ValueBinding(javax.faces.el.ValueBinding) UIComponent(javax.faces.component.UIComponent)

Aggregations

ValueBinding (javax.faces.el.ValueBinding)16 UIInput (javax.faces.component.UIInput)3 FacesContext (javax.faces.context.FacesContext)3 MethodBinding (javax.faces.el.MethodBinding)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 UICommand (javax.faces.component.UICommand)2 UIComponent (javax.faces.component.UIComponent)2 ResponseWriter (javax.faces.context.ResponseWriter)2 AlfrescoRuntimeException (org.alfresco.error.AlfrescoRuntimeException)2 UIListItems (org.alfresco.web.ui.common.component.UIListItems)2 IOException (java.io.IOException)1 Calendar (java.util.Calendar)1 GregorianCalendar (java.util.GregorianCalendar)1 Iterator (java.util.Iterator)1 Application (javax.faces.application.Application)1 FacesMessage (javax.faces.application.FacesMessage)1 UIOutput (javax.faces.component.UIOutput)1 UISelectBoolean (javax.faces.component.UISelectBoolean)1 UISelectItems (javax.faces.component.UISelectItems)1