Hi, Thanks for the valuable information. The problem is my company is not using ajax at the moment. Is there any other way to call the javascipt funtion in struts tag. I have a java script function placed in web project. This function returns a value
function shortenTextLength(text, textlength) { var textValue = text; if (textValue.length > textlength){ var shortenedText = textValue.substring(0,textlength) + "..."; }else{ var shortenedText = text; } return (shortenedText); } I want to call function shortenTextLength(text, textlength) in JSP using struts tag. regards, Varun mgainty wrote: > > lets say you have some tag which has its base function called > updateReports() > > assuming the div tag has theme="ajax" referencing > http://struts.apache.org/2.0.11/docs/ajax-div-template.html > <saf:head theme="ajax" /> > function doit(){ document.login_form.hidden_id.value="01420";}</script> > <script type="text/javascript"> > function updateReports(id) { doit(); //this modifies the > zipcode (id) for the weather id = > document.login_form.hidden1.value; > var reportDiv= window['reportDivId']; reportDiv.href = > '/../reportListRemote.action?selectedId='+id; > reportDiv.refresh(); } > dojo.event.topic.getTopic("updateReportsListTopic").subscribe(null, > "updateReports"); > </script> > Here is the html > <html> > <body> > <form> > <table> > <input type="hidden" name="hidden1" value="hidden1"> > ..</table></form></body></html>HTHM------- Original Message ----- > From: "Varun Ratra" <[EMAIL PROTECTED]> > To: <user@struts.apache.org> > Sent: Friday, February 22, 2008 4:05 PM > Subject: How to call javascript from Struts tag > > >> >> Hello everyone, >> >> I have been researching on the web on how to call javascript from Struts >> tag. >> I am using struts 2 to develop JSP. Following is the piece of code in >> JSP, >> which calls javascript >> <td class="nowrap"> >> <script type="text/javascript"> >> document.write(shortenTextLength('${defaultReturnReason}', >> '${displayLength}')) >> </script> >> </td> >> The script returns a shortened value of defaultReturnReason based >> displayLength >> I want to use struts tag to call javascript shortenTextLength(). In other >> words, I want to embed javascript inside struts tag. >> Please suggest how I can achieve this. >> -- >> View this message in context: > http://www.nabble.com/How-to-call-javascript-from-Struts-tag-tp15641406p1564 > 1406.html >> Sent from the Struts - User mailing list archive at Nabble.com. >> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/How-to-call-javascript-from-Struts-tag-tp15641406p15740609.html Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]