You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Gabriel Gruber <Ga...@workflow.at> on 2007/10/09 08:28:05 UTC
Java for generating suggestion-list
Hello!
I was just wondering, if it is possible to use java instead of javascript
to generate a suggestion-list for a cforms widget. this java aims to query
a database (via hibernate) and should return a list of results.
something like this...
<fd:field id="person">
<fd:datatype base="string"/>
<fd:suggestion-list type="java"
src="com.mycompany.SuggestionListHandler"/>
</fd:field>
any ideas? from looking in the api i couldn't find a way for this to
work.
gabriel
______________________
Mag. Gabriel Gruber
Senior Consultant
mailto:gabriel.gruber@workflow.at
http://www.workflow.at
Re: Java for generating suggestion-list
Posted by David Legg <da...@searchevent.co.uk>.
In searching for information on how to use Java generated data as a
*suggestion* list in a CFORM multivaluefield I came across the 3 month
old email thread below.
I am interested in using this... did it get resolved?
Regards,
David Legg
Jeroen Reijn wrote:
> Ah.. I must have been still a sleep. I'll try to have a look today as
> well. The suggestion list has the ability for an attribute
> type='java', but the flowscript part I have no idea yet.
>
>
> Reijn
>
> Gabriel Gruber wrote:
>>
>> Hmm, thanx for your quick replies.
>>
>> however you are referring to the "selection-list" while I would like
>> to use the new "suggestion-list".
>> an example is provided within the latest cocoon cforms samples, but
>> the suggestion-list is created via javascript (which is very hard to
>> debug). so my question is: is there a way to do that in java?
>>
>> <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)).startsWith(string2);
>> }
>> 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>
>>
>> thanx for you help
>>
>> gabriel
>>
>>
>> Gabriel Gruber wrote:
>> >
>> > Hello!
>> >
>> > I was just wondering, if it is possible to use java instead of
>> > javascript to generate a suggestion-list for a cforms widget. this
>> java
>> > aims to query a database (via hibernate) and should return a list of
>> > results.
>> >
>> > something like this...
>> > <fd:field id="person">
>> > <fd:datatype base="string"/>
>> > <fd:suggestion-list type="java"
>> > src="com.mycompany.SuggestionListHandler"/>
>> > </fd:field>
>> >
>> > any ideas? from looking in the api i couldn't find a way for this
>> to work.
>> >
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Java for generating suggestion-list
Posted by Jeroen Reijn <j....@hippo.nl>.
Ah.. I must have been still a sleep. I'll try to have a look today as
well. The suggestion list has the ability for an attribute type='java',
but the flowscript part I have no idea yet.
Reijn
Gabriel Gruber wrote:
>
> Hmm, thanx for your quick replies.
>
> however you are referring to the "selection-list" while I would like to
> use the new "suggestion-list".
> an example is provided within the latest cocoon cforms samples, but the
> suggestion-list is created via javascript (which is very hard to debug).
> so my question is: is there a way to do that in java?
>
> <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)).startsWith(string2);
> }
>
> 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>
>
> thanx for you help
>
> gabriel
>
>
> ______________________
> Mag. Gabriel Gruber
> Senior Consultant
> http://www.workflow.at
>
>
>
> *Jeroen Reijn <j....@hippo.nl>*
>
> 09.10.2007 09:10
> Please respond to
> users@cocoon.apache.org
>
>
>
> To
> users@cocoon.apache.org
> cc
>
> Subject
> Re: Java for generating suggestion-list
>
>
>
>
>
>
>
>
> Hi Garbriel,
>
> It is possible to create a Java selection list. In the forms block
> samples a Java selection list is used for the second selection list of
> birthdays.
>
> http://cocoon.zones.apache.org/demos/release/samples/blocks/forms/form1
>
> Kind regards,
>
> Jeroen Reijn
>
> Gabriel Gruber wrote:
> >
> > Hello!
> >
> > I was just wondering, if it is possible to use java instead of
> > javascript to generate a suggestion-list for a cforms widget. this java
> > aims to query a database (via hibernate) and should return a list of
> > results.
> >
> > something like this...
> > <fd:field id="person">
> > <fd:datatype base="string"/>
> > <fd:suggestion-list type="java"
> > src="com.mycompany.SuggestionListHandler"/>
> > </fd:field>
> >
> > any ideas? from looking in the api i couldn't find a way for this to
> work.
> >
> > gabriel
> > ______________________
> > Mag. Gabriel Gruber
> > Senior Consultant
> > mailto:gabriel.gruber@workflow.at
> > http://www.workflow.at
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
--
Met vriendelijke groet,
Kind regards,
Jeroen Reijn
Hippo
Oosteinde 11
1017WT Amsterdam
The Netherlands
Tel +31 (0)20 5224466
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Java for generating suggestion-list
Posted by Gabriel Gruber <Ga...@workflow.at>.
Hmm, thanx for your quick replies.
however you are referring to the "selection-list" while I would like to
use the new "suggestion-list".
an example is provided within the latest cocoon cforms samples, but the
suggestion-list is created via javascript (which is very hard to debug).
so my question is: is there a way to do that in java?
<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)).startsWith(string2);
}
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>
thanx for you help
gabriel
______________________
Mag. Gabriel Gruber
Senior Consultant
http://www.workflow.at
Jeroen Reijn <j....@hippo.nl>
09.10.2007 09:10
Please respond to
users@cocoon.apache.org
To
users@cocoon.apache.org
cc
Subject
Re: Java for generating suggestion-list
Hi Garbriel,
It is possible to create a Java selection list. In the forms block
samples a Java selection list is used for the second selection list of
birthdays.
http://cocoon.zones.apache.org/demos/release/samples/blocks/forms/form1
Kind regards,
Jeroen Reijn
Gabriel Gruber wrote:
>
> Hello!
>
> I was just wondering, if it is possible to use java instead of
> javascript to generate a suggestion-list for a cforms widget. this java
> aims to query a database (via hibernate) and should return a list of
> results.
>
> something like this...
> <fd:field id="person">
> <fd:datatype base="string"/>
> <fd:suggestion-list type="java"
> src="com.mycompany.SuggestionListHandler"/>
> </fd:field>
>
> any ideas? from looking in the api i couldn't find a way for this to
work.
>
> gabriel
> ______________________
> Mag. Gabriel Gruber
> Senior Consultant
> mailto:gabriel.gruber@workflow.at
> http://www.workflow.at
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Java for generating suggestion-list
Posted by Jeroen Reijn <j....@hippo.nl>.
Hi Garbriel,
It is possible to create a Java selection list. In the forms block
samples a Java selection list is used for the second selection list of
birthdays.
http://cocoon.zones.apache.org/demos/release/samples/blocks/forms/form1
Kind regards,
Jeroen Reijn
Gabriel Gruber wrote:
>
> Hello!
>
> I was just wondering, if it is possible to use java instead of
> javascript to generate a suggestion-list for a cforms widget. this java
> aims to query a database (via hibernate) and should return a list of
> results.
>
> something like this...
> <fd:field id="person">
> <fd:datatype base="string"/>
> <fd:suggestion-list type="java"
> src="com.mycompany.SuggestionListHandler"/>
> </fd:field>
>
> any ideas? from looking in the api i couldn't find a way for this to work.
>
> gabriel
> ______________________
> Mag. Gabriel Gruber
> Senior Consultant
> mailto:gabriel.gruber@workflow.at
> http://www.workflow.at
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org