Yes, it is basically to give style to the table.
this.tablecloth = function(){
// CONFIG
// if set to true then mouseover a table cell will highlight entire
column (except sibling headings)
var highlightCols = false;
// if set to true then mouseover a table cell will highlight entire
row (except sibling headings)
var highlightRows = true;
// if set to true then click on a table sell will select row or column
based on config
var selectable = true;
// this function is called when
// add your own code if you want to add action
// function receives object that has been clicked
this.clickAction = function(obj){
//alert(obj.innerHTML);
};
// END CONFIG (do not edit below this line)
var tableover = false;
this.start = function(){
var tables = document.getElementsByTagName("table");
for (var i=0;i<tables.length;i++){
tables[i].onmouseover = function(){tableover = true};
tables[i].onmouseout = function(){tableover = false};
rows(tables[i]);
};
};
this.rows = function(table){
var css = "";
var tr = table.getElementsByTagName("tr");
for (var i=0;i<tr.length;i++){
css = (css == "odd") ? "even" : "odd";
tr[i].className = css;
var arr = new Array();
for(var j=0;j<tr[i].childNodes.length;j++){
if(tr[i].childNodes[j].nodeType == 1)
arr.push(tr[i].childNodes[j]);
};
for (var j=0;j<arr.length;j++){
arr[j].row = i;
arr[j].col = j;
if(arr[j].innerHTML == " " || arr[j].innerHTML == "")
arr[j].className += " empty";
arr[j].css = arr[j].className;
arr[j].onmouseover = function(){
over(table,this,this.row,this.col);
};
arr[j].onmouseout = function(){
out(table,this,this.row,this.col);
};
arr[j].onmousedown = function(){
down(table,this,this.row,this.col);
};
arr[j].onmouseup = function(){
up(table,this,this.row,this.col);
};
arr[j].onclick = function(){
click(table,this,this.row,this.col);
};
};
};
};
// appyling mouseover state for objects (th or td)
this.over = function(table,obj,row,col){
if (!highlightCols && !highlightRows) obj.className = obj.css + "
over";
if(check1(obj,col)){
if(highlightCols) highlightCol(table,obj,col);
if(highlightRows) highlightRow(table,obj,row);
};
};
// appyling mouseout state for objects (th or td)
this.out = function(table,obj,row,col){
if (!highlightCols && !highlightRows) obj.className = obj.css;
unhighlightCol(table,col);
unhighlightRow(table,row);
};
// appyling mousedown state for objects (th or td)
this.down = function(table,obj,row,col){
obj.className = obj.css + " down";
};
// appyling mouseup state for objects (th or td)
this.up = function(table,obj,row,col){
obj.className = obj.css + " over";
};
// onclick event for objects (th or td)
this.click = function(table,obj,row,col){
if(check1){
if(selectable) {
unselect(table);
if(highlightCols) highlightCol(table,obj,col,true);
if(highlightRows) highlightRow(table,obj,row,true);
document.onclick = unselectAll;
}
};
clickAction(obj);
};
this.highlightCol = function(table,active,col,sel){
var css = (typeof(sel) != "undefined") ? "selected" : "over";
var tr = table.getElementsByTagName("tr");
for (var i=0;i<tr.length;i++){
var arr = new Array();
for(j=0;j<tr[i].childNodes.length;j++){
if(tr[i].childNodes[j].nodeType == 1)
arr.push(tr[i].childNodes[j]);
};
var obj = arr[col];
if (check2(active,obj) && check3(obj)) obj.className = obj.css +
" " + css;
};
};
this.unhighlightCol = function(table,col){
var tr = table.getElementsByTagName("tr");
for (var i=0;i<tr.length;i++){
var arr = new Array();
for(j=0;j<tr[i].childNodes.length;j++){
if(tr[i].childNodes[j].nodeType == 1)
arr.push(tr[i].childNodes[j])
};
var obj = arr[col];
if(check3(obj)) obj.className = obj.css;
};
};
this.highlightRow = function(table,active,row,sel){
var css = (typeof(sel) != "undefined") ? "selected" : "over";
var tr = table.getElementsByTagName("tr")[row];
for (var i=0;i<tr.childNodes.length;i++){
var obj = tr.childNodes[i];
if (check2(active,obj) && check3(obj)) obj.className = obj.css +
" " + css;
};
};
this.unhighlightRow = function(table,row){
var tr = table.getElementsByTagName("tr")[row];
for (var i=0;i<tr.childNodes.length;i++){
var obj = tr.childNodes[i];
if(check3(obj)) obj.className = obj.css;
};
};
this.unselect = function(table){
tr = table.getElementsByTagName("tr")
for (var i=0;i<tr.length;i++){
for (var j=0;j<tr[i].childNodes.length;j++){
var obj = tr[i].childNodes[j];
if(obj.className) obj.className =
obj.className.replace("selected","");
};
};
};
this.unselectAll = function(){
if(!tableover){
tables = document.getElementsByTagName("table");
for (var i=0;i<tables.length;i++){
unselect(tables[i])
};
};
};
this.check1 = function(obj,col){
return (!(col == 0 && obj.className.indexOf("empty") != -1));
}
this.check2 = function(active,obj){
return (!(active.tagName == "TH" && obj.tagName == "TH"));
};
this.check3 = function(obj){
return (obj.className) ? (obj.className.indexOf("selected") == -1) :
true;
};
start();
};
/* script initiates on page load. */
window.onload = tablecloth;
2009/11/8 Martin Gainty <[email protected]>
>
> can you display the function(s) inside tablecloth.js
>
> thx
> Martin Gainty
> ______________________________________________
> Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
>
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
> Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte
> Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht
> dient lediglich dem Austausch von Informationen und entfaltet keine
> rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
> E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
> destinataire prévu, nous te demandons avec bonté que pour satisfaire
> informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie
> de ceci est interdite. Ce message sert à l'information seulement et n'aura
> pas n'importe quel effet légalement obligatoire. Étant donné que les email
> peuvent facilement être sujets à la manipulation, nous ne pouvons accepter
> aucune responsabilité pour le contenu fourni.
>
>
>
>
> > Date: Sun, 8 Nov 2009 20:49:29 +0100
> > Subject: Re: sx:div and executeScript
> > From: [email protected]
> > To: [email protected]
> >
> > This is the jsp I'm calling:
> >
> > <%@ page contentType="text/html; charset=UTF-8" %>
> > <%@ taglib prefix="s" uri="/struts-tags" %>
> > <%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
> >
> > <?xml version="1.0" encoding="UTF-8" ?>
> > <%@ page language="java" contentType="text/html; charset=UTF-8"
> > pageEncoding="UTF-8"%>
> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
> > http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> > <html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="
> > http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">
> > <head>
> > <link href="tablecloth/tablecloth.css" rel="stylesheet" type="text/css"
> > media="screen" />
> > <script language="JavaScript" src="tablecloth/tablecloth.js"
> > type="text/javascript"></script>
> >
> > <sx:head/>
> >
> > </head>
> > <body>
> >
> > <table>
> > <tr>
> > <th><s:text name="Title"/></th>
> > <th><s:text name="Author"/></th>
> > <th><s:text name="Ending"/></th>
> > <th><s:text name="Energy"/></th>
> > <th><s:text name="Flatness"/></th>
> > <th><s:text name="Validate"/></th>
> > <th><s:text name="Play"/></th>
> > </tr>
> >
> > <s:iterator value="songs" status="rowstatus">
> > <tr>
> > <td ><s:property value="songs[#rowstatus.index].title"/></td>
> > <td >
> > <s:property value="songs[#rowstatus.index].author"/>
> > </td>
> > <s:hidden name = "songs[%{#rowstatus.index}].id">
> > </s:hidden>
> > </tr>
> >
> > </s:iterator>
> >
> > </table>
> >
> > </body>
> >
> > </html>
> >
> > and I would like to call the Javascript function:
> > window.onload = tablecloth;
> >
> >
> > 2009/11/8 Martin Gainty <[email protected]>
> >
> > >
> > > then the href should call the javascript function instead of the
> supplied
> > > URL
> > > please post the complete jsp (with the javascript function you want to
> > > call)
> > >
> > > Martin Gainty
> > > ______________________________________________
> > > Verzicht und Vertraulichkeitanmerkung/Note de déni et de
> confidentialité
> > >
> > > Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
> > > Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede
> unbefugte
> > > Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese
> Nachricht
> > > dient lediglich dem Austausch von Informationen und entfaltet keine
> > > rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
> > > E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> > > Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas
> le
> > > destinataire prévu, nous te demandons avec bonté que pour satisfaire
> > > informez l'expéditeur. N'importe quelle diffusion non autorisée ou la
> copie
> > > de ceci est interdite. Ce message sert à l'information seulement et
> n'aura
> > > pas n'importe quel effet légalement obligatoire. Étant donné que les
> email
> > > peuvent facilement être sujets à la manipulation, nous ne pouvons
> accepter
> > > aucune responsabilité pour le contenu fourni.
> > >
> > >
> > >
> > >
> > > > Date: Sun, 8 Nov 2009 17:37:19 +0100
> > > > Subject: Re: sx:div and executeScript
> > > > From: [email protected]
> > > > To: [email protected]
> > > >
> > > > I'm using <sx:head/>. Not theme="ajax", I think the last version does
> not
> > > > support this theme. The href attribute points a working url, however
> > > > Javascript is not executed when the ajax url is loaded.
> > > >
> > > > 2009/11/8 Martin Gainty <[email protected]>
> > > >
> > > > >
> > > > > assuming theme="ajax"
> > > > > then the div href would be
> > > > >
> > > > > href
> > > > > false
> > > > >
> > > > >
> > > > > false
> > > > > String
> > > > > The URL to call to obtain
> the
> > > > > content. Note: If used with ajax context, the value must be set as
> an
> > > url
> > > > > tag value.
> > > > > make sure your href attribute points a working url such as what is
> > > > > illustrated here
> > > > > http://struts.apache.org/2.1.8/docs/ajax-div-template.html
> > > > >
> > > > > Martin Gainty
> > > > > ______________________________________________
> > > > > Verzicht und Vertraulichkeitanmerkung/Note de déni et de
> > > confidentialité
> > > > >
> > > > > Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
> > > > > Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede
> > > unbefugte
> > > > > Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese
> > > Nachricht
> > > > > dient lediglich dem Austausch von Informationen und entfaltet keine
> > > > > rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit
> von
> > > > > E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> > > > > Ce message est confidentiel et peut être privilégié. Si vous n'êtes
> pas
> > > le
> > > > > destinataire prévu, nous te demandons avec bonté que pour
> satisfaire
> > > > > informez l'expéditeur. N'importe quelle diffusion non autorisée ou
> la
> > > copie
> > > > > de ceci est interdite. Ce message sert à l'information seulement et
> > > n'aura
> > > > > pas n'importe quel effet légalement obligatoire. Étant donné que
> les
> > > email
> > > > > peuvent facilement être sujets à la manipulation, nous ne pouvons
> > > accepter
> > > > > aucune responsabilité pour le contenu fourni.
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > > Date: Sat, 7 Nov 2009 17:44:28 +0100
> > > > > > Subject: sx:div and executeScript
> > > > > > From: [email protected]
> > > > > > To: [email protected]
> > > > > >
> > > > > > Hi,
> > > > > >
> > > > > > I'm using sx:div for loading a content after the page is loaded.
> > > > > > But, I have problems because Javascript is not working in the
> page
> > > linked
> > > > > by
> > > > > > <sx:div ..>. I read about a solution with Struts2.1.2 (I'm using
> > > > > > Struts2.1.8) in this page(
> > > > > >
> > > > >
> > >
> http://mail-archives.apache.org/mod_mbox/struts-issues/200808.mbox/%3c2107922214.1217595186486.javamail.j...@brutus%3e
> > > > > ,
> > > > > > but it did not work for me.
> > > > > > I'm using this code:
> > > > > > <sx:div id="tableScroll"label="table" href="%{#table}"
> > > > > > separateScripts="false" executeScripts="true">
> > > > > > Carregant'se
> > > > > > </sx:div>
> > > > > > and the returned code is a populated table.
> > > > > > I changed the jar struts2-dojo-plugin-2.1.8.jar, how the thread
> > > > > indicates,
> > > > > > but nothing changed.
> > > > > > I need Javacript in the returned content. Please, I need help.
> > > > > >
> > > > > >
> > > > > > Thanks in advance,
> > > > > >
> > > > > > Irene
> > > > >
> > > > > _________________________________________________________________
> > > > > Find the right PC with Windows 7 and Windows Live.
> > > > >
> > > > >
> > >
> http://www.microsoft.com/Windows/pc-scout/laptop-set-criteria.aspx?cbid=wl&filt=200,2400,10,19,1,3,1,7,50,650,2,12,0,1000&cat=1,2,3,4,5,6&brands=5,6,7,8,9,10,11,12,13,14,15,16&addf=4,5,9&ocid=PID24727::T:WLMTAGL:ON:WL:en-US:WWL_WIN_evergreen2:112009
> > > > >
> > >
> > > _________________________________________________________________
> > > Hotmail: Trusted email with Microsoft's powerful SPAM protection.
> > > http://clk.atdmt.com/GBL/go/177141664/direct/01/
> > > http://clk.atdmt.com/GBL/go/177141664/direct/01/
> > >
>
> _________________________________________________________________
> Hotmail: Trusted email with Microsoft's powerful SPAM protection.
> http://clk.atdmt.com/GBL/go/177141664/direct/01/
> http://clk.atdmt.com/GBL/go/177141664/direct/01/
>