This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JSF and the fly likes Accessing  t:dataTable tag rowCountVar in JavaScript Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Accessing  t:dataTable tag rowCountVar in JavaScript" Watch "Accessing  t:dataTable tag rowCountVar in JavaScript" New topic
Author

Accessing t:dataTable tag rowCountVar in JavaScript

m yasmin
Greenhorn

Joined: Nov 11, 2008
Posts: 9
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

Joined: Nov 11, 2008
Posts: 9
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

Joined: Nov 11, 2008
Posts: 9
Hi Phil,
Thanks for replying to my post. I went with solution 1.

Yasmin
m yasmin
Greenhorn

Joined: Nov 11, 2008
Posts: 9
Hi Phil,
Thanks for replying to my post. I went with solution 1.

Yasmin
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Accessing t:dataTable tag rowCountVar in JavaScript
 
Similar Threads
Problem with MyFaces t:popup tag
groupBy="true" not working
<rich:tooltip>
is it possible to write javascript in html?
Need to call javascript function from an html page.