Jeremy Quinn <[EMAIL PROTECTED]> responds:
>
> On Friday, August 8, 2003, at 07:56 PM, Hunsberger, Peter wrote:
>
> > Jeremy Quinn <[EMAIL PROTECTED]> asks:
> >
> >>
> >> I have a class called Constants, that is like this:
> >>
> >> public final class Constants {
> >> public static final String FAILURE = "Failed";
> >> public static final String CANCEL_ACTION = "Cancelled";
> >> // etc.
> >> }
> >>
> >> I wish to share this between my Java 'biz logic', my
> FlowScripts and
> >> the View Layer.
> >>
> >> I have the first two working as expected, the third I
> cannot work
> >> out .....
> >>
> >> Is it possible to pass the Constants class to the JXTemplate view
> >> layer in such a way that I can extract their values?
> >>
> >> I have tried several ways of sending the Constants class
> to the view
> >> layer, and using #{CANCEL_ACTION} (etc.) in my template, without
> >> success.
> >>
> >> Any suggestions?
> >>
> > Yes, but you may not like it... We build our static
> constants from an
> > XML file using an XSLT transform to create the Java code:
> >
>
> Thanks for your reply, but I cannot work out what you mean from what
> you have written.
Might have helped if I gave you a sample XML def?
<package name="org.stjude.ct.ui">
<message>
<field name="MESSAGE" min="0" max="*">msg</field>
<field name="MESSAGE_TYPE" min="1" max="1">type</field>
</message>
</package>
Then using the XSLT transform on this XML you get the Java file:
package org.stjude.ct.ui;
/**
* Static constant values used in the UI layer
*
* ***** Do not alter this file *****
*
* This file was produced from the source UIConstants.xml
* See the comments in that file for information on how to
* update and produce this file
*
*/
public abstract class UIConstants {
public static final String MESSAGE = "msg";
public static final String MESSAGE_TYPE = "type";
}
Now you have your constants for your Java code. Since they originated
from an XML file you can reference the XML file in any other
transform/transformer you might have (use aggregation in the sitemap if
you're not comfortable with the document() function and the caching
implications)...