Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts bug? <s:if> string comparison fail

 
Miltos Tereres
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • 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?
 
Satya Sakhinetipalli
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried this?

<s:property value="#parameters.menu_key == %{'configure'}"/>
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • 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
  • 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
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
#parameters.menuKey[0] only works... why??? I didnt pass an array:S
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
 
Miltos Tereres
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • 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
  • 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....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic