You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Baptiste Placé <bp...@jouve.fr> on 2007/05/09 17:37:54 UTC

Enumerated datatype with selection lists.

Hi,

I want to use an enumerated type for the different options of my 
selection list. My problem is that the label of the options is always 
the full qualified name of the enum type.
My toString() function is not used :(
As indicated on the Datatypes part of CForms, I have the following code :

- Form definition :
<fd:field id="procedure_type" required="true">
        <fd:datatype base="enum">
            <fd:convertor type="enum">
                
<fd:enum>org.epoline.soprano.visualisation.customModel.Tyappli</fd:enum>
            </fd:convertor>
        </fd:datatype>
        <fd:selection-list type="enum" 
class="org.epoline.soprano.visualisation.customModel.Tyappli"/>
    </fd:field>

- Tyappli.class (simplified) :
public class Tyappli {

    public static final Tyappli NATIONAL = new Tyappli("National", new 
Short("1"));
    public static final Tyappli SPC = new Tyappli("Statistical Process 
Control", new Short("4"));

    private String descr;

    private Tyappli(String descr, Short dbInt) {
        this.descr = descr;
        this.dbShort = dbInt;
    }

    @Override
    public String toString() {
        return descr;
    }

    public static Tyappli fromString(String value) { ... }
}


I keep having this large selection list with e.g. 
org.epoline.soprano.visualisation.customModel.Tyappli.NATIONAL as option.
Any idea what am I missing for this to work ?

-Baptiste

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


Re: AW: Enumerated datatype with selection lists.

Posted by Grzegorz Kossakowski <gk...@apache.org>.
Baptiste Placé pisze:
> Hi Grzegorz,
> 
> The use of toString() / fromString() methods is actually suggested on 
> the cocoon daisy (like here : 
> http://cocoon.zones.apache.org/daisy/cdocs-forms/g1/forms/concepts/487.html). 
> The usual 2.1 documentation does not mention it.
> Anyway, I quickly found the part where the name is given in the 
> EnumSelectionList class and there is no trace of a declared toString() 
> lookup. Latest trunk of 2.2 does not have it either. So this is not a 
> bug :)
> I did not succeed in creating a patch, I may look again into it if I get 
> some time.
> Shall I open an issue in Cocoon JIRA ?

The document you mentioned talks about toString() method in context of use "enum" datatype and its convertor. To be honest, I have never 
used enum datatypes and I have no idea how enum selectionlist + enum convertor would work.

If you have found that documentation/code has a mistake/bug feel free to create an issue at any time.

-- 
Grzegorz Kossakowski
http://reflectingonthevicissitudes.wordpress.com/

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


Re: AW: Enumerated datatype with selection lists.

Posted by Baptiste Placé <bp...@jouve.fr>.
Hi Grzegorz,

The use of toString() / fromString() methods is actually suggested on 
the cocoon daisy (like here : 
http://cocoon.zones.apache.org/daisy/cdocs-forms/g1/forms/concepts/487.html). 
The usual 2.1 documentation does not mention it.
Anyway, I quickly found the part where the name is given in the 
EnumSelectionList class and there is no trace of a declared toString() 
lookup. Latest trunk of 2.2 does not have it either. So this is not a bug :)
I did not succeed in creating a patch, I may look again into it if I get 
some time.
Shall I open an issue in Cocoon JIRA ?

-Baptiste

Grzegorz Kossakowski a écrit :
> Baptiste Placé napisał(a):
>> Hi Franziska ,
>>
>> Thanks for the tip, it works quite well :)
>> Although a cleaner way with toString() method would be the best ^^
>
> I'm not sure if this issue is really a bug but if you think so create 
> an issue in our JIRA, please.
> If you submit a patch I'll be happy to commit it as soon as you 
> explain the issue in more detail and discuss back compatibility.
>
>



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


Re: AW: Enumerated datatype with selection lists.

Posted by Grzegorz Kossakowski <gk...@apache.org>.
Baptiste Placé napisał(a):
> Hi Franziska ,
> 
> Thanks for the tip, it works quite well :)
> Although a cleaner way with toString() method would be the best ^^

I'm not sure if this issue is really a bug but if you think so create an issue in our JIRA, please.
If you submit a patch I'll be happy to commit it as soon as you explain the issue in more detail and discuss back 
compatibility.


-- 
Grzegorz Kossakowski

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


Re: AW: Enumerated datatype with selection lists.

Posted by Baptiste Placé <bp...@jouve.fr>.
Hi Franziska ,

Thanks for the tip, it works quite well :)
Although a cleaner way with toString() method would be the best ^^

-Baptiste


Franziska Witzani a écrit :
> Hi Baptiste,
>
> Actually I don't have a solution for your problem, but a way around it. :)
> Try using the I18n-Transformer and supply the Strings to be displayed as I18n-messages (key is the full qualified name of your Enumeration-Elements).
>
> <message key="your.package.Tyappli.SPC">whatevermeansSPC</message>
>
> http://cocoon.apache.org/2.1/userdocs/i18nTransformer.html
>
> If anyone knows a cleaner way to do it, feel free to correct me!
>
>
> Greetings,
> Franzi
>
>
>
>   
>> -----Ursprüngliche Nachricht-----
>> Von: Baptiste Placé [mailto:bplace@jouve.fr]
>> Gesendet: Mittwoch, 9. Mai 2007 17:38
>> An: users@cocoon.apache.org
>> Betreff: Enumerated datatype with selection lists.
>>
>> Hi,
>>
>> I want to use an enumerated type for the different options of my
>> selection list. My problem is that the label of the options is always
>> the full qualified name of the enum type.
>> My toString() function is not used :(
>> As indicated on the Datatypes part of CForms, I have the following code :
>>
>> - Form definition :
>> <fd:field id="procedure_type" required="true">
>>         <fd:datatype base="enum">
>>             <fd:convertor type="enum">
>>
>> <fd:enum>org.epoline.soprano.visualisation.customModel.Tyappli</fd:enum>
>>             </fd:convertor>
>>         </fd:datatype>
>>         <fd:selection-list type="enum"
>> class="org.epoline.soprano.visualisation.customModel.Tyappli"/>
>>     </fd:field>
>>
>> - Tyappli.class (simplified) :
>> public class Tyappli {
>>
>>     public static final Tyappli NATIONAL = new Tyappli("National", new
>> Short("1"));
>>     public static final Tyappli SPC = new Tyappli("Statistical Process
>> Control", new Short("4"));
>>
>>     private String descr;
>>
>>     private Tyappli(String descr, Short dbInt) {
>>         this.descr = descr;
>>         this.dbShort = dbInt;
>>     }
>>
>>     @Override
>>     public String toString() {
>>         return descr;
>>     }
>>
>>     public static Tyappli fromString(String value) { ... }
>> }
>>
>>
>> I keep having this large selection list with e.g.
>> org.epoline.soprano.visualisation.customModel.Tyappli.NATIONAL as option.
>> Any idea what am I missing for this to work ?
>>
>> -Baptiste
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
>>     
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>   


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


AW: Enumerated datatype with selection lists.

Posted by Franziska Witzani <fr...@e-tecture.com>.
Hi Baptiste,

Actually I don't have a solution for your problem, but a way around it. :)
Try using the I18n-Transformer and supply the Strings to be displayed as I18n-messages (key is the full qualified name of your Enumeration-Elements).

<message key="your.package.Tyappli.SPC">whatevermeansSPC</message>

http://cocoon.apache.org/2.1/userdocs/i18nTransformer.html

If anyone knows a cleaner way to do it, feel free to correct me!


Greetings,
Franzi



> -----Ursprüngliche Nachricht-----
> Von: Baptiste Placé [mailto:bplace@jouve.fr]
> Gesendet: Mittwoch, 9. Mai 2007 17:38
> An: users@cocoon.apache.org
> Betreff: Enumerated datatype with selection lists.
> 
> Hi,
> 
> I want to use an enumerated type for the different options of my
> selection list. My problem is that the label of the options is always
> the full qualified name of the enum type.
> My toString() function is not used :(
> As indicated on the Datatypes part of CForms, I have the following code :
> 
> - Form definition :
> <fd:field id="procedure_type" required="true">
>         <fd:datatype base="enum">
>             <fd:convertor type="enum">
> 
> <fd:enum>org.epoline.soprano.visualisation.customModel.Tyappli</fd:enum>
>             </fd:convertor>
>         </fd:datatype>
>         <fd:selection-list type="enum"
> class="org.epoline.soprano.visualisation.customModel.Tyappli"/>
>     </fd:field>
> 
> - Tyappli.class (simplified) :
> public class Tyappli {
> 
>     public static final Tyappli NATIONAL = new Tyappli("National", new
> Short("1"));
>     public static final Tyappli SPC = new Tyappli("Statistical Process
> Control", new Short("4"));
> 
>     private String descr;
> 
>     private Tyappli(String descr, Short dbInt) {
>         this.descr = descr;
>         this.dbShort = dbInt;
>     }
> 
>     @Override
>     public String toString() {
>         return descr;
>     }
> 
>     public static Tyappli fromString(String value) { ... }
> }
> 
> 
> I keep having this large selection list with e.g.
> org.epoline.soprano.visualisation.customModel.Tyappli.NATIONAL as option.
> Any idea what am I missing for this to work ?
> 
> -Baptiste
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org


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