. Message for "Website" changes to "Web Project" for appropriate wizards and actions

. New JSF component called SelectList
 - This generic selection component displays a graphical list of items, each with an optional icon, label, description and tooltip.
 - The list has three selection modes; single select (radio), multi-select (checkbox) and 'active' selection mode.
 - The 'active' selection mode renders any child command components (such as ActionLink or CommandButton components) which can then data-bind to each row item in the list. i.e. to allow buttons or links with context for each item.
 - This various selection modes covers the usage for 4 different screens in the WCM wireframes
. Forms page (new step 2) added to Create Web Project wizard
 - this is currently mostly a test page for the SelectList component

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4236 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-10-26 17:42:08 +00:00
parent 07686ab8ce
commit 202f9d5957
11 changed files with 432 additions and 122 deletions

View File

@@ -18,11 +18,13 @@ package org.alfresco.web.bean.wcm;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
import javax.faces.component.UISelectItem;
import javax.faces.context.FacesContext;
import org.alfresco.error.AlfrescoRuntimeException;
@@ -44,6 +46,8 @@ import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wizard.BaseWizardBean;
import org.alfresco.web.bean.wizard.InviteUsersWizard.UserGroupRole;
import org.alfresco.web.ui.common.component.UIListItem;
import org.alfresco.web.ui.wcm.WebResources;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -275,6 +279,45 @@ public class CreateWebsiteWizard extends BaseWizardBean
new String[] {this.name, this.description, buf.toString()});
}
public List<UIListItem> getFormsList()
{
List<UIListItem> forms = new ArrayList<UIListItem>();
UIListItem item = new UIListItem();
item.setValue("0001");
item.setLabel("Company Press Release");
item.setDescription("Standard monthly press release form");
item.setTooltip("Standard monthly press release form");
item.setImage(WebResources.IMAGE_SANDBOX_32);
forms.add(item);
item = new UIListItem();
item.setValue("0002");
item.setLabel("Company Site Note");
item.setDescription("Main site footer node");
item.setTooltip("Basic footer node addition form");
item.setImage(WebResources.IMAGE_SANDBOX_32);
forms.add(item);
item = new UIListItem();
item.setValue("0003");
item.setLabel("Index Generator");
item.setDescription("Complete site index");
item.setTooltip("Complete site index generation form");
item.setImage(WebResources.IMAGE_SANDBOX_32);
forms.add(item);
return forms;
}
public String[] getFormsSelectedValue()
{
return testValue;
}
public void setFormsSelectedValue(String[] value)
{
testValue = value;
}
private String[] testValue = new String[] {"0001"};
/**
* @return the InviteWebsiteUsersWizard delegate bean

View File

@@ -19,44 +19,50 @@ 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.component.UIInput;
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;
/**
* 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 active
* selection mode (child action components).
*
* The value for the component is collection of UIListItem objects or a UIListItems instance.
*
* For passive single and multi-select modes, the selected value(s) can be retrieved from the component.
* For active selection mode, appropriate child components such as Command buttons or Action Links
* will be rendered for each item in the list, data-binding to the specified 'var' variable should be
* used to bind required params. It is then up to the developer to retrieve the selected item param
* from the actionListener of the appropriate child component.
*
* @author Kevin Roast
*/
public class UISelectList extends UICommand
public class UISelectList extends UIInput
{
private Boolean multiSelect;
private String buttonLabel;
private Boolean activeSelect;
// ------------------------------------------------------------------------------
// Construction
// Component Impl
/**
* Default Constructor
* Default constructor
*/
public UISelectList()
{
setRendererType(null);
}
// ------------------------------------------------------------------------------
// Component Impl
/**
* @see javax.faces.component.UIComponent#getFamily()
@@ -75,7 +81,7 @@ public class UISelectList extends UICommand
// standard component attributes are restored by the super class
super.restoreState(context, values[0]);
this.multiSelect = (Boolean)values[1];
this.buttonLabel = (String)values[2];
this.activeSelect = (Boolean)values[2];
}
/**
@@ -87,26 +93,38 @@ public class UISelectList extends UICommand
// standard component attributes are saved by the super class
values[0] = super.saveState(context);
values[1] = this.multiSelect;
values[2] = this.buttonLabel;
values[2] = this.activeSelect;
return (values);
}
/**
* @see javax.faces.render.Renderer#decode(javax.faces.context.FacesContext, javax.faces.component.UIComponent)
* @see javax.faces.component.UIComponentBase#decode(javax.faces.context.FacesContext)
*/
public void decode(FacesContext context, UIComponent component)
public void decode(FacesContext context)
{
Map requestMap = context.getExternalContext().getRequestParameterMap();
String fieldId = getHiddenFieldName(context, component);
String value = (String)requestMap.get(fieldId);
Map valuesMap = context.getExternalContext().getRequestParameterValuesMap();
// 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);
}
// save the selected values that match our component Id
setSubmittedValue((String[])valuesMap.get(getClientId(context)));
}
/**
* @see javax.faces.component.UIComponentBase#encodeChildren(javax.faces.context.FacesContext)
*/
public void encodeChildren(FacesContext context) throws IOException
{
// we encode child components explicity
}
/**
* @see javax.faces.component.UIComponentBase#getRendersChildren()
*/
public boolean getRendersChildren()
{
return true;
}
/**
* @see javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
*/
@@ -117,8 +135,29 @@ public class UISelectList extends UICommand
return;
}
// Prepare the data-binding variable "var" ready for the each cycle of
// renderering for the child components.
String var = (String)getAttributes().get("var");
Map requestMap = context.getExternalContext().getRequestMap();
ResponseWriter out = context.getResponseWriter();
out.write("<table cellspacing=0 cellpadding=0");
String style = (String)getAttributes().get("style");
if (style != null)
{
out.write(" style='");
out.write(style);
out.write('\'');
}
String styleClass = (String)getAttributes().get("styleClass");
if (styleClass != null)
{
out.write(" class=");
out.write(styleClass);
}
out.write('>');
// get the child components and look for compatible ListItem objects
for (Iterator i = getChildren().iterator(); i.hasNext(); /**/)
{
@@ -134,6 +173,10 @@ public class UISelectList extends UICommand
UIListItem item = (UIListItem)iter.next();
if (item.isRendered())
{
if (var != null)
{
requestMap.put(var, item);
}
renderItem(context, out, item);
}
}
@@ -145,10 +188,20 @@ public class UISelectList extends UICommand
{
// found a valid UIListItem child to render
UIListItem item = (UIListItem)child;
if (var != null)
{
requestMap.put(var, item);
}
renderItem(context, out, item);
}
}
}
if (var != null)
{
requestMap.remove(var);
}
out.write("</table>");
}
/**
@@ -159,14 +212,106 @@ public class UISelectList extends UICommand
* @param item UIListItem representing the item to render
*/
private void renderItem(FacesContext context, ResponseWriter out, UIListItem item)
throws IOException
{
}
/**
* @see javax.faces.component.UICommand#broadcast(javax.faces.event.FacesEvent)
*/
public void broadcast(FacesEvent event) throws AbortProcessingException
{
boolean activeSelect = isActiveSelect();
// begin the row, add tooltip if present
String tooltip = item.getTooltip();
out.write("<tr title=\"");
out.write(tooltip != null ? tooltip : "");
out.write("\">");
if (activeSelect == false)
{
// we are rendering passive select list, so either multi or single selection using
// checkboxes or radio button control respectively
boolean multiSelect = isMultiSelect();
String id = getClientId(context);
String itemValue = item.getValue().toString();
out.write("<td");
Utils.outputAttribute(out, getAttributes().get("itemStyle"), "style");
Utils.outputAttribute(out, getAttributes().get("itemStyleClass"), "class");
out.write(" width=16><input type='");
out.write(multiSelect ? "checkbox" : "radio");
out.write("' name='");
out.write(id);
out.write("' id='");
out.write(id);
out.write("' value='");
out.write(itemValue);
out.write('\'');
String[] value = (String[])getValue();
if (multiSelect)
{
if (value != null)
{
for (int i=0; i<value.length; i++)
{
if (value[i].equals(itemValue))
{
out.write(" CHECKED");
break;
}
}
}
}
else
{
if (value != null && value.length == 1 && value[0].equals(itemValue))
{
out.write(" CHECKED");
}
}
out.write("></td>");
}
// optional 32x32 pixel icon
String icon = item.getImage();
if (icon != null)
{
out.write("<td");
Utils.outputAttribute(out, getAttributes().get("itemStyle"), "style");
Utils.outputAttribute(out, getAttributes().get("itemStyleClass"), "class");
out.write(" width=34>"); // give pixel space around edges
out.write(Utils.buildImageTag(context, icon, 32, 32, ""));
out.write("</td>");
}
// label and description text
String description = item.getDescription();
out.write("<td");
Utils.outputAttribute(out, getAttributes().get("itemStyle"), "style");
Utils.outputAttribute(out, getAttributes().get("itemStyleClass"), "class");
out.write("><div style='padding:2px'>");
out.write(item.getLabel());
out.write("</div><div style='padding:2px'>");
if (description != null)
{
out.write(description);
}
out.write("</div></td>");
if (activeSelect)
{
// we are rendering an active select list with child components next to each item
// get the child components and look for compatible Command objects
out.write("<td");
Utils.outputAttribute(out, getAttributes().get("itemStyle"), "style");
Utils.outputAttribute(out, getAttributes().get("itemStyleClass"), "class");
out.write('>');
for (Iterator i = getChildren().iterator(); i.hasNext(); /**/)
{
UIComponent child = (UIComponent)i.next();
if (child instanceof UICommand)
{
out.write("<span style='padding:1px'>");
Utils.encodeRecursive(context, child);
out.write("</span>");
}
}
out.write("</td>");
}
}
@@ -208,25 +353,37 @@ public class UISelectList extends UICommand
}
/**
* @return Returns the action button label.
* Get the active selection mode flag
*
* @return true for active selection mode, false otherwise
*/
public String getButtonLabel()
public boolean isActiveSelect()
{
ValueBinding vb = getValueBinding("buttonLabel");
ValueBinding vb = getValueBinding("activeSelect");
if (vb != null)
{
this.buttonLabel = (String)vb.getValue(getFacesContext());
this.activeSelect = (Boolean)vb.getValue(getFacesContext());
}
return this.buttonLabel;
if (this.activeSelect != null)
{
return this.activeSelect.booleanValue();
}
else
{
// return the default
return false;
}
}
/**
* @param buttonLabel The action button label to set.
* Set true for active selection mode, false otherwise
*
* @param activeSelect True for active selection
*/
public void setButtonLabel(String buttonLabel)
public void setActiveSelect(boolean activeSelect)
{
this.buttonLabel = buttonLabel;
this.activeSelect = activeSelect;
}

View File

@@ -16,7 +16,6 @@
*/
package org.alfresco.web.ui.common.tag;
import javax.faces.component.UICommand;
import javax.faces.component.UIComponent;
/**
@@ -46,10 +45,12 @@ public class SelectListTag extends HtmlComponentTag
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);
setBooleanProperty(component, "activeSelect", this.activeSelect);
setStringStaticProperty(component, "var", this.var);
setStringProperty(component, "itemStyle", this.itemStyle);
setStringProperty(component, "itemStyleClass", this.itemStyleClass);
setStringProperty(component, "value", this.value);
}
/**
@@ -58,62 +59,89 @@ public class SelectListTag extends HtmlComponentTag
public void release()
{
super.release();
this.action = null;
this.actionListener = null;
this.multiSelect = null;
this.buttonLabel = null;
this.activeSelect = null;
this.var = null;
this.itemStyle = null;
this.itemStyleClass = null;
this.value = null;
}
/**
* Set the action
* Set the multi-select mode
*
* @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
* @param multiSelect the multi-select mode
*/
public void setMultiSelect(String multiSelect)
{
this.multiSelect = multiSelect;
}
/**
* Set the buttonLabel
* Set the active selection mode
*
* @param buttonLabel the buttonLabel
* @param activeSelect the active selection mode
*/
public void setButtonLabel(String buttonLabel)
public void setActiveSelect(String activeSelect)
{
this.buttonLabel = buttonLabel;
this.activeSelect = activeSelect;
}
/**
* Set the variable name for row item context
*
* @param var the variable name for row item context
*/
public void setVar(String var)
{
this.var = var;
}
/**
* Set the item Style
*
* @param itemStyle the item Style
*/
public void setItemStyle(String itemStyle)
{
this.itemStyle = itemStyle;
}
/**
* Set the item Style Class
*
* @param itemStyleClass the item Style Class
*/
public void setItemStyleClass(String itemStyleClass)
{
this.itemStyleClass = itemStyleClass;
}
/**
* Set the selected value
*
* @param value the selected value
*/
public void setValue(String value)
{
this.value = value;
}
/** the multiSelect */
/** the selected value */
private String value;
/** the itemStyle */
private String itemStyle;
/** the itemStyleClass */
private String itemStyleClass;
/** the multi-select mode */
private String multiSelect;
/** the buttonLabel */
private String buttonLabel;
/** the action */
private String action;
/** the actionListener */
private String actionListener;
/** the active selection mode */
private String activeSelect;
/** the variable name for row item context */
private String var;
}

View File

@@ -74,7 +74,6 @@ public class UIUserGroupPicker extends UICommand
public void decode(FacesContext context)
{
Map requestMap = context.getExternalContext().getRequestParameterMap();
Map valuesMap = context.getExternalContext().getRequestParameterValuesMap();
String fieldId = getHiddenFieldName(context);
String value = (String)requestMap.get(fieldId);

View File

@@ -149,7 +149,6 @@ public class UIUserSandboxes extends SelfRenderingComponent
public void decode(FacesContext context)
{
Map requestMap = context.getExternalContext().getRequestParameterMap();
Map valuesMap = context.getExternalContext().getRequestParameterValuesMap();
String fieldId = getClientId(context);
String value = (String)requestMap.get(fieldId);