try
{
if (getValue() instanceof URL)
{
URL url = (URL) getValue();
ds = new URLDataSource(url);
}
else if (getValue() instanceof File)
{
File file = (File) getValue();
ds = new FileDataSource(file);
}
else if (getValue() instanceof String)
{
String string = (String) getValue();
ds = new URLDataSource( FacesResources.getResource( string, context.getExternalContext() ) );
}
else if (getValue() instanceof InputStream)
{
InputStream is = (InputStream) getValue();
ds = new ByteArrayDataSource(is, getContentType());