Introduced multi-value support in the client

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2648 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2006-04-11 22:15:43 +00:00
parent e5a0e58041
commit 0d45ce4c18
27 changed files with 1122 additions and 529 deletions

View File

@@ -0,0 +1,100 @@
/*
* 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.converter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.StringTokenizer;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.ConverterException;
import org.alfresco.web.app.Application;
import org.alfresco.web.ui.repo.RepoConstants;
/**
* Converter class to convert a List of multiple values into a comma
* separated list.
*
* @author gavinc
*/
public class MultiValueConverter implements Converter
{
/**
* <p>The standard converter id for this converter.</p>
*/
public static final String CONVERTER_ID = "org.alfresco.faces.MultiValueConverter";
/**
* @see javax.faces.convert.Converter#getAsObject(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String)
*/
public Object getAsObject(FacesContext context, UIComponent component, String value)
throws ConverterException
{
List<String> items = new ArrayList<String>();
StringTokenizer tokenizer = new StringTokenizer(value, ",");
while (tokenizer.hasMoreTokens())
{
items.add(tokenizer.nextToken());
}
return items;
}
/**
* @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object)
*/
public String getAsString(FacesContext context, UIComponent component, Object value)
throws ConverterException
{
String result = null;
if (value instanceof Collection)
{
StringBuilder buffer = new StringBuilder();
for (Object obj : (Collection)value)
{
if (buffer.length() != 0)
{
buffer.append(", ");
}
if (obj instanceof Boolean)
{
Converter boolLabel = context.getApplication().createConverter(
RepoConstants.ALFRESCO_FACES_BOOLEAN_CONVERTER);
buffer.append(boolLabel.getAsString(context, component, obj));
}
else
{
buffer.append(obj.toString());
}
}
result = buffer.toString();
}
else if (value != null)
{
result = value.toString();
}
return result;
}
}

View File

@@ -17,6 +17,7 @@
package org.alfresco.web.ui.common.converter;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
@@ -36,7 +37,7 @@ public class XMLDateConverter extends DateTimeConverter
/**
* <p>The standard converter id for this converter.</p>
*/
public static final String CONVERTER_ID = "org.alfresco.faces.XMLDataConverter";
public static final String CONVERTER_ID = "org.alfresco.faces.XMLDateConverter";
/**
* @see javax.faces.convert.Converter#getAsObject(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.String)
@@ -58,6 +59,21 @@ public class XMLDateConverter extends DateTimeConverter
Date date = ISO8601DateFormat.parse((String)value);
str = super.getAsString(context, component, date);
}
else if (value instanceof List)
{
StringBuilder buffer = new StringBuilder();
for (Object date : ((List)value))
{
if (buffer.length() != 0)
{
buffer.append(", ");
}
buffer.append(super.getAsString(context, component, date));
}
str = buffer.toString();
}
else
{
str = super.getAsString(context, component, value);