You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "F. Da Costa" <da...@xs4all.nl> on 2004/01/04 15:21:33 UTC

[script] How to use the

Hi,

Still trying to get a handle on the .script 'stuff'
Following two snips.
The .page snip works fine. Debugger shows that the gets are made.

<component id="scr0" type="Script">
  <static-binding name="script" value="test0.script" />
  <binding name="test" expression="test" /> *is retrieved*
  <binding name="tstRows" expression="rows" /> *is retrieved*
</component>

The .script however only works for the single function.
The multi() function does not work, as in the ${row} does not show a value 
(whilst the ArrayList is definitely filled).
Q: What am i missing here?

<script>
  <input-symbol key="test" />
  <input-symbol key="tstRows" /> *no go with or without this line*
  <set key="tst" expression="test" />
	
<body>
  <![CDATA[
    // this works fine
   function single() {
    alert("${tst}");
   }

   // This does *not* show the ${row}
   function multi() {
    var s = "The String ";
     <foreach key="row" source="tstRows">
       s = s + ${row}+"~";
     </foreach>
    alert(s);
   }

  ]]>
  </body>

TIA
Fermin DCG


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: [script] How to use the

Posted by "F. Da Costa" <da...@xs4all.nl>.
F. Da Costa wrote:

> Hi,
> 
> Still trying to get a handle on the .script 'stuff'
> Following two snips.
> The .page snip works fine. Debugger shows that the gets are made.
> 
> <component id="scr0" type="Script">
>  <static-binding name="script" value="test0.script" />
>  <binding name="test" expression="test" /> *is retrieved*
>  <binding name="tstRows" expression="rows" /> *is retrieved*
> </component>
> 
> The .script however only works for the single function.
> The multi() function does not work, as in the ${row} does not show a 
> value (whilst the ArrayList is definitely filled).
> Q: What am i missing here?
> 
> <script>
>  <input-symbol key="test" />
>  <input-symbol key="tstRows" /> *no go with or without this line*
>  <set key="tst" expression="test" />
>     
> <body>
>  <![CDATA[
>    // this works fine
>   function single() {
>    alert("${tst}");
>   }
> 
>   // This does *not* show the ${row}
>   function multi() {
>    var s = "The String ";
>     <foreach key="row" source="tstRows">
>       s = s + ${row}+"~";
This should be:
  s = s + "${row}" + "~"; *does not work either however, ${row} is empty?*
>     </foreach>
>    alert(s);
>   }
> 
>  ]]>
>  </body>
> 
> TIA
> Fermin DCG
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: [script] How to use the (SOLVED)

Posted by "F. Da Costa" <da...@xs4all.nl>.
Harish Krishnaswamy wrote:
> Hi Fermin,
> 
> Sorry, I was wrong about the <input-symbol> before, the type is 
> maintained irrespective of whether the "class" attribute is specified or 
> not. But I just noticed a problem, and that is you are enclosing the 
> <foreach> inside the CDATA block. Anything inside the CDATA block is 
> rendered unaltered. If you take a look at the source of the rendered web 
> page you will see the <foreach>. Hope this helps.
M a n, it most certainly does. Its actually quite logical because its meant 
for literal interpretation of the code ...

Not feeling too clever right now! ;)

Thx

Fermin
> 
> -Harish
> 
> F. Da Costa wrote:
> 
>> Hi,
>>
>> Still trying to get a handle on the .script 'stuff'
>> Following two snips.
>> The .page snip works fine. Debugger shows that the gets are made.
>>
>> <component id="scr0" type="Script">
>>  <static-binding name="script" value="test0.script" />
>>  <binding name="test" expression="test" /> *is retrieved*
>>  <binding name="tstRows" expression="rows" /> *is retrieved*
>> </component>
>>
>> The .script however only works for the single function.
>> The multi() function does not work, as in the ${row} does not show a 
>> value (whilst the ArrayList is definitely filled).
>> Q: What am i missing here?
>>
>> <script>
>>  <input-symbol key="test" />
>>  <input-symbol key="tstRows" /> *no go with or without this line*
>>  <set key="tst" expression="test" />
>>     <body>
>>  <![CDATA[
>>    // this works fine
>>   function single() {
>>    alert("${tst}");
>>   }
>>
>>   // This does *not* show the ${row}
>>   function multi() {
>>    var s = "The String ";
>>     <foreach key="row" source="tstRows">
>>       s = s + ${row}+"~";
>>     </foreach>
>>    alert(s);
>>   }
>>
>>  ]]>
>>  </body>
>>
>> TIA
>> Fermin DCG
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: [script] How to use the

Posted by Harish Krishnaswamy <hk...@comcast.net>.
Hi Fermin,

Sorry, I was wrong about the <input-symbol> before, the type is maintained irrespective of whether 
the "class" attribute is specified or not. But I just noticed a problem, and that is you are 
enclosing the <foreach> inside the CDATA block. Anything inside the CDATA block is rendered 
unaltered. If you take a look at the source of the rendered web page you will see the <foreach>. 
Hope this helps.

-Harish

F. Da Costa wrote:
> Hi,
> 
> Still trying to get a handle on the .script 'stuff'
> Following two snips.
> The .page snip works fine. Debugger shows that the gets are made.
> 
> <component id="scr0" type="Script">
>  <static-binding name="script" value="test0.script" />
>  <binding name="test" expression="test" /> *is retrieved*
>  <binding name="tstRows" expression="rows" /> *is retrieved*
> </component>
> 
> The .script however only works for the single function.
> The multi() function does not work, as in the ${row} does not show a 
> value (whilst the ArrayList is definitely filled).
> Q: What am i missing here?
> 
> <script>
>  <input-symbol key="test" />
>  <input-symbol key="tstRows" /> *no go with or without this line*
>  <set key="tst" expression="test" />
>     
> <body>
>  <![CDATA[
>    // this works fine
>   function single() {
>    alert("${tst}");
>   }
> 
>   // This does *not* show the ${row}
>   function multi() {
>    var s = "The String ";
>     <foreach key="row" source="tstRows">
>       s = s + ${row}+"~";
>     </foreach>
>    alert(s);
>   }
> 
>  ]]>
>  </body>
> 
> TIA
> Fermin DCG
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: [script] How to use the

Posted by "F. Da Costa" <da...@xs4all.nl>.
Harish Krishnaswamy wrote:

> Have you tried with  <input-symbol key="tstRows" 
> class="java.util.ArrayList" /> if you don't specifiy the class the
Noop, does not work either.
It gets even stranger though because I just *cannot* get the <foreach> 
working from the body. Looking at your VarPropSel.script I did get it 
working with the following code:
<script>
<input-symbol key="tstRows" />
<input-symbol key="s" class="java.lang.String" />
	
<set key="tst" expression="page.test" />
<set key="name" expression="page.pageName" />
<set key="str" expression="'Start string: '" />
	
  <body>
  <![CDATA[
   var sjs = "The String ";

   function start() {
   alert("${tst}");
   alert("${name}");
   }

   function r() {
    alert(sjs);
   }

  ]]>
  </body>

  <initialization>
     start();

    <foreach key="row" expression="tstRows">
     <foreach key="cell" expression="row">
      sjs += "${cell}"+"~";
     </foreach>
    </foreach>

	r();

  </initialization>
</script>

Judging from what I read in the Guides I was under the impression that the 
<foreach> could also be used within the <body>.
Is this conclusion correct on not?

Thx
F DCG


> default type would be String (from memory).
> 
> -Harish
> 
> F. Da Costa wrote:
> 
>> Hi,
>>
>> Still trying to get a handle on the .script 'stuff'
>> Following two snips.
>> The .page snip works fine. Debugger shows that the gets are made.
>>
>> <component id="scr0" type="Script">
>>  <static-binding name="script" value="test0.script" />
>>  <binding name="test" expression="test" /> *is retrieved*
>>  <binding name="tstRows" expression="rows" /> *is retrieved*
>> </component>
>>
>> The .script however only works for the single function.
>> The multi() function does not work, as in the ${row} does not show a 
>> value (whilst the ArrayList is definitely filled).
>> Q: What am i missing here?
>>
>> <script>
>>  <input-symbol key="test" />
>>  <input-symbol key="tstRows" /> *no go with or without this line*
>>  <set key="tst" expression="test" />
>>     <body>
>>  <![CDATA[
>>    // this works fine
>>   function single() {
>>    alert("${tst}");
>>   }
>>
>>   // This does *not* show the ${row}
>>   function multi() {
>>    var s = "The String ";
>>     <foreach key="row" source="tstRows">
>>       s = s + ${row}+"~";
>>     </foreach>
>>    alert(s);
>>   }
>>
>>  ]]>
>>  </body>
>>
>> TIA
>> Fermin DCG
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: [script] How to use the

Posted by Harish Krishnaswamy <hk...@comcast.net>.
Have you tried with  <input-symbol key="tstRows" class="java.util.ArrayList" /> if you don't 
specifiy the class the default type would be String (from memory).

-Harish

F. Da Costa wrote:

> Hi,
> 
> Still trying to get a handle on the .script 'stuff'
> Following two snips.
> The .page snip works fine. Debugger shows that the gets are made.
> 
> <component id="scr0" type="Script">
>  <static-binding name="script" value="test0.script" />
>  <binding name="test" expression="test" /> *is retrieved*
>  <binding name="tstRows" expression="rows" /> *is retrieved*
> </component>
> 
> The .script however only works for the single function.
> The multi() function does not work, as in the ${row} does not show a 
> value (whilst the ArrayList is definitely filled).
> Q: What am i missing here?
> 
> <script>
>  <input-symbol key="test" />
>  <input-symbol key="tstRows" /> *no go with or without this line*
>  <set key="tst" expression="test" />
>     
> <body>
>  <![CDATA[
>    // this works fine
>   function single() {
>    alert("${tst}");
>   }
> 
>   // This does *not* show the ${row}
>   function multi() {
>    var s = "The String ";
>     <foreach key="row" source="tstRows">
>       s = s + ${row}+"~";
>     </foreach>
>    alert(s);
>   }
> 
>  ]]>
>  </body>
> 
> TIA
> Fermin DCG
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org