• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Take value to a variable using structs tags

 
Deepa Pillai
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to pass values to javascripts scripts , am trying as below,

<logic:iterate name="testBean" property="cardList" id="d">
<bean:write name ="d" property="cardAccountNumber" />,
<%String str=//get the above value%>
<script>
globalvar=<%=str%>
</script>
</logic:iterate>

Here my cardList is a list of card objects.But How to i get the values to variable string str.Please help.

I was able to achieve below code where list contains only string variable,


<logic:iterate name="testBean" property="listMyString" id="s" >
<%out.println("test============="+s.toString());%>
</logic:iterate>

Please help on this ...
 
Doug Slattery
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Deepa,

I think you need to replace

with


if the variable str contains "ABC" then your statement is evaluated to:
globalvar=ABC instead of globalvar="ABC" which is what you want.

Hope this helps...
Aloha,
Doug

-- Nothing is impossible if I'mPossible
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34202
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepa,
We have a forum just for Struts. I'll move this for you.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34202
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepa,
Why do you need a scriptlet? You could just use bean:write directly?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic