cancel
Showing results for 
Search instead for 
Did you mean: 

Get list of files within folder in Java

mikepoole
Champ in-the-making
Champ in-the-making
I am trying to create a constraint class to show a drop-down box to the user of all files within the current folder

My question is - how, within my Java constraint class can I get the list of files? How do I get a handle on the current nodeRef to then use the FileFolderService? Do I need to get the nodeRef from the url and if so, how do I do that?

Many thanks for your time

Mike
2 REPLIES 2

afaust
Legendary Innovator
Legendary Innovator
Hello,

constraints are considered to be state-less restrictions on values. State-less means independent of a certain context, which is why you don't have a handle on the affected node within a custom Java constraint class. Only by tricking / working around the integrity checking framework would I suspect you might be able to get a hold of the current node.

What I'd do in such an instance is implement a Java-based form filter, which can generate the constraint definition dynamically based on the current node reference. Of course, this only works for form-based UIs and does not provide automatic validation during saving, if you don't include the validation code in your form filter / a policy.

Regards
Axel

mikepoole
Champ in-the-making
Champ in-the-making
Thanks Axel

Your post makes perfect sense. It has saved me spending hours trying to bang a square peg into a round-hole during my first exposure to Alfresco. You are a life-saver!

Mike