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;");
}
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());
}
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);
}
}
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);
}
}
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;
}
Aggregations