• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

using scriptelet in s:if

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
I have a value in one of the java veriables in jsp. and I want to use it to compare it with one of the value coming from my action. I know values are same but <s:if> never returns true.
This works:
if(languageSelected1.equals("9")) { %>
<s:if test='key.equals("9")'>
comes here fine.

And same this doesn't work ...if I write it like this
<s:if test='key.equals("<%=languageSelected1%>")'>
never comes here.

I tried to use <s:set to set the value, but that didn't help either. Heres the code with <s:set>
<s:set name="templang" value="<%=languageSelected1%>">
</s:set>
//some code here
I tried follwing and nothing worked
<s:if test='key.equals(#templang)'>
<s:if test='#templang=="${key}"'>
<s:if test='%{#templang == key}'>
<s:if test='%{#templang == "${key}"}'>
is there something wrong with the usage ?
 
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know of any struts2 tags that allow you to use scriptlets in its attributes. You need to get the variable into a location that can be accessed by OGNL. You could put the value into one of the scoped objects (probably the request object) and then OGNL should be able to access it. Or you could write some scriptlet code to push the value onto the stack, but I think putting the value into the request makes the most sense.
 
D kukreja
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tom,
after doing <s:set > I did try to print it using <s roperty> and it was printing correctly. So, I assume atleast <s:set> is one struts tag that identify and evaluate scriptlet.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic