Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Accessing t:dataTable tag rowCountVar in JavaScript

 
m yasmin
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am trying to access the rowCountVar tag for t:dataTable in javascript. Here is the code snippet:

<t:dataTable id="emailTable" rowCountVar="rowCountVar">
... ... ...

<script>
var rowCount = "<%=rowCountVar%>";
alert("Number of rows in the table = " + rowCount);
</script>
</t:dataTable>

The jsp page does not load because javascript cannot resolve rowCountVar.

Please help!!
Yasmin
 
a phil
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi yasmin,

I see that you are trying to access a server-side dynamic value as a javascript's input value. Practically I dont think this is possible because of the fact that you are trying to dynamically update (this happen on the fly through jsp engine) a static field value after the page is processed by the jsp engine.

I see that you can solve your problem in 2 ways:

1). You can declare a hidden variable on you jsp and through javascript get the value of this hidden field and update your javascript's value with the hidden field value. Please remember to update this hidden variable through you backing bean.

2). You can still use the above suggested mechanism by actually updating the javascript variable with the same scriptlet you have currently. You would again need to assign this scriptlet value to some hidden variable and inturn capture this hidden field's value before rendering and assign to the javascript variable.

Please hollar if you found a better solution. Gud luck!
 
m yasmin
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Phil,
Thanks for replying to my post. I went with solution 1.

Yasmin
 
m yasmin
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Phil,
Thanks for replying to my post. I went with solution 1.

Yasmin
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!