Oh, i thought there is some trick for that in Tapestry (as usually :)).
So for completeness i'm sending my raw solution... Thank you for advise.
@Inject
private Context context;
@Inject
private PersistentLocale persistentLocale;
@Inject
private AssetSource assetSource;
private Context context;
@Inject
private PersistentLocale persistentLocale;
@Inject
private AssetSource assetSource;
File resource = context.getRealFile("/images/backgrounds/");
String[] list = resource.list();
if (list != null)
{
Random r = new Random();
int index = r.nextInt(list.length);
Asset result = assetSource.getContextAsset(
"context:/images/backgrounds/" + list[index],
persistentLocale.get());
return result;
}
return null;
String[] list = resource.list();
if (list != null)
{
Random r = new Random();
int index = r.nextInt(list.length);
Asset result = assetSource.getContextAsset(
"context:/images/backgrounds/" + list[index],
persistentLocale.get());
return result;
}
return null;
BR,
Jan
On Sat, 11 May 2013 23:49:50 +0200, Thiago H de Paula Figueiredo <thiag...@gmail.com> wrote:
On Sat, 11 May 2013 17:42:34 -0300, Jan Fryblik <jan.fryb...@ebrothers.cz> wrote:Hi guys,Hi!i just created simple slider component. Now i'm wondering, is somehow possible to load all images from context path? I mean, i have for instance folder /webapp/images/slider and i need to get all images in the directory without knowing image names. Thanks for answer.Just do what you'd do in a Servlet environment without Tapestry. See first answer to http://stackoverflow.com/questions/11195532/in-java-is-it-possible-to-get-a-directory-file-listing-inside-a-war-classpath-us.--Thiago H. de Paula Figueiredo