cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Chávez, Carlos" <ccha...@agssa.net>
Subject Re: CForms suggestion-list: setting value
Date Thu, 15 Jul 2010 14:48:20 GMT
On Miércoles, 14 de Julio de 2010 3:44:08 AM Barbara Slupik wrote:

Hi Barbara.
It is working for me.
If possible try to update from the svn.

--
Cheers.
Carlos Chávez.

> Hello
> 
> How to set a value on a suggestion-list?
> 
> I am using cocoon-2.1.11 with Firefox 3.6.6.
> 
> The cocoon sample listed below does not seem to work. I think that it
> should display the suggestion list set to "Bruno Dumon" but it
> displays the list with no initial value. You have to start typing to
> get suggestions or press the arrow to get a drop down with all elements.
> 
> The sample:
> 
>    <fd:field id="personId">
>        <fd:datatype base="integer"/>
>        <fd:initial-value>16</fd:initial-value>
>        <fd:suggestion-list type="javascript">
>        <![CDATA[
>          function addSuggestion(bean) {
>              suggestions.push({value: bean.value, label: bean.label});
>          }
> 
>          function personList() {
>            return [
>                    {value: 1, label: "Donald Ball"},
>                    {value: 2, label: "Sylvain Wallez"},
>                    {value: 3, label: "Carsten Ziegeler"},
>                    {value: 4, label: "Torsten Curdt"},
>                    {value: 5, label: "Marcus Crafter"},
>                    {value: 6, label: "Ovidiu Predescu"},
>                    {value: 7, label: "Christian Haul"},
>                    {value: 8, label: "Jeremy Quinn"},
>                    {value: 9, label: "Stefano Mazzocchi"},
>                    {value: 10, label: "Pierpaolo Fumagalli"},
>                    {value: 11, label: "Davanum Srinivas"},
>                    {value: 12, label: "Antonio Gallardo"},
>                    {value: 13, label: "Ugo Cei"},
>                    {value: 14, label: "David Crossley"},
>                    {value: 15, label: "Bertrand Delacrétaz"},
>                    {value: 16, label: "Bruno Dumon"},
>                    {value: 17, label: "Daniel Fagerstrom"},
>                    {value: 18, label: "Leszek Gawron"},
>                    {value: 19, label: "Ralph Goers"},
>                    {value: 20, label: "Vadim Gritsenko"},
>                    {value: 21, label: "Jorg Heymans"},
>                    {value: 22, label: "Jörg Heinicke"},
>                    {value: 23, label: "Jean-Baptiste Quenot"}
>                  ];
>          }
> 
>          function startsWith(string1, string2) {
>            return (new
> java
> .lang.String(string1.toLowerCase())).startsWith(string2.toLowerCase());
>          }
> 
>          function searchByString() {
>            for (var i = 0; i < list.length; i++) {
>              if (startsWith(list[i].label, filter)) {
>                addSuggestion(list[i]);
>              }
>            }
>          }
> 
>          function searchById() {
>            for (var i = 0; i < list.length; i++) {
>              if (list[i].value == parseInt(filter)) {
>                addSuggestion(list[i]);
>              }
>            }
>          }
> 
>          var suggestions = [];
>          var list = personList();
>          if (filter) {
>            var phase = cocoon.request.getParameter("phase");
>            if (phase && phase.equals("init")) {
>              if (!isNaN(parseInt(filter))) {
>                searchById();
>              } else {
>                cocoon.log.error("The filter: '" + filter + "' must be
> a number.");
>              }
>            } else {
>              searchByString();
>            }
>          } else {
>            suggestions = list;
>          }
>          return suggestions;
>        ]]>
>        </fd:suggestion-list>
>      </fd:field>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org

-- 
Saludos.
Carlos Chávez.

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


Mime
View raw message