Shane - My replies below. On 10/25/05, Shane Smith <[EMAIL PROTECTED]> wrote: > There is a way to accomplish both, it appears that in order to pass it > along more than one grammar file, then you must pass it an array, and > not some type of deliminated list. Also, if in the case of having one > or more of them of the type dtmf, you need to pass an array of > org.apache.taglibs.rdc.core.Grammar objects. > <snip/>
Yup, thanks for looking at the code. You have a fair point about the TLD documentation for the template, I'll try to brush it up within the next week. > Since the information necessary to create these objects lives in the > jsp context of my application, I have to resort to scriptlets to > accomplish the above. I would much rather see a method for > rdc:template to handle this on it's own. > > I recommend: > > 1. Making rdctemplate.java look for and handle a comma seperated list > of grammar url's > > 2. possible adding another attribute to template: > > <rdc:template grammar="foo.grxml,bar.grxml" grammar-dtmf="dtmf.grxml"/> > > Then, the code could loadall of them into the document. Any other > ideas on how to accomplish this easily, without resorting to > scriptlets? > > Here is what I have now: > <snap/> > > ugly. > <snip/> Yup, thats hideous. The Grammar class you mention was conceived exactly for the kind of scenarios you've drawn out. Furthermore, it allows an application developer to specify inline grammars (consider a small dynamic grammar generated based on user's previous inputs in the session). It also allows for the data model of the template instance to be populated based on the names you associate with the Grammar objects. To see how this is useful, take a look at the template that deals with the initial menu in the music store sample application, specifically, how the component's "active" grammars change per its state. The template was designed for maximum flexibility, and application specific, one-off components, so when it comes to grammars, that means it needs to allow any combination of voice/dtmf, inline/external grammars. It appeared best to consolidate all grammars into one attribute, rather than created an attribute for each "class" of grammars. Now I'm probably ready to address the scriptlet question. I think of RDCs as primarily a view layer technology. Therefore, I see the need for an application framework sitting atop, and since we are in the J2EE space, that will probably use some procedural Java code. The notion of having the application framework prepare a request for the upcoming view is not uncommon. So, the Grammar array passed to a template instance may come pre-populated in the scope of choice by the time you reach the view. Indeed, that is what the music store sample application does, for when we visit the view, mainmenu.jsp [1], the preceeding Struts action has created the Grammar array for us. So, if you look at the template in isolation, it appears there is a hole, but in the larger scheme, its probably OK. Finally, as an aside, while I like RDC templates (and its possible to write entire applications with little else), I also remind myself to package useful template instances as first class components in order to gain portability and reuse. -Rahul [1] http://svn.apache.org/viewcvs.cgi/jakarta/taglibs/proper/rdc/trunk/examples/web/musicstore-app/voice/mainmenu.jsp?view=markup > Thanks, > Shane > > On 10/25/05, Shane Smith <[EMAIL PROTECTED]> wrote: > > Hey all, > > > > I'm trying to setup a RDC using the rdc:template tag, but running into > > an issue with grammars: > > > > > > In the RDC docs, it says that the grammar attribute of the tag takes, > > "One or more grammars needed by this instance". It doesn't say how > > they should be deliminated. I've tried both a space and a comma, but > > neither one appears to work. I only get the grammar file that was > > last listed. > > > > Regardless, the most common reason for doing this is to list one voice > > grammar, and one dtmf grammar. But, RDCTemplate.java has hard-coded > > logic to assume voice grammars, and fills in that attribute of the > > grammar tag. According to spec, the grammar tag attribute of "mode" > > allows for either "voice" or "dtmf", but not both, and if left blank > > it defaults to "voice". > > > > How can I specify more than one grammar file using rdc:template, and > > also, how can I specify one as a voice grammar and one as dtmf? > > > > Thanks, > > Shane > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
