Hi all. I'm trying to use javascript with Tapestry 4.1.6 and I'm stumbling at the very first steps.
First of all I see that whenever a form component is specified in the template Tapestry put a script at the end of the generated html that set the focus on the first control of the form. If I try to put my specific function to give focus to a control of my choice, the automatically generated script is put as the last statement hence overruling my script. Secondly (I need a log introduction) I have used the example given in http://tapestry.apache.org/tapestry4.1/components/general/script.html to give focus to a control of my choice, but it fails: the problem is that when executed function setFocus() { var inputField = document.barCodeForm_0.barCode; if (inputField.type != "hidden") { if (inputField.disabled != true) { inputField.focus(); } } else { window.alert('InputFocus.script cannot set focus on a hidden field'); } } I debugged it using firebug and it seems then document.barCodeForm_0 is undefined. Actually looking at the generated html , barCodeForm_0 is there. But the html as a whole is a little weird. I attach it to the end of this message: the point is that html tag is closed and reopened several times. I'm not enough javascript expert to understand if this is could cause my problem but looks anyeay bad to me. Here is my question: I had read that T416 templates have to be well formed HTML files but looking at the Tapestry Bench application I see that html templates don't include <html>, <head> and <body> tags. May I include them ? -----------------generated html-------------------------- <html> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- Application: app --> <!-- Page: HomeLoggedUser --> <!-- Generated: Mon Jan 04 15:54:56 CET 2010 --> <html> <head> <meta name="generator" content="Tapestry Application Framework, version 4.1.6-SNAPSHOT" /> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <title>Home Guide</title> <script type="text/javascript">djConfig = {"baseRelativePath":"/METGestioneIngressi/app?service=asset&path=%2Fdojo-0.4.3-custom-4.1.6%2F","preventBackButtonFix":false,"parseWidgets":false,"locale":"it-it"} </script> <script type="text/javascript" src="/METGestioneIngressi/app?service=asset&path=%2Fdojo-0.4.3-custom-4.1.6%2Fdojo.js <view-source:http://localhost:8081/METGestioneIngressi/app?service=asset&path=%2Fdojo-0.4.3-custom-4.1.6%2Fdojo.js>"></script><script type="text/javascript" src="/METGestioneIngressi/app?service=asset&path=%2Fdojo-0.4.3-custom-4.1.6%2Fdojo2.js <view-source:http://localhost:8081/METGestioneIngressi/app?service=asset&path=%2Fdojo-0.4.3-custom-4.1.6%2Fdojo2.js>"></script> <script type="text/javascript"> dojo.registerModulePath("tapestry", "/METGestioneIngressi/app?service=asset&path=%2Ftapestry-4.1.6%2F"); </script> <script type="text/javascript" src="/METGestioneIngressi/app?service=asset&path=%2Ftapestry-4.1.6%2Fcore.js <view-source:http://localhost:8081/METGestioneIngressi/app?service=asset&path=%2Ftapestry-4.1.6%2Fcore.js>"></script> <script type="text/javascript"> dojo.require("tapestry.namespace"); tapestry.requestEncoding='UTF-8'; </script> </head> <title>MET Online</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <link href="css/stile_palmare.css <view-source:http://localhost:8081/METGestioneIngressi/css/stile_palmare.css>" rel="stylesheet" type="text/css"> </html> <!-- Render time: ~ 172 ms --> <body id="tapBody"> <script type="text/javascript"><!-- function setFocus() { var inputField = document.barCodeForm_0.barCode; if (inputField.type != "hidden") { if (inputField.disabled != true) { inputField.focus(); } } else { window.alert('InputFocus.script cannot set focus on a hidden field'); } } // --></script> <div id="container"> <h1>Battistero</h1> <html> <head> <title>MET Online</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <link href="css/stile_palmare.css <view-source:http://localhost:8081/METGestioneIngressi/css/stile_palmare.css>" rel="stylesheet" type="text/css"> </head> <body> <div id="box_operazione"> <h1>Lettura BarCode</h1> <br /> <h2>passare il barcode sotto il lettore ottico</h2> <form method="post" action="/METGestioneIngressi/app" id="barCodeForm_0"> <div style="display:none;" id="barCodeForm_0hidden"><input type="hidden" name="formids" value="barCode" /> <input type="hidden" name="seedids" value="BrO0ABXdtAGssc2VydmljZSQwLHBhZ2UkMCxjb21wb25lbnQkMCxjb250YWluZXIkMCxzZXNzaW9uJDAsc3AkMCx0YXBTaGVsbCQwLHRhcEJvZHkkMCxub21lTW9udW1lbnRvJDAsYmFyQ29kZUZvcm0kMQ==" /> <input type="hidden" name="component" value="barCodeForm.barCodeForm" /> <input type="hidden" name="page" value="HomeLoggedUser" /> <input type="hidden" name="service" value="direct" /> <input type="hidden" name="session" value="T" /> <input type="hidden" name="submitmode" value="" /> <input type="hidden" name="submitname" value="" /> </div> <input type="text" name="barCode" value="" id="barCode" class="text_box" /> <br /><br /> <input type="submit" name="Submit" value="Submit" class="bottone"> </form> </div> </body> </html> <div id="box_logout"> <table width="100%" border="0" cellpadding="2" cellspacing="0"> <tbody> <tr> <td id="submenu" class="submenu-act"> <a id="linklogout" href="/METGestioneIngressi/app?component=menu.linklogout&page=HomeLoggedUser&service=direct&session=T <view-source:http://localhost:8081/METGestioneIngressi/app?component=menu.linklogout&page=HomeLoggedUser&service=direct&session=T>">LogOut</a> </td> </tr> </tbody> </table> </div> </div> <script type="text/javascript"><!-- tapestry.addOnLoad(function(e) { dojo.require("tapestry.form");tapestry.form.registerForm("barCodeForm_0"); setFocus(); tapestry.form.focusField('barCode');}); // --></script></body> </html> -- ================================================== dott. Ivano Mario Luberti Archimede Informatica societa' cooperativa a r. l. Sede Operativa Via Gereschi 36 - 56126- Pisa tel.: +39-050- 580959 tel/fax: +39-050-9711344 web: www.archicoop.it ================================================== --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org