You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Laurent Cornelis <la...@ubiquity.be> on 2003/06/17 11:38:06 UTC

Form name is null in scripts

Hi,

I have a problem with Javascript and Tapestry 2.3. On my scripts, the form
name is not rendered.



I have a script file (/somepath/myapp.script) :


----------------------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script PUBLIC
"-//Howard Lewis Ship//Tapestry Script 1.2//EN"
"http://tapestry.sf.net/dtd/Script_1_2.dtd">
<script>
<include-script resource-path="/somepath/myapp.js"/>
<input-symbol key="page" required="yes"/>
<set key="formName" expression="page.form.name"/>
<set key="name" expression="page.name"/>
<!-- baseName - base name from which other names are generated -->
<let key="baseName">
${formName}_${name}
</let>
<let key="formPath">
document.${formName}
</let>
<body>
function clearCheckboxes() {
clearCheckboxes(${formPath});
}
</body>
<initialization/>
</script>

----------------------------------------------------------------------


Here is the script component in my page :


----------------------------------------------------------------------

<component id="Script" type="Script">
<static-binding name="script">/somepath/myapp.script</static-binding>
<binding name="symbols" expression="scriptSymbols"/>
</component>

----------------------------------------------------------------------

In my page class I have :


----------------------------------------------------------------------
private Map _scriptSymbols;

public MyPage() {
_scriptSymbols = new HashMap();
_scriptSymbols.put("page",this);
}

public Map getScriptSymbols() {
return _scriptSymbols;
}

public IForm getForm() {
return (IForm)getComponent("myForm");
}


----------------------------------------------------------------------

In my template, I have :

----------------------------------------------------------------------

<!-- generated by Spindle, http://spindle.sourceforge.net -->
<html>
<body>
<!-- begin of $content$ -->
<span jwcid="$content$">
<span jwcid="shell">
<body jwcid="body">
<span jwcid="Script"/>
[...]

----------------------------------------------------------------------


And when I run the page, the form name is not generated, here is what I have
:


----------------------------------------------------------------------

<script language="JavaScript" type="text/javascript"
src="/myapp?service=asset&amp;sp=%2Fsomepath%2Fmyapp.js"></script>
<script language="JavaScript"><!--
function clearCheckboxes() {
 clearCheckboxes(document.);
}
// --></script>

----------------------------------------------------------------------

As you can see, the form name is not rendered (document.). What I am doing
wrong ? I'm a bit lost.

Thanks,

Laurent CORNELIS


Re: Form name is null in scripts

Posted by Laurent Cornelis <la...@ubiquity.be>.
Thanks, it works perfectly :-)

> Hi,
>
>     Please move the script component under the form one in the template.
>
>     The form name is generated dynamically (since it can be in a loop, for
> example) at the time the form is rendered. Moving the script component
under
> the form would resolve the issue, I believe.
>
> -mb



Re: Form name is null in scripts

Posted by Mindbridge <mi...@yahoo.com>.
Hi,

    Please move the script component under the form one in the template.

    The form name is generated dynamically (since it can be in a loop, for
example) at the time the form is rendered. Moving the script component under
the form would resolve the issue, I believe.

-mb

----- Original Message ----- 
From: "Laurent Cornelis" <la...@ubiquity.be>
To: <ta...@jakarta.apache.org>
Sent: Tuesday, June 17, 2003 12:38 PM
Subject: Form name is null in scripts


> Hi,
>
> I have a problem with Javascript and Tapestry 2.3. On my scripts, the form
> name is not rendered.
>
>
>
> I have a script file (/somepath/myapp.script) :
>
>
> ----------------------------------------------------------------------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE script PUBLIC
> "-//Howard Lewis Ship//Tapestry Script 1.2//EN"
> "http://tapestry.sf.net/dtd/Script_1_2.dtd">
> <script>
> <include-script resource-path="/somepath/myapp.js"/>
> <input-symbol key="page" required="yes"/>
> <set key="formName" expression="page.form.name"/>
> <set key="name" expression="page.name"/>
> <!-- baseName - base name from which other names are generated -->
> <let key="baseName">
> ${formName}_${name}
> </let>
> <let key="formPath">
> document.${formName}
> </let>
> <body>
> function clearCheckboxes() {
> clearCheckboxes(${formPath});
> }
> </body>
> <initialization/>
> </script>
>
> ----------------------------------------------------------------------
>
>
> Here is the script component in my page :
>
>
> ----------------------------------------------------------------------
>
> <component id="Script" type="Script">
> <static-binding name="script">/somepath/myapp.script</static-binding>
> <binding name="symbols" expression="scriptSymbols"/>
> </component>
>
> ----------------------------------------------------------------------
>
> In my page class I have :
>
>
> ----------------------------------------------------------------------
> private Map _scriptSymbols;
>
> public MyPage() {
> _scriptSymbols = new HashMap();
> _scriptSymbols.put("page",this);
> }
>
> public Map getScriptSymbols() {
> return _scriptSymbols;
> }
>
> public IForm getForm() {
> return (IForm)getComponent("myForm");
> }
>
>
> ----------------------------------------------------------------------
>
> In my template, I have :
>
> ----------------------------------------------------------------------
>
> <!-- generated by Spindle, http://spindle.sourceforge.net -->
> <html>
> <body>
> <!-- begin of $content$ -->
> <span jwcid="$content$">
> <span jwcid="shell">
> <body jwcid="body">
> <span jwcid="Script"/>
> [...]
>
> ----------------------------------------------------------------------
>
>
> And when I run the page, the form name is not generated, here is what I
have
> :
>
>
> ----------------------------------------------------------------------
>
> <script language="JavaScript" type="text/javascript"
> src="/myapp?service=asset&amp;sp=%2Fsomepath%2Fmyapp.js"></script>
> <script language="JavaScript"><!--
> function clearCheckboxes() {
>  clearCheckboxes(document.);
> }
> // --></script>
>
> ----------------------------------------------------------------------
>
> As you can see, the form name is not rendered (document.). What I am doing
> wrong ? I'm a bit lost.
>
> Thanks,
>
> Laurent CORNELIS
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org