• 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

passing a bean property as a parameter to html:multibox's onclick javascript

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
i am new to Struts and was using <html:multibox> in my jsp.I have to pass two bean properties to my Action when a checkbox is selected.One property i sent using body part of <html:multibox> tag.For second property, i wrote a javascript method which to be invoked when clicking a checkbox.
The problem i was facing is-
Bean property passed as argument to that javascript method is not being evaluated to its value.Its being passed as an string.
Example code is below to better understand the problem :-)

<bean efine id="prop22" name="bean" property="prop2"/>
<html:multibox name="myForm" property="selectedCheckbox" on click="javascript:findSelectedIndex(this.form,'<%=prop22%>');">
<bean:write name="bean" property="prop1"/>
</html:multibox>
If prop22 is having value "123XYZ", the value got by javascript method is '<%=prop22%>' not "123XYZ".

Looking for ur responses
Thanks in advance
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Riya,
I got ur problem but can you please send me the complete code, so that i could check where the problem is?
[ February 17, 2006: Message edited by: Ish Rawal ]
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use run-time expressions within a Struts <html:xxx> tag, but it's all or nothing: meaning that the whole entry must be a run-time expression or none of it must be a run-time expression. If you code the following, it should work:

oclick='<%= "javascript:findSelectedIndex(this.form,'"+prop22+"');"%>'
 
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not a JSP expert. I have looked a few times but I have not seen a good book or article that talked about how custom tags and scriptlets interact and when they are evaluated. I tend to try out different things until they work. With that said, I searched through the code base for my project.

I see a few examples where bean:define is used along with standard html tags. All the examples that I found that use struts tags define the scripting variable in a scriptlet. You could try something like this and see if it works:



- Brent
 
Brent Sterling
Ranch Hand
Posts: 948
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see that Merrill submitted a reply while I was typing. Yea, I guess in all the examples that I found the entire attribute value is a run-time expression.

- Brent
 
Riya Pant
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Merill!
I tried this and its working now.Thanks a lot.
Cheers :-)
reply
    Bookmark Topic Watch Topic
  • New Topic