On Fri, 2003-07-18 at 19:11, Dickson, Craig wrote: > Excellent suggestion, and very good timing since you posted it just > yesterday and I needed it today. > > Ironically however, you mention to watch out for Strings, which is > exactly what I am having a problem with. Any thoughts about how to get > quotes around the string value in the source code? I tried something > like: > > value="\"myvalue\"" > in my tag, but still got no quotes at all. Also tried using ", > but that just came through unchanged in the source code.
Have you tried value='"myvalue"'? No idea if that'd work, but if it does it'll be much simpler than any of the below... Failing that, if you're following my second suggestion (i.e. generate them from class level tags), you could use <XDtClass:ifClassTagValueEquals tagName="franks.constant" paramName="type" value="String">"<XDtClass:classTagValue tagName="franks.constant" paramName="value"/>"</XDtClass:ifClassTagValueEquals> <XDtClass:ifClassTagValueNotEquals tagName="franks.constant" paramName="type" value="String"><XDtClass:classTagValue tagName="franks.constant" paramName="value"/></XDtClass:ifClassTagValueNotEquals> for the value part. A bit messy, but it ought to work. If you're doing it from a field in the bean class, like in my first suggestion, I'm not sure. My immediate instinct was to do something similar with <XDtType:ifIsOfType> and <XDtType:ifIsNotOfType>, but looking at the docs for those tags it seems they can only test the current class or the current method's return type, unlike the other tags in that namespace (which take the type to be tested as a parameter). You could maybe get a similar effect by a combination of <XDtType:ifIsPrimitiveOrString> and <XDtType:ifIsNotPrimitive> but that's getting far to messy for my liking. By the time you've done that, it'd be easier to write a custom template tag handler to implement a "quoteValueIfString" tag that adds them where necessary. Or raise an enhancement request for some <XDtType:ifIs[Not]String> tags to be added... Andrew. > -----Original Message----- > From: Andrew Stevens [mailto:[EMAIL PROTECTED] > Sent: Wednesday, July 16, 2003 1:40 PM > To: [EMAIL PROTECTED] > Subject: Re: [Xdoclet-user] how to add constant values in Home-Remote > intercae ? > > > On Tue, 2003-07-15 at 20:10, Langelage, Frank wrote: > > I want to add a field like > > public final static int LAYOUT = 1; > > to home-remote interface of a session bean. > > > > But there seems to be no way to do this ? > > Am I right ? > > > > In home.xdt I only found iterators on methods, not on fields. > > It's obviously National Merge Files Day today :-) > http://xdoclet.sourceforge.net/ant/xdoclet/modules/ejb/home/HomeInterfaceSubTask.html#Merge%20Files > You could use the home-custom.xdt merge point to include some extra > template code of your own that loops through the fields and include > those which have been labelled with a custom tag. The value is more > of > a problem, though, since the templates only have access to the > javadocs > and not the source code. So you'd have to include the value as the > custom tag's body (or a tag parameter). e.g. > > <XDtField:forAllFields> > <XDtField:ifHasFieldTag tagName="franks.constant"> > /** <XDtField:fieldComment/> */ > public static final <XDtField:fieldType/> <XDtField:fieldName/> = > <XDtField:fieldTagValue tagName="franks.constant"/>; > </XDtField:ifHasFieldTag> > </XDtField:forAllFields> > > Of course, since you're having to include the value in the tag anyway, > then unless you also need to have the field in your bean class for > some > reason you could always generate the whole lot from class-level tags: > > <XDtClass:forAllClassTags tagName="franks.constant"> > /** <XDtClass:classTagValue tagName="franks.constant" > paramName="comment"/> */ > public static final <XDtClass:classTagValue > tagName="franks.constant" paramName="type"/> <XDtClass:classTagValue > tagName="franks.constant" paramName="name"/> = <XDtClass:classTagValue > tagName="franks.constant" paramName="value"/>; > <XDtClass:forAllClassTags/> > > Watch out for the quotes if you're using strings... > > > Andrew. ------------------------------------------------------- This SF.net email is sponsored by: VM Ware With VMware you can run multiple operating systems on a single machine. WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the same time. Free trial click here: http://www.vmware.com/wl/offer/345/0 _______________________________________________ xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user
