You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2002/05/01 06:13:57 UTC

DO NOT REPLY [Bug 8688] New: - Improved Javascript for Link Tag

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8688>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8688

Improved Javascript for Link Tag

           Summary: Improved Javascript for Link Tag
           Product: Struts
           Version: 1.1 Beta 1
          Platform: All
               URL: http://www.phase.ws/linktag/taglib.zip
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Custom Tags
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: mail@phase.ws


I don't know if a similar solution has been provided, but, I tweaked the Link 
Tag to support the writing of 'javascript:[function_name]
([param1,param2,param3...])' to the href
attribute of the final output. Here is a summarization of it's functionality:

I added the following attributes:

function - This is the name of the javascript function that will be called;

functionName - This is the name of the bean that will provide parameter
values from one of it's properties.

functionProperty - This is a property of a bean that will either provide a
String or an ArrayList to populate the parameters of the function

urlIndex - This allows you to include the url generated by href,forward or
page to be included at a specific place in the function's parameters.

There is another class that I wrote that does the actual processing and
preparation of the url. I named it EcmaUtil.  I modeled the computeURL and
computerParam methods of the RequestUtils class when I built the methods for
the EcmaUtil.

The LinkTag class that I wrote extends the BaseHandlerTag under the
org.apache.struts.taglib.html package of struts jar.

I know the code needs a bit of reworking to fit back in to the struts
framework. I stripped out the MessageReources for the most part and removed
some exception handling that will need to be included again.

Anyways, if nobody has done this in the nightly or if it sounds like it
might be of use. Let me know and I will post the code,the tld and an example
of it's usage.

EXAMPLE OF USAGE:

This tag works exactly like the struts html tag with expanded feature outlined 
above:

<pwshtml:link forward="listings/detail/popup" function="popUpWin" urlIndex="1" 
paramId="image" paramName="image">
<img src="image.jpg"> some text</pwshtml:link>

This code will produce the follwing html
<a href="javascript:popUpWin('/do/listings/detail/popup?
image=NWMT203336.jpg')"><img src="image.jpg"></a>

Of course some of the elements are arbitrary to the values in your beans. But 
you should be able to traverse the code and get the idea.

P.S. I am in the process of submitting this to struts for inclusion with the 
base package. Give me a vote on the message boards if you think this will be a 
good contribution. Also, feel free to enhance features.

Let me know,
Brandon Goodin
Phase Web and Multimedia
P(406)862-2245
F(406)862-0354
http://www.phase.ws
mail@phase.ws

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>