• Post Reply Bookmark Topic Watch Topic
  • New Topic

passing script parameters in custom tag  RSS feed

 
reena wadhwa
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I have created a custom tag for translation. This tag takes 4 arguments .
I have to use this tag inside my jsp. But i have to pass my java script variables as parameters.
My JSP code is as below:
<SCRIPT Language="JavaScript">

function errorI18N_listboxItem(itemName, itemIndex, numOfItems)
{
return <itc:translate key="access.listboxItemTooltip" arg0="${itemName}" arg1="${ itemIndex }" arg2="${ numOfItems }" />;
}

</script>

But parameters passed to tag does not take value of variables but taking the variable name itself. I mean if itemIndex is 5 it is getting passed as itemIndex not as 5.
I even tried with following code.

function errorI18N_listboxItem(itemName, itemIndex, numOfItems)
{
return '<itc:translate key="access.listboxItemTooltip" arg0="' + itemName + '" arg1="' + itemIndex + '" arg2="' + numOfItems + '" />';
}

No use. Still it pass arg1 as ' + itemIndex + ' not as 5.
Can anyone help here.
Thanks.
 
Ankit Garg
Sheriff
Posts: 9608
36
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi reena welcome to javaranch

please Use Code Tags when you post a source code. You can edit your message using button and then add code tags to it.

The second should have worked. Can you try this

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course that's not going to work. The JSP tags are evaluated on the server long before the HTML page is sent to the browser where the JavaScript can be evaluated.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!