You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by aum strut <au...@gmail.com> on 2011/12/17 13:07:53 UTC

using property/constant placeholder in struts config file

Hi All,

While working in one application i came across a requirement where i need
to define a constant in struts.xml file and want to use in my
application.Here is the use case
in our application the layout is fixed and we are using a same template
throughout the application say

"applicationframe.jsp"
we have fixed the layout for the working template which we decide on run
time based on the action call,everything is working perfectly fine except
one issue as in each action configuration i have to do the following
configuration

<action name="welcome" class="welcomeAction">
            <result>/templates/application/applicationframe.jsp</result>
        </action>

<action name="morewelcome" class="welcomeAction1">
            <result>/templates/application/applicationframe.jsp</result>
        </action>

etc
which means if anyhow at later stage we want to change the name of
applicationframe we need to change it at every place.I was thinking of
creating a constant like
<constant name="applicationframe"
value="/templates/application/applicationframe.jsp"/>
and using its value in the result so if any change occur in future i know i
need to change it only at one place

is there a way i can achieve this?

thanks in advance

Re: using property/constant placeholder in struts config file

Posted by Greg Lindholm <gr...@gmail.com>.
You could also define a global result for success:

<global-results>
   <result name="success">/templates/application/applicationframe.jsp</result>
</global-results>

On Mon, Dec 19, 2011 at 1:44 AM, aum strut <au...@gmail.com> wrote:
> Thanks Łukasz, that's a perfect approach
>
> 2011/12/18 Łukasz Lenart <lu...@googlemail.com>
>
>> Instead hardcoded result you can use expression
>>
>> <action name="welcome" class="welcomeAction">
>>     <result>${actionFrame}</result>
>> </action>
>>
>> And create a BaseAction (as a base action for all your actions) with
>> getActionFrame() which will return
>> "/templates/application/applicationframe.jsp" or whatever your want
>> ;-)
>>
>>
>> Regards
>> --
>> Łukasz
>> + 48 606 323 122 http://www.lenart.org.pl/
>> Warszawa JUG conference - Confitura http://confitura.pl/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>

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


Re: using property/constant placeholder in struts config file

Posted by aum strut <au...@gmail.com>.
Thanks Łukasz, that's a perfect approach

2011/12/18 Łukasz Lenart <lu...@googlemail.com>

> Instead hardcoded result you can use expression
>
> <action name="welcome" class="welcomeAction">
>     <result>${actionFrame}</result>
> </action>
>
> And create a BaseAction (as a base action for all your actions) with
> getActionFrame() which will return
> "/templates/application/applicationframe.jsp" or whatever your want
> ;-)
>
>
> Regards
> --
> Łukasz
> + 48 606 323 122 http://www.lenart.org.pl/
> Warszawa JUG conference - Confitura http://confitura.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: using property/constant placeholder in struts config file

Posted by Łukasz Lenart <lu...@googlemail.com>.
Instead hardcoded result you can use expression

<action name="welcome" class="welcomeAction">
    <result>${actionFrame}</result>
</action>

And create a BaseAction (as a base action for all your actions) with
getActionFrame() which will return
"/templates/application/applicationframe.jsp" or whatever your want
;-)


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/
Warszawa JUG conference - Confitura http://confitura.pl/

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