Mikko Harjula <[EMAIL PROTECTED]> writes:

I sent this also to wrc and got an answer faster than I could spell
potato!  Just in case someone else bumps into this the explanation in
enclosed inline...

> I'm trying to define a tag that creates a pulldown menu populated from
> Yleiset.Kieli class query and initially show the value of o.kieli.
>
> I have created the following csr tag definition:
>
> <csr:rule name="SelectKieli" match="SelectKieli">
>   <csr:action>
>     <script language="cache" runat="compiler">
>       set name=%this.GetAttribute("name","kieli")
>       set init=%this.GetAttribute("init","")
>     </script>
>
>     <script language="cache" runat="server">
>       set res=##class(%ResultSet).%New("Yleiset.Kieli:Kielet")
>       do res.Execute()
>
>       write "<select name='##(name)##'>",!
>       while (res.Next()) {
>       if (res.Data("koodi") = ##(init)##) {
>         set selected="selected"
>       } else {
>         set selected=""
>       }
>
>       write "<option value='"_res.Data("koodi")_"' "_selected_">",!
>       write "  "_res.Data("nimi"),!
>       write "</option>",!
>       }
>     </script>
>   </csr:action>
> </csr:rule>
>
> and in a form call it like this:
>
> <SelectKieli name="kieli" init="#(o.kieli)#"></SelectKieli>

My error lies here.  The #()# does not get evaluated inside Cache
strings ("-quotes), but does inside '-quotes.  So the
init="#(o.kieli)#" is passing #(o.kieli)# instead of the value of
o.kieli.  The solution was to pass o.kieli as string
(i.e. init="o.kieli").  This works because in the csr <action> I use
compile time code to insert the o.kieli string into runtime code.

-- 
Mikko Harjula                   tel.   +358-3-316 7552
[EMAIL PROTECTED]         mobile +358-40-778 6669

Reply via email to