• 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

Struts bug? <s:if> string comparison fail

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello...
I am forced to use struts


<jsp:include page="template/menu_top.jsp">
<jsp:param name="menu_key" value="configure"></jsp:param>
</jsp:include>


This calls menu_top.jsp

menu_top.jsp has some TEST code...

|<s:property value="#parameters.menu_key"/>|
|<s:property value="#parameters.menu_key == 'configure'"/>|
|<s:property value="#menu_item.key == 'configure'"/>|

the result is....

|configure|
|false|
|false|


|configure|
|false|
|false|


|configure|
|false|
|false|




|configure|
|false|
|false|


|configure|
|false|
|true|


|<s:property value="#parameters.menu_key == 'configure'"/>|
is never true for some reason.......

The only fix i found is to use #attr instead of #parameters...
am i missing something?
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried this?

<s:property value="#parameters.menu_key == %{'configure'}"/>
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Miltos Tereres wrote:am i missing something?


Yes; you're trying to use Struts tags in a page that isn't reached through an action. Just use JSTL.

And please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read.
 
Miltos Tereres
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i found why ....

#parameters.menuKey is an array!


I dont know why.....

Indeed i dididnt use an action.... but this wasnt the problem...
Now i do



without namespace="/" doesnt work...
dont know why
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because request parameters can come as an array (multiple with same name and all that).
 
Miltos Tereres
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
#parameters.menuKey[0] only works... why??? I didnt pass an array:S
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://struts.apache.org/2.x/docs/why-doesnt-the-if-tag-evaluate-params-properly.html
 
Miltos Tereres
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Books didnt mention that...
I dont know whats happenning...anyways!
I see my older project with struts 2 and i see there that i called parameteres
without
#parameters. prefix and worked fine...Now nothing happens
 
Miltos Tereres
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you man...
but this worked at
2.1.6 struts

<s:if test="id == selected_id">

selected_id was a parameter also....
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic