• 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

howto pass parameter to struts tag ?

 
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi good day,

i having a problem which due to passing parameter to struts tag <html:image>

the parameters(calMonth&dateFormat) is need to call the calendar and are dynamic, and i use to pass it by defined it in scriptlet in <head>





the problem is calMonth and dateFormat is not detect in struts link tag, howto i solve this problem ?
 
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 scriptlets with Struts tags, but the rule is "all or nothing", meaning that the entire contents of the attribute must be a scriptlet, or none of it must be a scriptlet. So, something like the following would work:

<html:link href='<%="javascript:show_calendar('document.forms[0].pre_fitdate','"+calMonth+"', '', '"+dateFormat+"');" %>'><html:img page="/pages/images/cal.gif" width="16" height="16" border="0" /> </html:link>

Note that no such restriction applies to the Struts-el version of the taglib. It allows you to sprikle in EL expressions with literals.
 
Nakata kokuyo
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you for guidance, Merrill Higginson , i will try it later, what if if i use struts-el? how it should be ? in fact, i confuse what is struts-el ?
 
Nakata kokuyo
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Merrill Higginson, i have try it , ans it work , thank you

but somehow, i need to add more script into it

original :


new addon script


test1 is from scriptlet , where it initialise as follow


note : onMouseeover and onMouseeOut word have been modified in order to allow save in this thread

in source ,



when i run it, it doesn't show the img anymore



[ October 28, 2006: Message edited by: Nakata kokuyo ]

[ October 28, 2006: Message edited by: Nakata kokuyo ]
[ October 28, 2006: Message edited by: Nakata kokuyo ]
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you've misunderstood what I was trying to get across with the "all or nothing" comment. What I mean is that in a single attribute it's either all a scriptlet or not a scriptlet. onmouseover and onmouseout are each separate attributes of the tag, so they can each have their own scriplets. Since they don't appear to have variable information in them, just code them as part of the tag. Example:

<html:link href='<%="javascript:show_calendar('document.forms[0].pre_fitdate','"+calMonth+"', '', '"+dateFormat+"');" %>' oonMouseeOver="window.status='Date Picker';return true;" oonMouseeOut="window.status='';return true;" ><html:img page="/pages/images/cal.gif" width="16" height="16" border="0" /> </html:link>
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Nakata kokuyo:
what if if i use struts-el? how it should be ? in fact, i confuse what is struts-el ?


When the Java Standard Tag Library (JSTL) was introduced a few years ago, it also introduced an Expression Language (EL) which was a way of referring to JavaBeans and their properties on a JSP page, along with some simple string and numeric expressions.

Struts has a separate tag library called html-el that has all the same tags as the <html:xxx> tags. The only difference being that these tags will allow EL expressions to be used in attributes of the tags instead of scriptlets.

To use these tags, the struts-el.jar file must be in the WEB-INF/lib directory, and you must have the following taglib definition:

<%@ taglib uri="http://jakarta.apache.org/struts/tags-html-el" prefix="html" %>
 
Nakata kokuyo
Ranch Hand
Posts: 472
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you Merrill Higginson again, you are simply too good

how to become struts expert like you , do you mind to share your secret recipe to become struts guru
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Nakata,

I'm no "Guru". I've just worked with Struts for quite a while -- nearly since it was first released. One thing I've found that has increased my knowledge is answering others' questions, especially when I have to do a little research before answering. I'd suggest you join in this forum and others on JavaRanch. See if there are questions you can answer, or might be able to answer with a little research. You'll be amazed at how fast your knowledge of the subject grows.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic