Thanks. The following also worked: <s:a href="%{#application['view-register']}" title="%{getText('textTitle.account.register')}"> <s:text name="link.account.register" /></s:a>
Bottom-line, if we want to use "-" hyphen on OGNL expressions we must define them in the following way %{application['var-name']} This is great. Now I can name my JSP URL action variables the same way as the equivalent Struts 2 Annotation actions. Thank you very much. Rubens. ________________________________________ From: Biesbrock, Kevin [biesbrock.ke...@aoins.com] Sent: Tuesday, January 11, 2011 11:51 AM To: Struts Users Mailing List Subject: RE: How to use an application scoped variable in <s:a href=""/>? Sorry, I had a typo...I meant you could use your hyphens and try this: %{#application['view-register']} Beez r 5347 -----Original Message----- From: Rubens Gomes [mailto:rub...@pocketgear.com] Sent: Tuesday, January 11, 2011 11:45 AM To: Struts Users Mailing List Subject: RE: How to use an application scoped variable in <s:a href=""/>? BTW, the only reason I strated using the "-" minus sign in my JSP URL variable is to follow the convention used by Struts Annotation that uses "-" sign to map to the corresponding Action class name. For example, if the actions are in a package "com.softlagos.web.struts2.action"; And I have a class called "com.softlagos.web.struts2.action.ViewRegister.class", then, the action name "view-register" maps to the ViewRegister class. Therefore, the Struts 2 Annotation is using the "-" minus to map action names to action classes. And since my URLs map to actions, I therefore named the variables the same way. That is, with the "-" minus sign in it. However, I did not know that I would have problems with OGNL in the <s:a href="..." />. Now, that I know OGNL does not work with "-" minus sign, I am renaming all my variables to use the "camel" notation which is what I use throughout all my Java code anyway. Thanks, Rubens. ________________________________________ From: Biesbrock, Kevin [biesbrock.ke...@aoins.com] Sent: Tuesday, January 11, 2011 11:43 AM To: Struts Users Mailing List Subject: RE: How to use an application scoped variable in <s:a href=""/>? I prefer camel case anyway for my variable names but if you like the hyphen, I think you could do something like this: %{#application['viewRegister']} Beez r 5347 -----Original Message----- From: Rubens Gomes [mailto:rub...@pocketgear.com] Sent: Tuesday, January 11, 2011 11:38 AM To: Struts Users Mailing List Subject: RE: How to use an application scoped variable in <s:a href=""/>? That fixed the problem. The following works: <s:a href="%{#application.viewRegister}" title="%{getText('textTitle.account.register')}"> <s:text name="link.account.register" /></s:a> Bottom-line: We *cannot* use "-" (minus-sign) when naming variables that are used by the OGNL parser. Like in the case of the <s:a href="..." />. Thank you very much. Rubens. ________________________________________ From: Chris Pratt [thechrispr...@gmail.com] Sent: Tuesday, January 11, 2011 11:23 AM To: Struts Users Mailing List Subject: Re: How to use an application scoped variable in <s:a href=""/>? It seems to me that the minus sign in your expression might be being confused by the OGNL parser. You might try renaming your variable to something that is consistent with the Java bean naming convention and stay away from arithmetic operands. Maybe change <s:a href="%{#application.view-register}" title="%{getText('textTitle.account.register')}"> to <s:a href="%{#application.viewRegister}" title="%{getText('textTitle.account.register')}"> (*Chris*) On Tue, Jan 11, 2011 at 7:25 AM, Rubens Gomes <rub...@pocketgear.com> wrote: > I am using the <s:a href=".." /> Struts 2 tag, *not* the HTML standard > <a href=".." /> tag. > > And I would like to be able to de-reference an application scope > variable in the href argument of the <s:a href="???" /> tag. I have > already tried > > <s:a href='%{#application.var}' /> > > and it did not work. Below is an example (please see href). > > <s:a href="%{#application.view-register}" > title="%{getText('textTitle.account.register')}"> > <s:text name="link.account.register" /></s:a> > > > > <!-- portion of i_url.jsp where I define my url variables.... --> > <c:if test="${empty urls_defined}"> > > <s:set var="view-register" scope="application"><s:url > forceAddSchemeHostAndPort="true" scheme="https" namespace="/ssl/account" > action="view-register" /></s:set> > <s:set var="urls_defined" value="true" scope="application"/> > > </c:if> > > > then, I import the above jsp into my page using > > <c:import url="/jsp/resources/i_urls.jsp" /> > > > And now I want to use the above define application scoped URL > variables in the <s:a href="???" /> tags. > > Rubens. > > ________________________________________ > From: Maurizio Cucchiara [maurizio.cucchi...@gmail.com] > Sent: Monday, January 10, 2011 10:27 PM > To: Struts Users Mailing List > Subject: Re: How to use an application scoped variable in <s:a href=""/>? > > I'm pretty sure that the property tag is a better candidate in order > to evaluate OGNL expressions like this. > Try this > <a href="<s:property value="#application['...']"/>">Test</a> > > > 2011/1/11 Rubens Gomes <rub...@pocketgear.com>: > > I am using the <s:a ...> tags in my JSP pages. And I am using > > <s:url..> > to define URLs for the <s:a href="" />. > > I have recently made some changes to place the URLs <s:url.../> > > variables > on the application scope (so that they can > > be shared by all requests/threads). Since I made this change I need to > change the href in <s:a.../> to point to an > > application scoped variable instead. Is there any way to do that? > > > > I already tried: <s:a href="%{#application.var}"...>, and as far as > > I > know it does not work. > > > > Thanks, > > > > Rubens. > > > > -------------------------------------------------------------------- > > - To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > > For additional commands, e-mail: user-h...@struts.apache.org > > > > > > > > -- > Maurizio Cucchiara > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscr...@struts.apache.org > For additional commands, e-mail: user-h...@struts.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org