Look at this sample application. In DynamicPhraseset.java you will see the code below:
if(field.getIntValue() <= 2) {
try {
String phraseNumber = field.getStringValue().trim();
// Get the request url so we can use that to create a url to our audio file.
URL url = new URL(getMySession().getRequest().getRequestURL().toString());
// Get the base path to the phrase from the web.xml file.
ServletContext context = getMySession().getServlet().getServletContext();
String basePath = context.getInitParameter("myphrases.basepath");
// create a url to the phrase file.
String urlString = new URL(url.getProtocol(), url.getHost(), url.getPort(),
"/" + basePath + "/" + phraseNumber + ".wav").toString();
// create the phrase with the URL string.
phrase = new ExternalPhrase(urlString);
} catch (MalformedURLException e) {
throw new SCERuntimeException("Error generating URL to phrase file.", e);
}
} else {
// create the dynamic URL generator which will be invoked to calculate the URL to the audio file..
DynamicURLGenerator urlGen = new PhraseURLGenerator();
// create the phrase with the URL generator
phrase = new ExternalPhrase(urlGen);
}
What you would do here is replace this code with code that gets your CAV and constructs a URL
IVariableField field = getMySession().getVariableField("mycav");
String basePath = field.getStringValue();
phrase.getFileName()
// create a url to the phrase file.
String urlString = basePath + "/" +phrase.getFileName();
// create the phrase with the URL string.
phrase = new ExternalPhrase(urlString);