diff --git a/config/alfresco/web-client-config-wcm-actions.xml b/config/alfresco/web-client-config-wcm-actions.xml index 89738a5fdf..6bfe4e53a4 100644 --- a/config/alfresco/web-client-config-wcm-actions.xml +++ b/config/alfresco/web-client-config-wcm-actions.xml @@ -102,7 +102,7 @@ - + CreateChildren @@ -223,7 +223,7 @@ false - + diff --git a/source/java/org/alfresco/web/bean/content/EditContentPropertiesDialog.java b/source/java/org/alfresco/web/bean/content/EditContentPropertiesDialog.java index edaa8f7dea..af6e8ae556 100644 --- a/source/java/org/alfresco/web/bean/content/EditContentPropertiesDialog.java +++ b/source/java/org/alfresco/web/bean/content/EditContentPropertiesDialog.java @@ -42,7 +42,7 @@ public class EditContentPropertiesDialog extends BaseDialogBean super.init(parameters); // setup the editable node - this.editableNode = new Node(this.browseBean.getDocument().getNodeRef()); + this.editableNode = initEditableNode(); // special case for Mimetype - since this is a sub-property of the ContentData object // we must extract it so it can be edited in the client, then we check for it later @@ -54,11 +54,19 @@ public class EditContentPropertiesDialog extends BaseDialogBean } } + /** + * Init the editable Node + */ + protected Node initEditableNode() + { + return new Node(this.browseBean.getDocument().getNodeRef()); + } + @Override protected String finishImpl(FacesContext context, String outcome) throws Exception { - NodeRef nodeRef = this.browseBean.getDocument().getNodeRef(); + NodeRef nodeRef = this.editableNode.getNodeRef(); Map editedProps = this.editableNode.getProperties(); // get the name and move the node as necessary @@ -68,9 +76,9 @@ public class EditContentPropertiesDialog extends BaseDialogBean fileFolderService.rename(nodeRef, name); } - Map repoProps = this.nodeService.getProperties(nodeRef); // we need to put all the properties from the editable bag back into // the format expected by the repository + Map repoProps = this.nodeService.getProperties(nodeRef); // but first extract and deal with the special mimetype property for ContentData String mimetype = (String)editedProps.get(TEMP_PROP_MIMETYPE); @@ -172,7 +180,7 @@ public class EditContentPropertiesDialog extends BaseDialogBean this.nodeService.removeChild(assoc.getParentRef(), assoc.getChildRef()); } } - + return outcome; } @@ -233,6 +241,7 @@ public class EditContentPropertiesDialog extends BaseDialogBean return false; } + // ------------------------------------------------------------------------------ // Bean getters and setters diff --git a/source/java/org/alfresco/web/bean/dashboard/DashboardWizard.java b/source/java/org/alfresco/web/bean/dashboard/DashboardWizard.java index 4ff8d46793..a4e5767eb9 100644 --- a/source/java/org/alfresco/web/bean/dashboard/DashboardWizard.java +++ b/source/java/org/alfresco/web/bean/dashboard/DashboardWizard.java @@ -325,8 +325,7 @@ public class DashboardWizard extends BaseWizardBean item.setLabel(label); item.setTooltip(desc); item.setValue(layoutDef.Id); - // set the special attribute used by the imageRadioPicker component - item.getAttributes().put("image", layoutDef.Image); + item.setImage(layoutDef.Image); icons.add(item); // build UIDescription to represent the layout description text diff --git a/source/java/org/alfresco/web/bean/spaces/CreateSpaceWizard.java b/source/java/org/alfresco/web/bean/spaces/CreateSpaceWizard.java index 70d9ecae90..dfcfbd75f1 100644 --- a/source/java/org/alfresco/web/bean/spaces/CreateSpaceWizard.java +++ b/source/java/org/alfresco/web/bean/spaces/CreateSpaceWizard.java @@ -504,7 +504,7 @@ public class CreateSpaceWizard extends BaseWizardBean defaultItem.setValue(ContentModel.TYPE_FOLDER.toString()); defaultItem.setLabel(defaultLabel); defaultItem.setTooltip(defaultLabel); - defaultItem.getAttributes().put("image", DEFAULT_SPACE_TYPE_ICON_PATH); + defaultItem.setImage(DEFAULT_SPACE_TYPE_ICON_PATH); this.folderTypes.add(defaultItem); UIDescription defaultDesc = new UIDescription(); @@ -561,10 +561,10 @@ public class CreateSpaceWizard extends BaseWizardBean } UIListItem item = new UIListItem(); - item.getAttributes().put("value", idQName.toString()); - item.getAttributes().put("label", label); - item.getAttributes().put("tooltip", label); - item.getAttributes().put("image", icon); + item.setValue(idQName.toString()); + item.setLabel(label); + item.setTooltip(label); + item.setImage(icon); this.folderTypes.add(item); UIDescription desc = new UIDescription(); @@ -665,7 +665,7 @@ public class CreateSpaceWizard extends BaseWizardBean UIListItem item = new UIListItem(); item.setValue(iconName); - item.getAttributes().put("image", iconPath); + item.setImage(iconPath); icons.add(item); iconNames.add(iconName); } @@ -681,7 +681,7 @@ public class CreateSpaceWizard extends BaseWizardBean UIListItem item = new UIListItem(); item.setValue(DEFAULT_SPACE_ICON_NAME); - item.getAttributes().put("image", "/images/icons/space-icon-default.gif"); + item.setImage("/images/icons/space-icon-default.gif"); icons.add(item); iconNames.add(DEFAULT_SPACE_ICON_NAME); } diff --git a/source/java/org/alfresco/web/bean/spaces/EditSpaceDialog.java b/source/java/org/alfresco/web/bean/spaces/EditSpaceDialog.java index 99ef877d3f..73664eaeda 100644 --- a/source/java/org/alfresco/web/bean/spaces/EditSpaceDialog.java +++ b/source/java/org/alfresco/web/bean/spaces/EditSpaceDialog.java @@ -31,7 +31,7 @@ public class EditSpaceDialog extends CreateSpaceDialog super.init(parameters); // setup the space being edited - this.editableNode = new Node(this.browseBean.getActionSpace().getNodeRef()); + this.editableNode = initEditableNode(); this.spaceType = this.editableNode.getType().toString(); } @@ -59,7 +59,7 @@ public class EditSpaceDialog extends CreateSpaceDialog protected String finishImpl(FacesContext context, String outcome) throws Exception { // update the existing node in the repository - NodeRef nodeRef = this.browseBean.getActionSpace().getNodeRef(); + NodeRef nodeRef = this.editableNode.getNodeRef(); Map editedProps = this.editableNode.getProperties(); // handle the name property separately, perform a rename in case it changed @@ -163,4 +163,18 @@ public class EditSpaceDialog extends CreateSpaceDialog return outcome; } + + + // ------------------------------------------------------------------------------ + // Bean getters and setters + + /** + * Returns the node being edited + * + * @return The node being edited + */ + public Node getEditableNode() + { + return this.editableNode; + } } diff --git a/source/java/org/alfresco/web/bean/wcm/EditFolderPropertiesDialog.java b/source/java/org/alfresco/web/bean/wcm/EditFolderPropertiesDialog.java index 9c5e8c6229..e613da4de2 100644 --- a/source/java/org/alfresco/web/bean/wcm/EditFolderPropertiesDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/EditFolderPropertiesDialog.java @@ -165,7 +165,7 @@ public class EditFolderPropertiesDialog extends EditSpaceDialog UIListItem item = new UIListItem(); item.setValue(DEFAULT_SPACE_ICON_NAME); - item.getAttributes().put("image", "/images/icons/" + DEFAULT_SPACE_ICON_NAME + ".gif"); + item.setImage("/images/icons/" + DEFAULT_SPACE_ICON_NAME + ".gif"); icons.add(item); return icons; diff --git a/source/java/org/alfresco/web/ui/common/component/UIListItem.java b/source/java/org/alfresco/web/ui/common/component/UIListItem.java index fb4bbe1a13..d94db01cdc 100644 --- a/source/java/org/alfresco/web/ui/common/component/UIListItem.java +++ b/source/java/org/alfresco/web/ui/common/component/UIListItem.java @@ -40,12 +40,14 @@ public class UIListItem extends SelfRenderingComponent */ public Object saveState(FacesContext context) { - Object values[] = new Object[5]; + Object values[] = new Object[7]; values[0] = super.saveState(context); values[1] = this.value; values[2] = this.disabled; values[3] = this.label; - values[4] = this.tooltip; + values[4] = this.description; + values[5] = this.tooltip; + values[6] = this.image; return ((Object) (values)); } @@ -59,7 +61,9 @@ public class UIListItem extends SelfRenderingComponent this.value = values[1]; this.disabled = (Boolean)values[2]; this.label = (String)values[3]; - this.tooltip = (String)values[4]; + this.description = (String)values[4]; + this.tooltip = (String)values[5]; + this.image = (String)values[6]; } @@ -149,6 +153,50 @@ public class UIListItem extends SelfRenderingComponent { this.label = label; } + + /** + * @return Returns the description. + */ + public String getDescription() + { + ValueBinding vb = getValueBinding("description"); + if (vb != null) + { + this.description = (String)vb.getValue(getFacesContext()); + } + + return this.description; + } + + /** + * @param description The description to set. + */ + public void setDescription(String description) + { + this.description = description; + } + + /** + * @return Returns the image. + */ + public String getImage() + { + ValueBinding vb = getValueBinding("image"); + if (vb != null) + { + this.image = (String)vb.getValue(getFacesContext()); + } + + return this.image; + } + + /** + * @param image The image to set. + */ + public void setImage(String image) + { + this.image = image; + } /** * @return Returns the tooltip. @@ -187,4 +235,10 @@ public class UIListItem extends SelfRenderingComponent /** the label */ private String label; + + /** the description */ + private String description; + + /** the image */ + private String image; } diff --git a/source/java/org/alfresco/web/ui/common/component/UISelectList.java b/source/java/org/alfresco/web/ui/common/component/UISelectList.java new file mode 100644 index 0000000000..b489ea129f --- /dev/null +++ b/source/java/org/alfresco/web/ui/common/component/UISelectList.java @@ -0,0 +1,245 @@ +/* + * Copyright (C) 2005 Alfresco, Inc. + * + * Licensed under the Mozilla Public License version 1.1 + * with a permitted attribution clause. You may obtain a + * copy of the License at + * + * http://www.alfresco.org/legal/license.txt + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + */ +package org.alfresco.web.ui.common.component; + +import java.io.IOException; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.faces.component.NamingContainer; +import javax.faces.component.UICommand; +import javax.faces.component.UIComponent; +import javax.faces.component.UIForm; +import javax.faces.context.FacesContext; +import javax.faces.context.ResponseWriter; +import javax.faces.el.ValueBinding; +import javax.faces.event.AbortProcessingException; +import javax.faces.event.FacesEvent; + +import org.alfresco.web.ui.common.Utils; + +/** + * @author Kevin Roast + */ +public class UISelectList extends UICommand +{ + private Boolean multiSelect; + private String buttonLabel; + + + // ------------------------------------------------------------------------------ + // Construction + + /** + * Default Constructor + */ + public UISelectList() + { + setRendererType(null); + } + + + // ------------------------------------------------------------------------------ + // Component Impl + + /** + * @see javax.faces.component.UIComponent#getFamily() + */ + public String getFamily() + { + return "org.alfresco.faces.Controls"; + } + + /** + * @see javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext, java.lang.Object) + */ + public void restoreState(FacesContext context, Object state) + { + Object values[] = (Object[])state; + // standard component attributes are restored by the super class + super.restoreState(context, values[0]); + this.multiSelect = (Boolean)values[1]; + this.buttonLabel = (String)values[2]; + } + + /** + * @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext) + */ + public Object saveState(FacesContext context) + { + Object values[] = new Object[3]; + // standard component attributes are saved by the super class + values[0] = super.saveState(context); + values[1] = this.multiSelect; + values[2] = this.buttonLabel; + return (values); + } + + /** + * @see javax.faces.render.Renderer#decode(javax.faces.context.FacesContext, javax.faces.component.UIComponent) + */ + public void decode(FacesContext context, UIComponent component) + { + Map requestMap = context.getExternalContext().getRequestParameterMap(); + String fieldId = getHiddenFieldName(context, component); + String value = (String)requestMap.get(fieldId); + + // we encoded the value to start with our Id + if (value != null && value.startsWith(component.getClientId(context) + NamingContainer.SEPARATOR_CHAR)) + { + String selectedValue = value.substring(component.getClientId(context).length() + 1); + } + } + + /** + * @see javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext) + */ + public void encodeBegin(FacesContext context) throws IOException + { + if (isRendered() == false) + { + return; + } + + ResponseWriter out = context.getResponseWriter(); + + // get the child components and look for compatible ListItem objects + for (Iterator i = getChildren().iterator(); i.hasNext(); /**/) + { + UIComponent child = (UIComponent)i.next(); + if (child instanceof UIListItems) + { + // get the value of the list items component and iterate through it's collection + Object listItems = ((UIListItems)child).getValue(); + if (listItems instanceof Collection) + { + for (Iterator iter = ((Collection)listItems).iterator(); iter.hasNext(); /**/) + { + UIListItem item = (UIListItem)iter.next(); + if (item.isRendered()) + { + renderItem(context, out, item); + } + } + } + } + else if (child instanceof UIListItem) + { + if (child.isRendered()) + { + // found a valid UIListItem child to render + UIListItem item = (UIListItem)child; + renderItem(context, out, item); + } + } + } + } + + /** + * Render a list item in the appropriate selection mode + * + * @param context FacesContext + * @param out ResponseWriter + * @param item UIListItem representing the item to render + */ + private void renderItem(FacesContext context, ResponseWriter out, UIListItem item) + { + } + + /** + * @see javax.faces.component.UICommand#broadcast(javax.faces.event.FacesEvent) + */ + public void broadcast(FacesEvent event) throws AbortProcessingException + { + } + + + // ------------------------------------------------------------------------------ + // Strongly typed property accessors + + /** + * Get the multi-select rendering flag + * + * @return true for multi-select rendering, false otherwise + */ + public boolean isMultiSelect() + { + ValueBinding vb = getValueBinding("multiSelect"); + if (vb != null) + { + this.multiSelect = (Boolean)vb.getValue(getFacesContext()); + } + + if (this.multiSelect != null) + { + return this.multiSelect.booleanValue(); + } + else + { + // return the default + return false; + } + } + + /** + * Set true for multi-select rendering, false otherwise + * + * @param multiSelect True for multi-select + */ + public void setMultiSelect(boolean multiSelect) + { + this.multiSelect = multiSelect; + } + + /** + * @return Returns the action button label. + */ + public String getButtonLabel() + { + ValueBinding vb = getValueBinding("buttonLabel"); + if (vb != null) + { + this.buttonLabel = (String)vb.getValue(getFacesContext()); + } + + return this.buttonLabel; + } + + /** + * @param buttonLabel The action button label to set. + */ + public void setButtonLabel(String buttonLabel) + { + this.buttonLabel = buttonLabel; + } + + + /** + * We use a hidden field name based on the parent form component Id and + * the string "selectlist" to give a hidden field name that can be shared by all + * SelectList components within a single UIForm component. + * + * @return hidden field name + */ + private static String getHiddenFieldName(FacesContext context, UIComponent component) + { + UIForm form = Utils.getParentForm(context, component); + return form.getClientId(context) + NamingContainer.SEPARATOR_CHAR + "selectlist"; + } +} diff --git a/source/java/org/alfresco/web/ui/common/renderer/ImagePickerRadioRenderer.java b/source/java/org/alfresco/web/ui/common/renderer/ImagePickerRadioRenderer.java index 68fc6bb62f..4f81c4c4fc 100644 --- a/source/java/org/alfresco/web/ui/common/renderer/ImagePickerRadioRenderer.java +++ b/source/java/org/alfresco/web/ui/common/renderer/ImagePickerRadioRenderer.java @@ -154,7 +154,7 @@ public class ImagePickerRadioRenderer extends BaseRenderer { UIListItem item = new UIListItem(); item.setValue(iconName); - item.getAttributes().put("image", iconPath); + item.setImage(iconPath); renderItem(context, out, imagePicker, item, onclick); } } @@ -324,7 +324,7 @@ public class ImagePickerRadioRenderer extends BaseRenderer out.write(""); // get the image and make sure there is one! - String image = (String)item.getAttributes().get("image"); + String image = item.getImage(); if (image == null) { throw new IllegalStateException("All child items must specify an image"); diff --git a/source/java/org/alfresco/web/ui/common/renderer/ModeListRenderer.java b/source/java/org/alfresco/web/ui/common/renderer/ModeListRenderer.java index 9dd4c1d4c8..54cfaaa4d9 100644 --- a/source/java/org/alfresco/web/ui/common/renderer/ModeListRenderer.java +++ b/source/java/org/alfresco/web/ui/common/renderer/ModeListRenderer.java @@ -336,7 +336,7 @@ public class ModeListRenderer extends BaseRenderer else { // else show the image set for the individual item - String image = (String)item.getAttributes().get("image"); + String image = item.getImage(); if (image != null) { out.write( Utils.buildImageTag(context, image, item.getTooltip()) ); diff --git a/source/java/org/alfresco/web/ui/common/tag/ListItemTag.java b/source/java/org/alfresco/web/ui/common/tag/ListItemTag.java index fa377f4f50..72c528e6b9 100644 --- a/source/java/org/alfresco/web/ui/common/tag/ListItemTag.java +++ b/source/java/org/alfresco/web/ui/common/tag/ListItemTag.java @@ -48,6 +48,7 @@ public class ListItemTag extends BaseComponentTag super.setProperties(component); setStringProperty(component, "tooltip", this.tooltip); setStringProperty(component, "label", this.label); + setStringProperty(component, "description", this.description); setStringProperty(component, "image", this.image); setStringProperty(component, "value", this.value); setBooleanProperty(component, "disabled", this.disabled); @@ -61,6 +62,7 @@ public class ListItemTag extends BaseComponentTag super.release(); this.tooltip = null; this.label = null; + this.description = null; this.image = null; this.value = null; this.disabled = null; @@ -85,6 +87,16 @@ public class ListItemTag extends BaseComponentTag { this.label = label; } + + /** + * Set the description + * + * @param description the description + */ + public void setDescription(String description) + { + this.description = description; + } /** * Set the image @@ -130,4 +142,7 @@ public class ListItemTag extends BaseComponentTag /** the disabled flag */ private String disabled; + + /** the description */ + private String description; } diff --git a/source/java/org/alfresco/web/ui/common/tag/SelectListTag.java b/source/java/org/alfresco/web/ui/common/tag/SelectListTag.java new file mode 100644 index 0000000000..edcfa24fb3 --- /dev/null +++ b/source/java/org/alfresco/web/ui/common/tag/SelectListTag.java @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2005 Alfresco, Inc. + * + * Licensed under the Mozilla Public License version 1.1 + * with a permitted attribution clause. You may obtain a + * copy of the License at + * + * http://www.alfresco.org/legal/license.txt + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the + * License. + */ +package org.alfresco.web.ui.common.tag; + +import javax.faces.component.UICommand; +import javax.faces.component.UIComponent; + +/** + * @author Kevin Roast + */ +public class SelectListTag extends HtmlComponentTag +{ + /** + * @see javax.faces.webapp.UIComponentTag#getComponentType() + */ + public String getComponentType() + { + return "org.alfresco.faces.SelectList"; + } + + /** + * @see javax.faces.webapp.UIComponentTag#getRendererType() + */ + public String getRendererType() + { + return null; + } + + /** + * @see javax.faces.webapp.UIComponentTag#setProperties(javax.faces.component.UIComponent) + */ + protected void setProperties(UIComponent component) + { + super.setProperties(component); + setActionProperty((UICommand)component, this.action); + setActionListenerProperty((UICommand)component, this.actionListener); + setBooleanProperty(component, "multiSelect", this.multiSelect); + setStringProperty(component, "buttonLabel", this.buttonLabel); + } + + /** + * @see javax.servlet.jsp.tagext.Tag#release() + */ + public void release() + { + super.release(); + this.action = null; + this.actionListener = null; + this.multiSelect = null; + this.buttonLabel = null; + } + + /** + * Set the action + * + * @param action the action + */ + public void setAction(String action) + { + this.action = action; + } + + /** + * Set the actionListener + * + * @param actionListener the actionListener + */ + public void setActionListener(String actionListener) + { + this.actionListener = actionListener; + } + + /** + * Set the multiSelect + * + * @param multiSelect the multiSelect + */ + public void setMultiSelect(String multiSelect) + { + this.multiSelect = multiSelect; + } + + /** + * Set the buttonLabel + * + * @param buttonLabel the buttonLabel + */ + public void setButtonLabel(String buttonLabel) + { + this.buttonLabel = buttonLabel; + } + + + /** the multiSelect */ + private String multiSelect; + + /** the buttonLabel */ + private String buttonLabel; + + /** the action */ + private String action; + + /** the actionListener */ + private String actionListener; +} diff --git a/source/web/WEB-INF/alfresco.tld b/source/web/WEB-INF/alfresco.tld index 19c4bbaf77..3ced834476 100644 --- a/source/web/WEB-INF/alfresco.tld +++ b/source/web/WEB-INF/alfresco.tld @@ -1054,18 +1054,6 @@ true - - style - false - true - - - - styleClass - false - true - - tooltip false @@ -1078,6 +1066,12 @@ true + + description + false + true + + image false @@ -1844,4 +1838,78 @@ + + selectList + org.alfresco.web.ui.common.tag.SelectListTag + JSP + + + The SelectList component displays a graphical list of items, each with a label and icon image. + The list has three selection modes; single select (radio), multi-select (checkbox) and command + button single item select (action). + The value for the component is a bound list of SelectListItem objects. + The selected value can be retrieved from the component or during the actionListener event handler. + + + + id + false + true + + + + binding + false + true + + + + rendered + false + true + + + + style + false + true + + + + styleClass + false + true + + + + multiSelect + false + true + + + + buttonLabel + false + true + + + + action + false + true + + + + actionListener + false + true + + + + value + true + true + + + diff --git a/source/web/WEB-INF/faces-config-common.xml b/source/web/WEB-INF/faces-config-common.xml index 9af79c35b2..53aa647ebb 100644 --- a/source/web/WEB-INF/faces-config-common.xml +++ b/source/web/WEB-INF/faces-config-common.xml @@ -144,6 +144,11 @@ org.alfresco.web.ui.common.component.UIStatusMessage + + org.alfresco.faces.SelectList + org.alfresco.web.ui.common.component.UISelectList + + @@ -166,6 +171,7 @@ org.alfresco.web.ui.common.converter.MultiValueConverter +