Index: openacs-4/packages/xowiki/tcl/form-field-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/form-field-procs.tcl,v diff -u -N -r1.215 -r1.216 --- openacs-4/packages/xowiki/tcl/form-field-procs.tcl 17 Aug 2012 08:00:21 -0000 1.215 +++ openacs-4/packages/xowiki/tcl/form-field-procs.tcl 21 Aug 2012 15:43:32 -0000 1.216 @@ -869,6 +869,10 @@ } file instproc render_input {} { + util_createDom [list [my get_spec]] + } + + file instproc get_spec {} { my instvar value set package_id [[my object] package_id] array set entry_info [my entry_info $value] @@ -886,26 +890,35 @@ set reset_required 1 my set required false } - next + + lassign [next] tag atts children + if {[info exists reset_required]} { my set required true } - ::html::t " " - set id __old_value_[my name] - ::html::input -type hidden -name $id -id $id -value $value - #my msg "old_value '$value'" - ::html::span -class file-control -id __a$id { - ::html::a -href $href {::html::t [my label_or_value $fn] } - # Show the clear button just when - # - there is something to clear, and - # - the formfield is not disabled, and - # - the form-field is not sticky (default) - set disabled [expr {[my exists disabled] && [my disabled] ne "false"}] - if {$value ne "" && !$disabled && ![my sticky] } { - ::html::input -type button -value clear \ - -onClick "document.getElementById('$id').value = ''; document.getElementById('__a$id').style.display = 'none';" + + set additional_spec [util_tdom2list { + # FOLLOWING GIVES TROUBLE, SEE util_spec2json FOR DETAILS + ::html::t " " + set id __old_value_[my name] + ::html::input -type hidden -name $id -id $id -value $value + #my msg "old_value '$value'" + ::html::span -class file-control -id __a$id { + ::html::a -href $href {::html::t [my label_or_value $fn] } + # Show the clear button just when + # - there is something to clear, and + # - the formfield is not disabled, and + # - the form-field is not sticky (default) + set disabled [expr {[my exists disabled] && [my disabled] ne "false"}] + if {$value ne "" && !$disabled && ![my sticky] } { + ::html::input -type button -value clear \ + -onClick "document.getElementById('$id').value = ''; document.getElementById('__a$id').style.display = 'none';" + } } - } + }] + + lappend children $additional_spec + return [list $tag $atts $children] } ########################################################### @@ -3408,6 +3421,9 @@ # sample data: my set value "a b c" #my set value "a" + # Note that we have a spec parameter that refers to + # the form definition, and a get_spec proc that refers + # to the specification for generating html and json. set flyweight [::xowiki::formfield::$repeat_type new \ -name [my name] \ -locale [my locale] \ @@ -3418,6 +3434,7 @@ return [list $tag $atts $children] }] + set rep 0 foreach v [my value] { incr rep @@ -3455,6 +3472,7 @@ if { ![my disabled] } { $flyweight value "" set spec [$flyweight get_dom_spec] + #my log ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> [$flyweight info class] spec=$spec [$flyweight serialize] --- [my serialize]" html::a -spec $spec -href "#" -onclick "return wu.repeatable.addChoice(this);" { html::t "add another" } } } Index: openacs-4/packages/xowiki/tcl/xowiki-utility-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/xowiki-utility-procs.tcl,v diff -u -N -r1.20 -r1.21 --- openacs-4/packages/xowiki/tcl/xowiki-utility-procs.tcl 17 Aug 2012 08:00:21 -0000 1.20 +++ openacs-4/packages/xowiki/tcl/xowiki-utility-procs.tcl 21 Aug 2012 15:43:32 -0000 1.21 @@ -639,13 +639,26 @@ set cmdName [lindex $spec 0] lassign $spec cmdName atts inner_spec + + # We need to handle text nodes in a better way + # but our corresponding javascript function, + # i.e. wu.repeatable.createDom does not support it + # at the moment (August 2012) + if { $cmdName eq "\#text" } { continue } + set json "\{'tag':[util_jsquotevalue $cmdName]" if { $atts ne {} } { append json ",[util_map2json $atts]" } if { $inner_spec ne {} } { lassign [lindex $inner_spec 0] nodeType text - if { ${nodeType} eq "\#text" } { + # llength needs to go, please see comment above + # it would give us trouble if we have spec that starts with + # a text node but is then followed by element nodes, e.g. + # e.g. text node, element node 1, element node 2, and so on + # would give us trouble - we choose to ignore text nodes + # in this case + if { ${nodeType} eq "\#text" && [llength $inner_spec] == 1 } { # text node lassign [lindex $inner_spec 0] _nodeType_ text append json ",'html':[util_jsquotevalue $text]" @@ -660,4 +673,11 @@ return [join $result {,}] } +proc util_tdom2list {script {rootTag "div"}} { + set doc [dom createDocument $rootTag] + set root [$doc documentElement] + $root appendFromScript {uplevel $script} + return [$root asList] +} + ::xo::library source_dependent \ No newline at end of file