You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Simone Gianni <s....@thebug.it> on 2006/03/02 00:35:29 UTC
Forms enum selection list order
Hi team,
cocoon forms uses the common enumeration pattern for it's enum datatype
and selection list. The problem with the selection list is that the
order of the elements in it is not granted. Current implementation uses
the getDeclaredFields method, which states in its javadocs that " The
elements in the array returned are not sorted and are not in any
particular order".
Unfortunately, it's quite common for the customer to need elements in a
specific order. For example, in a payment options combo, they want to
see the various credit cards first, then other online payment methods,
then bank transactions etc.. And this is very critical for them, and
honestly quite horrible to see them mixed.
Actually, with sun JRE for windows and linux they appear in the right
order, but it's just a matter of implementation, since on other JREs
and/or platforms (and most notably, on IBM JREs, used by WebSphere) they
are in a random order.
There is no way to make them appear in the "right" order, but in a
project we had this issue and solved them using the apache commons
enums. In this enums, the enum fields are added to a list while they are
declared, and using this list instead of the getDeclaredFields gives
them in the declaration order also on other JRE implementations.
This also gives more control : by overriding the getList method of the
enum class, the developer can change the order directly from the enum
class, without involving front-end work and still maintaining a
selection list of type enum instead of a static unrolled selection list.
I developed an ApacheEnumSelectionList class and I'm ready to contribute
it, but i think it would be nicer to "merge" this code in the actual
EnumSelectionList, so that if the given enum is an apache enum, the
getList method is used instead of the getDeclaredFields method.
I can provide a patch shortly, WDYT?
Simone
--
Simone Gianni
Re: Forms enum selection list order
Posted by Antonio Gallardo <ag...@agssa.net>.
Simone Gianni wrote:
> Hi Ugo,
> yes, i checked that apache enums are in commons, so we already have
> that dependency. We should only add it to forms block dependencies in
> gump.xml (I think, tell me if there is something more to do for this).
You don't need to add the dependency in gump.xml. Cforms already depends
on commons-lang. :-)
Best Regards,
Antonio Gallardo.
>
> Simone
>
> Ugo Cei wrote:
>
>>
>> Il giorno 02/mar/06, alle ore 00:35, Simone Gianni ha scritto:
>>
>>> I developed an ApacheEnumSelectionList class and I'm ready to
>>> contribute it, but i think it would be nicer to "merge" this code
>>> in the actual EnumSelectionList, so that if the given enum is an
>>> apache enum, the getList method is used instead of the
>>> getDeclaredFields method.
>>
>>
>>
>> Jakarta Commons enum are already in commons-lang, right? If so, it's
>> a dependency we already have, so why not?
>>
>> Ugo
>>
>>
Re: Forms enum selection list order
Posted by Simone Gianni <s....@thebug.it>.
Hi Ugo,
yes, i checked that apache enums are in commons, so we already have that
dependency. We should only add it to forms block dependencies in
gump.xml (I think, tell me if there is something more to do for this).
Simone
Ugo Cei wrote:
>
> Il giorno 02/mar/06, alle ore 00:35, Simone Gianni ha scritto:
>
>> I developed an ApacheEnumSelectionList class and I'm ready to
>> contribute it, but i think it would be nicer to "merge" this code in
>> the actual EnumSelectionList, so that if the given enum is an apache
>> enum, the getList method is used instead of the getDeclaredFields
>> method.
>
>
> Jakarta Commons enum are already in commons-lang, right? If so, it's
> a dependency we already have, so why not?
>
> Ugo
>
>
--
Simone Gianni
Re: Forms enum selection list order
Posted by Ugo Cei <ug...@apache.org>.
Il giorno 02/mar/06, alle ore 00:35, Simone Gianni ha scritto:
> I developed an ApacheEnumSelectionList class and I'm ready to
> contribute it, but i think it would be nicer to "merge" this code
> in the actual EnumSelectionList, so that if the given enum is an
> apache enum, the getList method is used instead of the
> getDeclaredFields method.
Jakarta Commons enum are already in commons-lang, right? If so, it's
a dependency we already have, so why not?
Ugo
--
Ugo Cei
Blog: http://agylen.com/
Open Source Zone: http://oszone.org/
Evil or Not?: http://evilornot.info/
Company: http://www.sourcesense.com/