I've been using $action.dateFormatter.calendar.timeInMillis for a while now to create a random ID for some JS functions I call in my user macro but this doesn't seem to work anymore.
I use the same macro serval times in a page therefor I have to be able to distinguish between them. The macro generates an form and an email depending on what is selected in the editor (Installation request or Problem report).
Is there an other way to generate a random ID?
Yeah, it looks like those methods are depreciated. Here is one thought, there is this method in the general utils accessible via Velocity
------------------------------------
public static <T> List<T> getRandomSubSet(List<T> list, int sizeOfSubset, Random random)
Returns a randomized subset of the list provided. If the size of the subset is larger than the list, the entire list is returned in a random order.
list
- - the list to subsetsizeOfSubset
- - the size of the subset to returnrandom
- - the source of randomness------------------------------------
So create your list of some random set of IDs, then just select a subset of one element from your list randomly.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.