You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Matthew Seaborn <Ma...@performgroup.com> on 2008/03/27 20:09:06 UTC

Struts constants

How can you get hold of the constants defined in the struts.xml?






Matthew Seaborn
Software Architect
t    +44(0) 208 484 0729
m  +44(0) 7949 465 142
e   matthew.seaborn@performgroup.com<ma...@performgroup.com>

[cid:image001.jpg@01C8903D.E0C3C3F0]
Sussex House
Plane Tree Crescent
Feltham, Middlesex, TW13 7HE
United Kingdom
http://www.performgroup.com/




________________________________________________________________________

CONFIDENTIALITY - This email and any files transmitted with it, are confidential, may be legally privileged and are intended solely for the use of the individual or entity to whom they are addressed. If this has come to you in error, you must not copy, distribute, disclose or use any of the information it contains. Please notify the sender immediately and delete them from your system.

SECURITY - Please be aware that communication by email, by its very nature, is not 100% secure and by communicating with Perform Group by email you consent to us monitoring and reading any such correspondence.

VIRUSES - Although this email message has been scanned for the presence of computer viruses, the sender accepts no liability for any damage sustained as a result of a computer virus and it is the recipient�s responsibility to ensure that email is virus free.

AUTHORITY - Any views or opinions expressed in this email are solely those of the sender and do not necessarily represent those of Perform Group.

COPYRIGHT - Copyright of this email and any attachments belongs to Perform Group, Companies House Registration number 6324278.

Re: Struts constants

Posted by Jeromy Evans <je...@blueskyminds.com.au>.
If you want the value of a constant, use @Inject on a setter. This is 
available only to objects instantiated by the Struts2 Container (actions 
or beans in the config)

Example:

import com.opensymphony.xwork2.inject.Inject;

@Inject("struts.devMode")
public void setDeveloperMode(String value) {}


---
To access them elsewhere you'll have to get a reference to the 
com.opensymphony.xwork2.inject.Container instance which may be available 
from your DI framework (Guice/Spring). I'm not sure how much luck you'll 
have with that.

---
If you just want a list of the standard Struts2 constants, see 
StrutsConstants.class

Hope that helps,
Jeromy Evans

Matthew Seaborn wrote:
>
> How can you get hold of the constants defined in the struts.xml?
>
>
>
>
> Matthew Seaborn
>
> Software Architect
> t +44(0) 208 484 0729
> m +44(0) 7949 465 142
>
> e matthew.seaborn@performgroup.com 
> <ma...@performgroup.com>
>
> 	
>
>
> Sussex House
> Plane Tree Crescent
> Feltham, Middlesex, TW13 7HE
> United Kingdom
> http://www.performgroup.com/
>
>
> ________________________________________________________________________
>
> CONFIDENTIALITY - This email and any files transmitted with it, are 
> confidential, may be legally privileged and are intended solely for 
> the use of the individual or entity to whom they are addressed. If 
> this has come to you in error, you must not copy, distribute, disclose 
> or use any of the information it contains. Please notify the sender 
> immediately and delete them from your system.
>
> SECURITY - Please be aware that communication by email, by its very 
> nature, is not 100% secure and by communicating with Perform Group by 
> email you consent to us monitoring and reading any such correspondence.
>
> VIRUSES - Although this email message has been scanned for the 
> presence of computer viruses, the sender accepts no liability for any 
> damage sustained as a result of a computer virus and it is the 
> recipient’s responsibility to ensure that email is virus free.
>
> AUTHORITY - Any views or opinions expressed in this email are solely 
> those of the sender and do not necessarily represent those of Perform 
> Group.
>
> COPYRIGHT - Copyright of this email and any attachments belongs to 
> Perform Group, Companies House Registration number 6324278.
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG. 
> Version: 7.5.519 / Virus Database: 269.22.1/1345 - Release Date: 26/03/2008 6:50 PM
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts constants

Posted by Jeromy Evans <je...@blueskyminds.com.au>.
Matthew Seaborn wrote:
> What I meant was if the following is defined in the struts.xml
>
>             <constant name="struts.url.includeParams" value="none" />
>
> How does that make it to the URLTag#setIncludeParams method and how can make our own constants?
>
>   

Didn't I answer that?  Repeated below again.

---
If you want the value of a constant, use @Inject on a setter. This is 
available only to objects instantiated by the Struts2 Container (actions 
or beans in the config)

Example:

import com.opensymphony.xwork2.inject.Inject;

@Inject("struts.url.includeParams")
public void setIncludeParams(String value) {}

You can create new constants as struts.xml.
---
To access them elsewhere you'll have to get a reference to the 
com.opensymphony.xwork2.inject.Container instance which may be available 
from your DI framework (Guice/Spring). I'm not sure how much luck you'll 
have with that.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Struts constants

Posted by Matthew Seaborn <Ma...@performgroup.com>.
What I meant was if the following is defined in the struts.xml

            <constant name="struts.url.includeParams" value="none" />

How does that make it to the URLTag#setIncludeParams method and how can make our own constants?

From: Martin Gainty [mailto:mgainty@hotmail.com]
Sent: 28 March 2008 00:09
To: Matthew Seaborn
Subject: Re: Struts constants

given the following operationMode param in struts.xml:
  <action name="resubmitApplication" class="org.apache.struts2.showcase.validation.SubmitApplication">
   <interceptor-ref name="store">
    <param name="operationMode">RETRIEVE</param>
   </interceptor-ref>

Java class
        com.opensymphony.xwork2.ActionInvocation mockActionInvocation = org.easymock.EasyMock.createControl().createMock(com.opensymphony.xwork2.ActionInvocation.class);
org.apache.struts2.interceptor.MessageStoreInterceptor interceptor = new org.apache.struts2.interceptor.MessageStoreInterceptor();
        String operationMode = interceptor.getRequestOperationMode(mockActionInvocation);


HTH
M-
----- Original Message -----
From: Matthew Seaborn<ma...@performgroup.com>
To: 'Struts Users Mailing List'<ma...@struts.apache.org>
Sent: Thursday, March 27, 2008 2:09 PM
Subject: Struts constants

How can you get hold of the constants defined in the struts.xml?





Matthew Seaborn
Software Architect
t    +44(0) 208 484 0729
m  +44(0) 7949 465 142
e   matthew.seaborn@performgroup.com<ma...@performgroup.com>

[cid:image001.jpg@01C8903D.E0C3C3F0]
Sussex House
Plane Tree Crescent
Feltham, Middlesex, TW13 7HE
United Kingdom
http://www.performgroup.com/




________________________________________________________________________

CONFIDENTIALITY - This email and any files transmitted with it, are confidential, may be legally privileged and are intended solely for the use of the individual or entity to whom they are addressed. If this has come to you in error, you must not copy, distribute, disclose or use any of the information it contains. Please notify the sender immediately and delete them from your system.

SECURITY - Please be aware that communication by email, by its very nature, is not 100% secure and by communicating with Perform Group by email you consent to us monitoring and reading any such correspondence.

VIRUSES - Although this email message has been scanned for the presence of computer viruses, the sender accepts no liability for any damage sustained as a result of a computer virus and it is the recipient's responsibility to ensure that email is virus free.

AUTHORITY - Any views or opinions expressed in this email are solely those of the sender and do not necessarily represent those of Perform Group.

COPYRIGHT - Copyright of this email and any attachments belongs to Perform Group, Companies House Registration number 6324278.

________________________________________________________________________

CONFIDENTIALITY - This email and any files transmitted with it, are confidential, may be legally privileged and are intended solely for the use of the individual or entity to whom they are addressed. If this has come to you in error, you must not copy, distribute, disclose or use any of the information it contains. Please notify the sender immediately and delete them from your system.

SECURITY - Please be aware that communication by email, by its very nature, is not 100% secure and by communicating with Perform Group by email you consent to us monitoring and reading any such correspondence.

VIRUSES - Although this email message has been scanned for the presence of computer viruses, the sender accepts no liability for any damage sustained as a result of a computer virus and it is the recipient�s responsibility to ensure that email is virus free.

AUTHORITY - Any views or opinions expressed in this email are solely those of the sender and do not necessarily represent those of Perform Group.

COPYRIGHT - Copyright of this email and any attachments belongs to Perform Group, Companies House Registration number 6324278.