cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruno Dumon <br...@outerthought.org>
Subject Re: Integer formatting [was Re: Woody convertors: date formatting & decimal formatting]
Date Tue, 27 Jul 2004 08:34:39 GMT
On Tue, 2004-07-27 at 10:17, Derek Hohls wrote:
> Bruno
> 
> Well, not quite impossible ;-)  Here is the code I have been
> using to test this problem away from "my" app.
> 
> In samples\blocks\forms\forms, I changed:
> form2_model.xml to add the widget:
> 
>     <fd:field id="bignumber" required="true">
>       <fd:label>Type a really big number:</fd:label>
>       <fd:datatype base="integer">
>         <fd:convertor type="plain"/>
>       </fd:datatype>
>     </fd:field>  
>     
> In the form2_data.xml, I added:
> 
>   <bignumber value="3456789"/>    
>   
> In the form2_bind_xml.xml, I added:
> 
>     <fb:value id="bignumber" path="bignumber/@value">
>       <fd:convertor datatype="integer"/>
>     </fb:value> 
>     
> In the form2_template_action.xml, I added:
> 
>         <tr>
>           <td valign="top"><ft:widget-label id="bignumber"/></td>
>           <td valign="top"><ft:widget id="bignumber"/></td>
>         </tr>
> 
> And in the output XML file (after form submission), I now get:
> 
> <bignumber value="3,456,789" /> 
> 
> 
> Please try this and see if you can reproduce the problem too?!

I don't even need to.

In your form you have a field holding a java.lang.Integer object. XML
can only contain text (strings), so this object needs to be converted to
a string. Since it is the binding which takes the value from the form
and puts it in the XML, it is the binding which performs this
conversion, and in order to do so, it uses the convertor specified in
the binding.

In your binding you have:

>     <fb:value id="bignumber" path="bignumber/@value">
>       <fd:convertor datatype="integer"/>
>     </fb:value> 

Properly configuring that binding should solve it. For instance, for
what you want to achieve, you can do:

>     <fb:value id="bignumber" path="bignumber/@value">
>       <fd:convertor datatype="integer" type="plain"/>
>     </fb:value> 

Hope this makes it clear.

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


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


Mime
View raw message