First pass of Ajax object picker framework and JSF UI component wrappers. Ajax folder picker implementation.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@7429 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2007-11-23 19:58:42 +00:00
parent b9d8bb4a51
commit 47e90ec3f1
15 changed files with 1664 additions and 32 deletions

View File

@@ -0,0 +1,131 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing
*/
package org.alfresco.web.bean.ajax;
import java.io.IOException;
import java.io.Writer;
import java.util.Stack;
/**
* Very simple JSON writer. Wraps a Writer to output a JSON stream.
*
* @author Kevin Roast
*/
public class JSONWriter
{
private Writer out;
private Stack<Boolean> stack = new Stack<Boolean>();
public JSONWriter(Writer out)
{
this.out = out;
stack.push(Boolean.FALSE);
}
public void startArray() throws IOException
{
if (stack.peek() == true) out.write(", ");
out.write("[");
stack.pop();
stack.push(Boolean.TRUE);
stack.push(Boolean.FALSE);
}
public void endArray() throws IOException
{
out.write("]");
stack.pop();
}
public void startObject() throws IOException
{
if (stack.peek() == true) out.write(", ");
out.write("{");
stack.pop();
stack.push(Boolean.TRUE);
stack.push(Boolean.FALSE);
}
public void endObject() throws IOException
{
out.write("}");
stack.pop();
}
public void startValue(String name) throws IOException
{
if (stack.peek() == true) out.write(", ");
out.write(name);
out.write(": ");
stack.pop();
stack.push(Boolean.TRUE);
stack.push(Boolean.FALSE);
}
public void endValue()
{
stack.pop();
}
public void writeValue(String name, String value) throws IOException
{
if (stack.peek() == true) out.write(", ");
out.write(name);
out.write(": \"");
out.write(value);
out.write('"');
stack.pop();
stack.push(Boolean.TRUE);
}
public void writeValue(String name, int value) throws IOException
{
if (stack.peek() == true) out.write(", ");
out.write(name);
out.write(": ");
out.write(Integer.toString(value));
stack.pop();
stack.push(Boolean.TRUE);
}
public void writeValue(String name, boolean value) throws IOException
{
if (stack.peek() == true) out.write(", ");
out.write(name);
out.write(": ");
out.write(Boolean.toString(value));
stack.pop();
stack.push(Boolean.TRUE);
}
public void writeNullValue(String name) throws IOException
{
if (stack.peek() == true) out.write(", ");
out.write(name);
out.write(": null");
stack.pop();
stack.push(Boolean.TRUE);
}
}

View File

@@ -0,0 +1,237 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing
*/
package org.alfresco.web.bean.ajax;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.transaction.UserTransaction;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.search.CategoryService;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.ajax.InvokeCommand;
import org.alfresco.web.bean.BrowseBean;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Bean backing the ajax requests for the ajax based picker components.
*
* @author Kevin Roast
*/
public class PickerBean
{
private static Log logger = LogFactory.getLog(PickerBean.class);
private CategoryService categoryService;
private NodeService nodeService;
private NodeService internalNodeService;
private FileFolderService fileFolderService;
/**
* @param categoryService The categoryService to set
*/
public void setCategoryService(CategoryService categoryService)
{
this.categoryService = categoryService;
}
/**
* @param nodeService The nodeService to set
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/**
* @param internalNodeService The internalNodeService to set.
*/
public void setInternalNodeService(NodeService internalNodeService)
{
this.internalNodeService = internalNodeService;
}
/**
* @param fileFolderService the FileFolderService to set
*/
public void setFileFolderService(FileFolderService fileFolderService)
{
this.fileFolderService = fileFolderService;
}
@InvokeCommand.ResponseMimetype(value=MimetypeMap.MIMETYPE_HTML)
public void getCategoryNodes() throws Exception
{
FacesContext fc = FacesContext.getCurrentInstance();
UserTransaction tx = null;
try
{
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance(), true);
tx.begin();
Collection<ChildAssociationRef> childRefs;
NodeRef parentRef = null;
Map params = fc.getExternalContext().getRequestParameterMap();
String strParentRef = (String)params.get("parent");
if (strParentRef == null || strParentRef.length() == 0)
{
childRefs = this.categoryService.getRootCategories(
Repository.getStoreRef(),
ContentModel.ASPECT_GEN_CLASSIFIABLE);
}
else
{
parentRef = new NodeRef(strParentRef);
childRefs = this.categoryService.getChildren(
parentRef,
CategoryService.Mode.SUB_CATEGORIES,
CategoryService.Depth.IMMEDIATE);
}
JSONWriter out = new JSONWriter(fc.getResponseWriter());
out.startObject();
out.startValue("parent");
out.startObject();
if (parentRef == null)
{
out.writeNullValue("id");
out.writeValue("name", "Categories");
}
else
{
out.writeValue("id", strParentRef);
out.writeValue("name", Repository.getNameForNode(this.internalNodeService, parentRef));
}
out.endObject();
out.endValue();
out.startValue("children");
out.startArray();
for (ChildAssociationRef ref : childRefs)
{
NodeRef nodeRef = ref.getChildRef();
out.startObject();
out.writeValue("id", nodeRef.toString());
out.writeValue("name", Repository.getNameForNode(this.internalNodeService, nodeRef));
out.endObject();
}
out.endArray();
out.endValue();
out.endObject();
tx.commit();
}
catch (Throwable err)
{
Utils.addErrorMessage("PickerBean exception in getCategoryRootNodes()", err);
fc.getResponseWriter().write("ERROR: " + err.getMessage());
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
}
@InvokeCommand.ResponseMimetype(value=MimetypeMap.MIMETYPE_HTML)
public void getFolderNodes() throws Exception
{
FacesContext fc = FacesContext.getCurrentInstance();
UserTransaction tx = null;
try
{
tx = Repository.getUserTransaction(FacesContext.getCurrentInstance(), true);
tx.begin();
List<ChildAssociationRef> childRefs;
NodeRef parentRef = null;
Map params = fc.getExternalContext().getRequestParameterMap();
String strParentRef = (String)params.get("parent");
if (strParentRef == null || strParentRef.length() == 0)
{
parentRef = new NodeRef(Repository.getStoreRef(), Application.getCompanyRootId(fc));
}
else
{
parentRef = new NodeRef(strParentRef);
}
List<FileInfo> folders = this.fileFolderService.listFolders(parentRef);
JSONWriter out = new JSONWriter(fc.getResponseWriter());
out.startObject();
out.startValue("parent");
out.startObject();
if (strParentRef == null || strParentRef.length() == 0)
{
out.writeNullValue("id");
out.writeValue("name", Repository.getNameForNode(this.internalNodeService, parentRef));
}
else
{
out.writeValue("id", strParentRef);
out.writeValue("name", Repository.getNameForNode(this.internalNodeService, parentRef));
}
out.endObject();
out.endValue();
out.startValue("children");
out.startArray();
// filter out those children that are not spaces
for (FileInfo folder : folders)
{
out.startObject();
out.writeValue("id", folder.getNodeRef().toString());
out.writeValue("name", (String)folder.getProperties().get(ContentModel.PROP_NAME));
String icon = (String)folder.getProperties().get(ApplicationModel.PROP_ICON);
out.writeValue("icon", (icon != null ? icon + "-16.gif" : BrowseBean.SPACE_SMALL_DEFAULT + ".gif"));
out.endObject();
}
out.endArray();
out.endValue();
out.endObject();
tx.commit();
}
catch (Throwable err)
{
Utils.addErrorMessage("PickerBean exception in getFolderNodes()", err);
fc.getResponseWriter().write("ERROR: " + err.getMessage());
try { if (tx != null) {tx.rollback();} } catch (Exception tex) {}
}
}
}

View File

@@ -81,7 +81,7 @@ public class UIMenu extends SelfRenderingComponent
// output image
if (getAttributes().get("image") != null)
{
out.write(Utils.buildImageTag(context, (String)getAttributes().get("image"), null, "middle"));
out.write(Utils.buildImageTag(context, (String)getAttributes().get("image"), null, "-4px"));
}
out.write("</a>");

View File

@@ -142,7 +142,7 @@ public class ActionLinkRenderer extends BaseRenderer
renderActionLinkAnchor(context, out, link);
}
out.write(Utils.buildImageTag(context, image, (String)link.getValue(), "middle"));
out.write(Utils.buildImageTag(context, image, (String)link.getValue(), "-4px"));
if (link.getShowLink() == false)
{

View File

@@ -214,7 +214,7 @@ public class ModeListRenderer extends BaseRenderer
// output image
if (list.getMenuImage() != null)
{
out.write(Utils.buildImageTag(context, list.getMenuImage(), null, "middle"));
out.write(Utils.buildImageTag(context, list.getMenuImage(), null, "-4px"));
}
out.write("</a></td></tr></table>");

View File

@@ -0,0 +1,328 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing
*/
package org.alfresco.web.ui.repo.component;
import java.io.IOException;
import java.util.Map;
import java.util.ResourceBundle;
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.app.Application;
/**
* @author Kevin Roast
*/
public abstract class BaseAjaxItemPicker extends UIInput
{
private static final String MSG_GO_UP = "go_up";
private static final String MSG_OK = "ok";
private static final String MSG_CANCEL = "cancel";
/** label to be displayed before an item is selected */
protected String label = null;
/** id of the initially selected item, if value is not set */
protected String initialSelectionId = null;
/** flag to show whether the component is disabled */
protected Boolean disabled;
/** True for single select mode, false for multi-select mode */
protected Boolean singleSelect;
protected static int ACTION_DONE = 0;
protected static int ACTION_CANCEL = 1;
public BaseAjaxItemPicker()
{
setRendererType(null);
}
/**
* @see javax.faces.component.UIComponent#getFamily()
*/
@Override
public abstract String getFamily();
/**
* @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.label = (String)values[1];
this.singleSelect = (Boolean)values[2];
this.initialSelectionId = (String)values[3];
this.disabled = (Boolean)values[4];
}
/**
* @see javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
*/
public Object saveState(FacesContext context)
{
Object values[] = new Object[] {
// standard component attributes are saved by the super class
super.saveState(context),
this.label,
this.singleSelect,
this.initialSelectionId,
this.disabled};
return (values);
}
/**
* @see javax.faces.component.UIComponentBase#decode(javax.faces.context.FacesContext)
*/
public void decode(FacesContext context)
{
Map requestMap = context.getExternalContext().getRequestParameterMap();
String fieldId = getHiddenFieldName();
String value = (String)requestMap.get(fieldId);
}
/**
* @see javax.faces.component.UIInput#broadcast(javax.faces.event.FacesEvent)
*/
public void broadcast(FacesEvent event) throws AbortProcessingException
{
super.broadcast(event);
}
/**
* @see javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
*/
public void encodeBegin(FacesContext fc) throws IOException
{
if (isRendered() == false)
{
return;
}
ResponseWriter out = fc.getResponseWriter();
ResourceBundle msg = Application.getBundle(fc);
// TODO: from submitted value or 'none'
String selection = "none";
// TODO: output images with context correctly
String divId = getId();
String objId = divId + "Obj";
String contextPath = fc.getExternalContext().getRequestContextPath();
out.write("<script type='text/javascript'>");
out.write("function init" + divId + "() {");
out.write(" window." + objId + " = new AlfPicker('" + divId + "','" + objId + "','" + getServiceCall() + "'," + getSingleSelect() + ");");
if (getInitialSelection() != null)
{
out.write(" window." + objId + ".setStartId('" + getInitialSelection() + "');");
}
out.write("}");
out.write(" window.addEvent('domready', init" + divId + ");");
out.write("</script>");
out.write("<div id='" + divId + "' class='picker'>") ;
out.write(" <input id='" + divId + "-value' name='" + divId + "-value' type='hidden'>");
out.write(" <div id='" + divId + "-noitems' class='pickerNoSelectedItems'>");
out.write(" <span>&lt;" + selection + "&gt;</span>");
out.write(" <span class='pickerActionButton'><a href='#' onclick='" + objId + ".showSelector();'>");
out.write(msg.getString(getLabel()));
out.write("</a></span>");
out.write(" </div>");
// container for item navigation
out.write(" <div id='" + divId + "-selector' class='pickerSelector'>");
out.write(" <div class='pickerResults'>");
out.write(" <div class='pickerResultsHeader'>");
out.write(" <div class='pickerNavControls'>");
out.write(" <span class='pickerNavUp'>");
out.write(" <a id='" + divId + "-nav-up' href='#'><img src='");
out.write(contextPath);
out.write("/images/icons/arrow_up.gif' border='0' alt='");
out.write(msg.getString(MSG_GO_UP));
out.write("' title='");
out.write(msg.getString(MSG_GO_UP));
out.write("'></a>");
out.write(" </span>");
out.write(" <span class='pickerNavBreadcrumb'>");
out.write(" <div id='" + divId + "-nav-bread' class='pickerNavBreadcrumbPanel'></div>");
out.write(" <a href='#' onclick='" + objId + ".breadcrumbToggle();'><span id='" + divId + "-nav-txt'></span><img border='0' src='");
out.write(contextPath);
out.write("/images/icons/arrow_open.gif'></a>");
out.write(" </span>");
out.write(" </div>");
out.write(" </div>");
// container for item selection
out.write(" <div>");
out.write(" <div id='" + divId + "-ajax-wait' class='pickerAjaxWait'></div>");
out.write(" <div id='" + divId + "-results-list' class='pickerResultsList'></div>");
out.write(" </div>");
out.write(" </div>");
out.write(" <div id='" + divId + "-finish' class='pickerFinishControls'>");
out.write(" <div class='pickerDoneButton'><a href='#' onclick='" + objId + ".doneClicked();'>");
out.write(msg.getString(MSG_OK));
out.write("</a></div>");
// TODO: Cancel button
out.write(" </div>");
out.write(" </div>");
// container for selected items
out.write(" <div id='" + divId + "-selected' class='pickerSelectedItems'></div>");
out.write("</div>");
}
/**
* @return the ajax service bean call, for instance 'PickerBean.getFolderNodes'
*/
protected abstract String getServiceCall();
// ------------------------------------------------------------------------------
// Strongly typed component property accessors
/**
* @return Returns the label.
*/
public String getLabel()
{
ValueBinding vb = getValueBinding("label");
if (vb != null)
{
this.label = (String)vb.getValue(getFacesContext());
}
return this.label;
}
/**
* @param label The label to set.
*/
public void setLabel(String label)
{
this.label = label;
}
/**
* @return Returns the initial selecttion.
*/
public String getInitialSelection()
{
ValueBinding vb = getValueBinding("initialSelection");
if (vb != null)
{
this.initialSelectionId = (String)vb.getValue(getFacesContext());
}
return this.initialSelectionId;
}
/**
* @param initialSelection The initial selection to set.
*/
public void setInitialSelection(String initialSelection)
{
this.initialSelectionId = initialSelection;
}
/**
* Determines whether the component should be rendered in a disabled state
*
* @return Returns whether the component is disabled
*/
public boolean isDisabled()
{
if (this.disabled == null)
{
ValueBinding vb = getValueBinding("disabled");
if (vb != null)
{
this.disabled = (Boolean)vb.getValue(getFacesContext());
}
}
return this.disabled == null ? Boolean.FALSE : this.disabled;
}
/**
* Determines whether the component should be rendered in a disabled state
*
* @param disabled true to disable the component
*/
public void setDisabled(boolean disabled)
{
this.disabled = disabled;
}
/**
* @return true is single select mode, false for multi-select
*/
public Boolean getSingleSelect()
{
if (this.singleSelect == null)
{
ValueBinding vb = getValueBinding("singleSelect");
if (vb != null)
{
this.singleSelect = (Boolean)vb.getValue(getFacesContext());
}
}
return this.singleSelect == null ? Boolean.TRUE : this.singleSelect;
}
/**
* @param singleSelect true for single select mode, false for multi-select
*/
public void setSingleSelect(Boolean singleSelect)
{
this.singleSelect = singleSelect;
}
// ------------------------------------------------------------------------------
// Protected helpers
/**
* We use a unique hidden field name based on our client Id.
* This is on the assumption that there won't be many selectors on screen at once!
* Also means we have less values to decode on submit.
*
* @return hidden field name
*/
protected String getHiddenFieldName()
{
return this.getClientId(getFacesContext());
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing
*/
package org.alfresco.web.ui.repo.component;
/**
* @author Kevin Roast
*/
public class UIAjaxFolderPicker extends BaseAjaxItemPicker
{
@Override
public String getFamily()
{
return "org.alfresco.faces.AjaxFolderPicker";
}
@Override
protected String getServiceCall()
{
return "PickerBean.getFolderNodes";
}
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
/*
* Created on 25-May-2005
*/
package org.alfresco.web.ui.repo.tag;
/**
* @author Kevin Roast
*/
public class AjaxFolderSelectorTag extends AjaxItemSelectorTag
{
/**
* @see javax.faces.webapp.UIComponentTag#getComponentType()
*/
public String getComponentType()
{
return "org.alfresco.faces.AjaxFolderPicker";
}
}

View File

@@ -0,0 +1,147 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
/*
* Created on 25-May-2005
*/
package org.alfresco.web.ui.repo.tag;
import javax.faces.component.UIComponent;
import org.alfresco.web.ui.common.tag.BaseComponentTag;
/**
* Base class for the item selector tag
*
* @author Kevin Roast
*/
public abstract class AjaxItemSelectorTag extends BaseComponentTag
{
/** the value */
private String value;
/** the label */
private String label;
/** the id of initial selection */
private String initialSelection;
/** Whether the component is single or multi-select */
private String singleSelect;
/** Whether the component is disabled */
private String disabled;
/**
* @see javax.faces.webapp.UIComponentTag#getComponentType()
*/
public abstract String getComponentType();
/**
* @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);
setStringBindingProperty(component, "value", this.value);
setStringBindingProperty(component, "initialSelection", this.initialSelection);
setStringProperty(component, "label", this.label);
setBooleanProperty(component, "singleSelect", this.singleSelect);
setBooleanProperty(component, "disabled", this.disabled);
}
/**
* @see org.alfresco.web.ui.common.tag.HtmlComponentTag#release()
*/
public void release()
{
super.release();
this.value = null;
this.label = null;
this.singleSelect = null;
this.initialSelection = null;
this.disabled = null;
}
/**
* Set the value
*
* @param value the value
*/
public void setValue(String value)
{
this.value = value;
}
/**
* Set the label
*
* @param label the label
*/
public void setLabel(String label)
{
this.label = label;
}
/**
* Set the singleSelect
*
* @param singleSelect the singleSelect
*/
public void setSingleSelect(String singleSelect)
{
this.singleSelect = singleSelect;
}
/**
* Sets the id of the item to be initially selected, this is overridden
* however if a value is supplied
*
* @param initialSelection The id of the initial selected item
*/
public void setInitialSelection(String initialSelection)
{
this.initialSelection = initialSelection;
}
/**
* Sets whether the component should be rendered in a disabled state
*
* @param disabled true to render the component in a disabled state
*/
public void setDisabled(String disabled)
{
this.disabled = disabled;
}
}

View File

@@ -45,9 +45,9 @@ public class PageTag extends TagSupport
private static final long serialVersionUID = 8142765393181557228L;
private final static String SCRIPTS_START = "<script type=\"text/javascript\" src=\"";
private final static String SCRIPTS_END = "\"></script>\n";
private final static String SCRIPTS_END = "\"></script>\n";
private final static String STYLES_START = "<link rel=\"stylesheet\" href=\"";
private final static String STYLES_MAIN = "/css/main.css\" type=\"text/css\">\n";
private final static String STYLES_MAIN = "\" type=\"text/css\">\n";
private final static String[] SCRIPTS =
{
@@ -66,7 +66,15 @@ public class PageTag extends TagSupport
// common Alfresco util methods
"/scripts/ajax/common.js",
// pop-up panel helper objects
"/scripts/ajax/summary-info.js"
"/scripts/ajax/summary-info.js",
// ajax pickers
"/scripts/ajax/picker.js"
};
private final static String[] CSS =
{
"/css/main.css",
"/css/picker.css"
};
/**
@@ -219,10 +227,15 @@ public class PageTag extends TagSupport
}
// CSS style includes
out.write(STYLES_START);
out.write(reqPath);
out.write(STYLES_MAIN);
for (final String css : PageTag.CSS)
{
out.write(STYLES_START);
out.write(reqPath);
out.write(css);
out.write(STYLES_MAIN);
}
// JavaScript includes
for (final String s : PageTag.SCRIPTS)
{
out.write(SCRIPTS_START);