referencing inserted controls in a repeat by id (javascript:setValue)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

referencing inserted controls in a repeat by id (javascript:setValue)

Florian Schmitt-2
Hi,

is it possible to obtain the id of a newly inserted XForms control, so
to reference it with the JavaScript Function setValue?

The background for my question is that i need to insert new controls
into a xforms:repeat and to set their value by javascript. Triggering
the insertion is no problem, but because i don't know the ids of the
created controls i can't call setValue(). xforms:setValue doesn't help
because i didn't find a way to pass the data to be inserted; it seems to
work only by reference to another xforms control.

So i tried to insert a "dummy" control in my XForm that could be
referenced by setValue() (because its id is fixed) and also by
xforms:setvalue. The JavaScript would first call setValue on the dummy
and then dispatch an event to trigger an xforms:action that does the
xforms:insert and the xforms:setvalue using the dummy value. But this
works only if i insert and fill only one control. Calling setValue and
dispatchEvent more often makes trouble because the functions aren't
"synchronized" - the dummy may contain already the second or third value
when the first xforms:insert / xforms:setvalue gets executed.


Thanks in advance
florian




--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: referencing inserted controls in a repeat by id (javascript:setValue)

Alessandro Vernet
Administrator
Hi Florian,

You are right: setValue() and getValue() don't support controls in
repeats. We'll need to add this. I added an RFE for this:

http://forge.objectweb.org/tracker/index.php?func=detail&aid=306743&group_id=168&atid=350207

In the meantime, you need to know how the ids inside repeats are
built. If a control with id xyz is inside the 3rd iteration of a
repeat, its id will be "xyz.3". The character that I typed here as a
period is in fact a special character, which you can access through
the global variable XFORMS_SEPARATOR_1. In JavaScript, you would
write:

ORBEON.xforms.Document.setValue(myID + XFORMS_SEPARATOR_1 + "3", "myValue")

Alex

On 3/8/07, Florian Schmitt <[hidden email]> wrote:

> Hi,
>
> is it possible to obtain the id of a newly inserted XForms control, so
> to reference it with the JavaScript Function setValue?
>
> The background for my question is that i need to insert new controls
> into a xforms:repeat and to set their value by javascript. Triggering
> the insertion is no problem, but because i don't know the ids of the
> created controls i can't call setValue(). xforms:setValue doesn't help
> because i didn't find a way to pass the data to be inserted; it seems to
> work only by reference to another xforms control.
>
> So i tried to insert a "dummy" control in my XForm that could be
> referenced by setValue() (because its id is fixed) and also by
> xforms:setvalue. The JavaScript would first call setValue on the dummy
> and then dispatch an event to trigger an xforms:action that does the
> xforms:insert and the xforms:setvalue using the dummy value. But this
> works only if i insert and fill only one control. Calling setValue and
> dispatchEvent more often makes trouble because the functions aren't
> "synchronized" - the dummy may contain already the second or third value
> when the first xforms:insert / xforms:setvalue gets executed.
>
>
> Thanks in advance
> florian
>
>
>
>
> --
> 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
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
>
>

--
Orbeon Forms - Web 2.0 Forms for the Enterprise
http://www.orbeon.com/



--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: referencing inserted controls in a repeat by id (javascript:setValue)

Joseph Lawrence
In reply to this post by Florian Schmitt-2
Hi Florian,
    If you are inserting the new node to an xml referenced by xforms:repeat won't you be able to set the value using the index function on repeat? If you are keen in  setting up the value using xxforms:script, then please go through the 'case 3' of the sample test case I have created and attached with this mail. Here What I am  doing is, I insert a new node to the 'main' instance when 'Inserts a Node from template' is pressed. Now, on clicking, 'Set the value at a later stage' I use script to set the value of the selected repeat item.
    I am not sure whether this works for you. But just give a try.

Thanks
Joseph Lawrence
Stabilix Solutions

Florian Schmitt <[hidden email]> wrote:
Hi,

is it possible to obtain the id of a newly inserted XForms control, so
to reference it with the JavaScript Function setValue?

The background for my question is that i need to insert new controls
into a xforms:repeat and to set their value by javascript. Triggering
the insertion is no problem, but because i don't know the ids of the
created controls i can't call setValue(). xforms:setValue doesn't help
because i didn't find a way to pass the data to be inserted; it seems to
work only by reference to another xforms control.

So i tried to insert a "dummy" control in my XForm that could be
referenced by setValue() (because its id is fixed) and also by
xforms:setvalue. The JavaScript would first call setValue on the dummy
and then dispatch an event to trigger an xforms:action that does the
xforms:insert and the xforms:setvalue using the dummy value. But this
works only if i insert and fill only one control. Calling setValue and
dispatchEvent more often makes trouble because the functions aren't
"synchronized" - the dummy may contain already the second or third value
when the first xforms:insert / xforms:setvalue gets executed.


Thanks in advance
florian



--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws


Don't be flakey. Get Yahoo! Mail for Mobile and
always stay connected to friends.

--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws

repeat-insert-setvalue.xhtml (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: referencing inserted controls in a repeat by id (javascript:setValue)

Florian Schmitt-2
Hi Joseph,

>     If you are inserting the new node to an xml referenced by
> xforms:repeat won't you be able to set the value using the index
> function on repeat? If you are keen in  setting up the value using
> xxforms:script, then please go through the 'case 3' of the sample test
> case I have created and attached with this mail. Here What I am  doing
> is, I insert a new node to the 'main' instance when 'Inserts a Node from
> template' is pressed. Now, on clicking, 'Set the value at a later stage'
> I use script to set the value of the selected repeat item.
>     I am not sure whether this works for you. But just give a try.

thank you very much for the example - that's indeed a good solution to
set a repeat value at a later stage. But i fear i get in trouble again
if i try to set _mutiple_ values that way. It seems that the only way to
insert new repeat controls by javascript is to dispatch an event. But i
can't dispatch the data for the new controls in the same step, and i
don't know _when_ the dispatched inserts are executed/finished. Because
of that, it seems to be some sort of race condition where the repeat
index() would point to and which control would be affected by the
setValue command.


florian



--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws

smime.p7s (7K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: referencing inserted controls in a repeat by id (javascript:setValue)

Florian Schmitt-2
In reply to this post by Alessandro Vernet
Hi Alessandro,

> In the meantime, you need to know how the ids inside repeats are
> built. If a control with id xyz is inside the 3rd iteration of a
> repeat, its id will be "xyz.3". The character that I typed here as a
> period is in fact a special character, which you can access through
> the global variable XFORMS_SEPARATOR_1. In JavaScript, you would
> write:

> ORBEON.xforms.Document.setValue(myID + XFORMS_SEPARATOR_1 + "3", "myValue")

thanks a lot for this hint - i already noticed the special character in
the ids when inspecting the DOM of my xforms page, but didn't know how
to produce it.


florian




--
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
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws