can not read some string from struts.properties

Go To StackoverFlow.com

0

I have define variable error in struts.properties as follows:

error=this is an error

Now I can call this error as follows:

ErrorMsg = "<s:property value='getText(\"error\")'/>";

and it works, the result is: ErrorMsg=this is an error

How to get the text of variable instead of string? I tried the following:

var m="error";
  error1 = "<s:property value='getText(m)'/>";
  error2 = "<s:property value='getText(\"m\")'/>";

I use firebug debugger and error1 and error2 are displyed as follows:

error1=""
error2=""

Any Idea? thank you in advance

2012-04-04 22:48
by Max_Salah
Either I'm not understanding something or the title of the question is wrong - madth3 2012-04-04 23:07
error1 should be "this is an error", but it is empty, the question is WHY : - Max_Salah 2012-04-04 23:14
you cannot pass m="error" to struts property tag. You should define the value m in your action then you can access here. or else hard code the value in getText('error') - MohanaRao SV 2012-04-05 02:47


1

You appear to be mixing server side and client side code.

The s:property tags will be evaluated first on the server side, long before any value of m is valid, as that is client side JavaScript code.

If you post what you're trying to achieve then I or someone else may be able to help further.

HTH

2012-04-04 23:34
by davidfrancis
Ads