Muhariz Jabeer wrote:
hey guys, I was trying to create this page which lists a collection of
filenames using a ForEach component and passes on the name of the file
clicked to a Script Component.
What i was doing was creating the Script Component inside the ForEach loop
with the name of the file as an input symbol. Then when the link is clicked,
i tried calling the method
inside the script which displayed the filename associated with it.
I guess that what happens is that for each iteration the script
'openFile' is generated. So each iteration overwrites the previous
script function. Perhaps you should have a javascript that takes the
filename as an argument and instead modify so; onClick="ognl:'openFile('
+ fileName.name + ');'"
I have not tried it but somehting like that.
The probelm im having is this: Even though the script component is in the
ForEach component, the last added filename pops up everytime i click on any
of the files.
<tr jwcid="@Foreach" source="ognl:case.filesList"
value="ognl:fileName"element="tr">
<td class="field"><strong><a jwcid="@Insert" value="ognl:fileName.name
"/></strong></td>
<td class="field" colspan="2">
<span jwcid="@Script" script="scripts/viewFile.script" name="ognl:
fileName.name"/>
<a jwcid="@DirectLink" listener="ognl:listeners.viewFile" parameters="ognl:
fileName.name" onClick="openFile();">View</a>
<a jwcid="@DirectLink" listener="ognl:listeners.removeFile"
parameters="ognl:fileName.name">Remove</a>
</td>
</tr>
the script:
<?xml version="1.0"?>
<!DOCTYPE script PUBLIC
"-//Apache Software Foundation//Tapestry Script Specification 3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Script_3_0.dtd">
<script>
<input-symbol key="name" class="java.lang.String" required="yes"/>
<body>
function openFile()
{
alert("${name}");
}
</body>
<initialization>
</initialization>
</script>
----------------------------------------------------------
Is this aproach going to work? All i wanna do is pass the correct filename
to the script.
pls help,
Thanx,
Muhariz.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]