Login  Register

Re: Re: Generating table cells based on a "columns" attribute

Posted by Ethan Gruber on Oct 27, 2009; 6:11pm
URL: https://discuss.orbeon.com/Generating-table-cells-based-on-a-columns-attribute-tp277051p277282.html

Thanks, Alex

I understand the logic now, but there is probably something wrong with my syntax since it is still not working properly.  Here's a clip of what I have (current context is tgroup)
                       <div>
                            <xforms:trigger appearance="minimal">
                                <xforms:label>
                                    <img src="/apps/ead/images/add.gif"/>Add Table
                                    Header</xforms:label>

                             <!-- inserts row into thead: this works -->
                                <xforms:insert ev:event="DOMActivate" context="thead"
                                    origin="instance('row-template')"/>

                             <!-- loop from 1 to @cols to add an entries into the thead/row: does not work -->
                                <xforms:action
                                    xxforms:iterate="for $i in 1 to @cols return
                                    xxforms:element('dummy')">
                                    <xforms:insert context="thead/row" origin="instance('entry-template')"/>
                                </xforms:action>
                            </xforms:trigger>
                        </xforms:group>
                    </div>

                    <xforms:input ref="@cols">
                        <xforms:label>Columns</xforms:label>
                        <xforms:alert>Required</xforms:alert>
                        <xforms:hint>This must be an integer</xforms:hint>
                    </xforms:input>

                    <xforms:group ref="thead/row">
                        <div class="subsection">
                          <!-- this appears -->
                            <h4>Table Header</h4>
                            <xforms:trigger appearance="minimal">
                                <xforms:delete ev:event="DOMActivate" nodeset="."/>
                                <xforms:label>
                                    <img src="/apps/ead/images/remove.gif"/>
                                </xforms:label>
                            </xforms:trigger>

                            <!-- this does not appear -->
                            <xforms:repeat nodeset="entry">
                                <div>
                                    <xforms:input ref=".">
                                        <xforms:label>Cell</xforms:label>
                                    </xforms:input>
                                </div>
                            </xforms:repeat>
                        </div>
                    </xforms:group>

---

What exactly is xxforms:element('dummy')?  Why does something need to be returned?

Thanks,
Ethan

On Mon, Oct 26, 2009 at 9:58 PM, Alessandro Vernet <[hidden email]> wrote:
Ethan,

On Mon, Oct 26, 2009 at 11:40 AM, Ethan Gruber <[hidden email]> wrote:
> For example, I would like to create an "Add Row" trigger that inserts a
> <row> into <tbody>.  If I define @cols as 4, I'd like "Add Row" to insert
> <row><entry/><entry/><entry/><entry/></row>, with an input for each <entry/>

It looks like you need a way to execute an action a given number of
times. In pseudo-code, you could do something like:

<xforms:action xxforms:iterate="for $i in 1 to tgroup/@cols return
xxforms:element('dummy')">
   <xforms:insert context="row" origin="xxforms:element('entry')"/>
</xforms:action>

The 1 to tgroup/@cols returns a sequence of (1, 2, 3, 4) if you have 4
columns, and the xxforms:element() creates an element for each one, as
the context for XPath evaluation is expected to be a node.

Alex
--
Orbeon Forms - Web forms, open-source, for the Enterprise
Orbeon's Blog: http://www.orbeon.com/blog/
My Twitter: http://twitter.com/avernet


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws