You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Nacho Jimenez <na...@ya.com> on 2004/04/14 20:18:23 UTC

Trying to get a selectionlist label into a binding

Hello all,
   
    I've got a (woody) form with lots of widgets. One of them is a 
selection list that let's you choose a user, with the full name as label 
and the login name as value of the selection list.
   
    I'm binding the form into an xml file, and would like to bind this 
information to:
   
    <user id="natz">Nacho Jimenez de Luis</user>

    The only idea that springs to my mind is to use a <wb:javascript> 
bindng and on the on-save option, access the widget directly, but i 
don't know wehre to get the selection's label from, not the widget's label.

    I'm out of ideas here, can someone point the right way?

    Thanks,
       Nacho Jimenez

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Trying to get a selectionlist label into a binding

Posted by Nacho Jimenez <na...@ya.com>.
Joerg Heinicke wrote:

> On 16.04.2004 16:46, Nacho Jimenez wrote:
>
> The selection list is another dimension of a field and no value in the 
> closer sense. So it's normally not bound to the field. The value of 
> this field is only the selected value at the end.
>
> So the normal way is setting the selection list via
> <wd:selection-list src="cocoon:/users"/>
> which calls another pipeline. In this pipeline you transform your 
> custom XML to the wd:item syntax.
>
> As already said you already bound the selected value of the field. And 
> this happens via a standard
> <wb:value id="user" path="where-ever-you-want-to-store-it"/>
>
> Is this what you want?
>
> Joerg


    It seems I'm not explaining the problem clearly.. Sorry.  Let's see 
if I can make myself clear this third time using a simple example...

    I've already populated my field widget with a list of elements, and 
I can do the normal binding like you are proposing.. the thing is, i 
want to bind BOTH the selected value and the selected label into the 
destination XML.. 

    For Example: Imagine you have a list of countries in your form, so 
the user can choose his address... In the form, the countries appear as 
a selection list with the names of the countries (say "Germany", 
"Spain", "United Kingdom", and so on), and their country code as value 
("de", "es", "uk"..) .

    I have  populated the list, and i  have binded  the value as 
"<country id='es'/>", but what I want is to bind it as "<country 
id='es'>Spain</country>". As there's no an out-of-the-box binding 
command that gives me the selection list selected value's label, I have 
to use the javascript binding command, and access the widget object, but 
I do not know where in that object is that stored..

    I hope you understand now...

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Trying to get a selectionlist label into a binding

Posted by la...@marinepower.com.
Perhaps an idea can be to create a value that is composed from the label 
and the value then parse it in the binding action

Laurent

Re: Trying to get a selectionlist label into a binding

Posted by Joerg Heinicke <jo...@gmx.de>.
On 16.04.2004 16:46, Nacho Jimenez wrote:

>> To clear up the picture:
>>
>> You have a form defined with a field widget and a selection list.
>>
>> You want to fill the selection list with an XML.
> 
> 
> No, that's easy and I already have taken care of it..
> 
> Right now my field widget is already a selection list populated with a 
> list of users... (sttatic version, for sake of simplicity)
> 
>        <wd:field id="user" required="true">
>            <wd:label>Usuario</wd:label>
>            <wd:datatype base="string"/>
>            <wd:selection-list>
>              <wd:item value="natz">
>                <wd:label>Nacho Jimenez</wd:label>
>              </wd:item>
>               <!-- etc -->
>              <wd:item value="otro">
>                <wd:label>Otro Distinto</wd:label>
>              </wd:item>
>            </wd:selection-list>
>        </wd:field>
> 
> What i need is to store the selection in an XML as:
> 
>    <user id="natz">Nacho Jimenez</user>
> 
>    The first binding is simple:
> 
>      <wb:value id="user" path="user/@id"/>
> 
>    But I just don't know how to do the second.. I guess it could be 
> something like:
>      <wb:javascript id="user" path="user" direction="save">
>         <wb:save-form>
>             widget.function.that.gets.the.selection's.label()
>        </wb:save-form>
>    </wb:javascript>
> 
>    Any idea?

The selection list is another dimension of a field and no value in the 
closer sense. So it's normally not bound to the field. The value of this 
field is only the selected value at the end.

So the normal way is setting the selection list via
<wd:selection-list src="cocoon:/users"/>
which calls another pipeline. In this pipeline you transform your custom 
XML to the wd:item syntax.

As already said you already bound the selected value of the field. And 
this happens via a standard
<wb:value id="user" path="where-ever-you-want-to-store-it"/>

Is this what you want?

Joerg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Trying to get a selectionlist label into a binding

Posted by Nacho Jimenez <na...@ya.com>.
Joerg Heinicke wrote:

> On 14.04.2004 20:18, Nacho Jimenez wrote:
>
>> Hello all,
>>      I've got a (woody) form with lots of widgets. One of them is a 
>> selection list that let's you choose a user, with the full name as 
>> label and the login name as value of the selection list.
>>      I'm binding the form into an xml file, and would like to bind 
>> this information to:
>>      <user id="natz">Nacho Jimenez de Luis</user>
>>
>>    The only idea that springs to my mind is to use a <wb:javascript> 
>> bindng and on the on-save option, access the widget directly, but i 
>> don't know wehre to get the selection's label from, not the widget's 
>> label.
>>
>>    I'm out of ideas here, can someone point the right way?
>
>
> To clear up the picture:
>
> You have a form defined with a field widget and a selection list.
>
> You want to fill the selection list with an XML.

No, that's easy and I already have taken care of it..

Right now my field widget is already a selection list populated with a 
list of users... (sttatic version, for sake of simplicity)

        <wd:field id="user" required="true">
            <wd:label>Usuario</wd:label>
            <wd:datatype base="string"/>
            <wd:selection-list>
              <wd:item value="natz">
                <wd:label>Nacho Jimenez</wd:label>
              </wd:item>
               <!-- etc -->
              <wd:item value="otro">
                <wd:label>Otro Distinto</wd:label>
              </wd:item>
            </wd:selection-list>
        </wd:field>

What i need is to store the selection in an XML as:

    <user id="natz">Nacho Jimenez</user>

    The first binding is simple:

      <wb:value id="user" path="user/@id"/>

    But I just don't know how to do the second.. I guess it could be 
something like:
   
    <wb:javascript id="user" path="user" direction="save">
         <wb:save-form>
             widget.function.that.gets.the.selection's.label()
        </wb:save-form>
    </wb:javascript>

    Any idea?

> Another question is where you want to store the value at the end.
>
> And if you still want to do it via binding, like I did it, but with 
> beans and not for XML, have a look at 
> http://wiki.cocoondev.org/Wiki.jsp?page=WoodyBinding and search for 
> wb:javascript there.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Trying to get a selectionlist label into a binding

Posted by Joerg Heinicke <jo...@gmx.de>.
On 14.04.2004 20:18, Nacho Jimenez wrote:

> Hello all,
>      I've got a (woody) form with lots of widgets. One of them is a 
> selection list that let's you choose a user, with the full name as label 
> and the login name as value of the selection list.
>      I'm binding the form into an xml file, and would like to bind this 
> information to:
>      <user id="natz">Nacho Jimenez de Luis</user>
> 
>    The only idea that springs to my mind is to use a <wb:javascript> 
> bindng and on the on-save option, access the widget directly, but i 
> don't know wehre to get the selection's label from, not the widget's label.
> 
>    I'm out of ideas here, can someone point the right way?

To clear up the picture:

You have a form defined with a field widget and a selection list.

You want to fill the selection list with an XML.

Now the questions: Is it necessary to fill the selection list from the 
binding? There are other possibilities, e.g. 
http://cvs.apache.org/viewcvs.cgi/cocoon-2.1/src/blocks/forms/samples/forms/form1.xml?annotate=1.3#64 
for doing it with a static XML file or
http://cvs.apache.org/viewcvs.cgi/cocoon-2.1/src/blocks/forms/samples/forms/carselector_form.xml?annotate=1.2#26
for doing it with a dynamic file.

Another question is where you want to store the value at the end.

And if you still want to do it via binding, like I did it, but with 
beans and not for XML, have a look at 
http://wiki.cocoondev.org/Wiki.jsp?page=WoodyBinding and search for 
wb:javascript there.

Joerg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org