You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Jeremy Quinn <je...@media.demon.co.uk> on 2003/08/08 20:36:17 UTC

Accessing public static final constants from JXTemplate

Hi All,


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?

thanks

regards Jeremy


Re: Accessing public static final constants from JXTemplate

Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On Tuesday, August 12, 2003, at 06:25 PM, Christopher Oliver wrote:

> This should work:
>
> ${Packages.org.iniva.util.Contstants.CANCEL_ACTION}
>
> But make sure you update to the latest cvs. I only recently added a 
> fix for this.

I am running Cocoon2.1RC1, so I will update the server and try again.

Many thanks

regards Jeremy


> Jeremy Quinn wrote:
>
>>
>> On Friday, August 8, 2003, at 07:36 PM, Jeremy Quinn wrote:
>>
>>> Hi All,
>>>
>>>
>>> I have a class called Constants, that is like this:
>>
>>
>>> Package org.iniva.util;
>>> 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 tried the following expressions in JXTemplate :
>>
>> #{org/iniva/util/Constants/CANCEL_ACTION}                 : No 
>> pointer for xpath Exception
>> #{Packages/org/iniva/util/Constants/CANCEL_ACTION} : No pointer for 
>> xpath Exception
>> #{org.iniva.util.Constants.CANCEL_ACTION}                   : no 
>> output
>> #{Packages.org.iniva.util.Constants. CANCEL_ACTION}   : no output
>> #{java.org.iniva.util.Constants. CANCEL_ACTION}            : no output
>> ${org.iniva.util.Constants.CANCEL_ACTION}                    : no 
>> output
>> ${Packages.org.iniva.util.Constants. CANCEL_ACTION}    : no output
>> ${java.org.iniva.util.Constants. CANCEL_ACTION}            :
>>             outputs "[JavaPackage java.org.iniva.util.Constants. 
>> CANCEL_ACTION]"
>>
>>
>> So I am not any closer ......
>>
>> Any suggestions?
>>
>> Thanks
>>
>> regards Jeremy
>>
>>
>
>


Re: Accessing public static final constants from JXTemplate

Posted by Christopher Oliver <re...@verizon.net>.
This should work:

${Packages.org.iniva.util.Contstants.CANCEL_ACTION}

But make sure you update to the latest cvs. I only recently added a fix 
for this.

Chris


Jeremy Quinn wrote:

>
> On Friday, August 8, 2003, at 07:36 PM, Jeremy Quinn wrote:
>
>> Hi All,
>>
>>
>> I have a class called Constants, that is like this:
>
>
>> Package org.iniva.util;
>> 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 tried the following expressions in JXTemplate :
>
> #{org/iniva/util/Constants/CANCEL_ACTION}                 : No pointer 
> for xpath Exception
> #{Packages/org/iniva/util/Constants/CANCEL_ACTION} : No pointer for 
> xpath Exception
> #{org.iniva.util.Constants.CANCEL_ACTION}                   : no output
> #{Packages.org.iniva.util.Constants. CANCEL_ACTION}   : no output
> #{java.org.iniva.util.Constants. CANCEL_ACTION}            : no output
> ${org.iniva.util.Constants.CANCEL_ACTION}                    : no output
> ${Packages.org.iniva.util.Constants. CANCEL_ACTION}    : no output
> ${java.org.iniva.util.Constants. CANCEL_ACTION}            :
>             outputs "[JavaPackage java.org.iniva.util.Constants. 
> CANCEL_ACTION]"
>
>
> So I am not any closer ......
>
> Any suggestions?
>
> Thanks
>
> regards Jeremy
>
>



Re: Accessing public static final constants from JXTemplate

Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On Friday, August 8, 2003, at 07:36 PM, Jeremy Quinn wrote:

> Hi All,
>
>
> I have a class called Constants, that is like this:

> Package org.iniva.util;
> 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 tried the following expressions in JXTemplate :

#{org/iniva/util/Constants/CANCEL_ACTION}                 : No pointer 
for xpath Exception
#{Packages/org/iniva/util/Constants/CANCEL_ACTION} : No pointer for 
xpath Exception
#{org.iniva.util.Constants.CANCEL_ACTION}                   : no output
#{Packages.org.iniva.util.Constants. CANCEL_ACTION}   : no output
#{java.org.iniva.util.Constants. CANCEL_ACTION}            : no output
${org.iniva.util.Constants.CANCEL_ACTION}                    : no output
${Packages.org.iniva.util.Constants. CANCEL_ACTION}    : no output
${java.org.iniva.util.Constants. CANCEL_ACTION}            :
			outputs "[JavaPackage java.org.iniva.util.Constants. CANCEL_ACTION]"


So I am not any closer ......

Any suggestions?

Thanks

regards Jeremy