cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Derek Hohls" <dho...@csir.co.za>
Subject Re: Integer formatting
Date Tue, 08 Nov 2005 06:11:32 GMT
Bruce
 
I struggled some time back with getting years displayed as YYYY
format and not YYYY.0 - in the end I used:
 
<fd:convertor datatype="integer" type="plain"/>
 
to get what I needed.  This syntax seems a little different from
what you are using - maybe it will help?
 
Derek

>>> bruce@callenish.com 2005/11/08 03:04:56 AM >>>
I have what I consider very odd behaviour in my forms. Specifically, 
javascript variables are being rendered as floats rather than integers 
in the HTML, but only if I tell the forms to render them as plain integers.

So if I have the following flowscript:

formData.queueList = [
{value: 1, label:"1"},
{value: 2, label:"2"},
{value: 3, label:"3"}
];

with a form definition that looks something like this:

<fd:field id="queue" >
<fd:label><i18n:text>Select Queue #</i18n:text></fd:label>
<fd:datatype base="integer" />
<fd:selection-list type="flow-jxpath" list-path="queueList" 
value-path="value" label-path="label" />
</fd:field>

things work great. But if I change the definition file to:

<fd:field id="queue" >
<fd:label><i18n:text>Select Queue #</i18n:text></fd:label>
<fd:datatype base="integer" >
<fd:convertor type="plain" variant="integer" />
</fd:datatype>
<fd:selection-list type="flow-jxpath" list-path="queueList" 
value-path="value" label-path="label" />
</fd:field>

what comes out in the HTML is:

<select class="repeater-form-widget" id="queueList.0.instance" name="queueList.0.instance">
<option value="1.0" selected="true">1</option>
<option value="2.0" selected="true">2</option>
etc...

Note the floating point value. When submitting the form, the dropdown 
ends up with an exclamation point beside it because it doesn't pass 
validation, 1.0 not being an integer value.

I can fix the problem by using Java types rather than the javascript 
variables in the flow. So this renders as integers in the HTML rather 
than floats:

formData.queueList = [
{value: new Integer(1), label:"1"},
{value: new Integer(2), label:"2"},
{value: new Integer(3), label:"3"}
];

but it strikes me as a weird behaviour.

Is this expected, or is it a bug? What is the recommended implementation 
for this?

P.S. I know that I don't need a convertor in this particular case, but 
I am trying to be consistent in how integers are handled and I don't 
want commas in integers under any circumstances. There are lots of other 
places where my integers can go over four digits.


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




-- 
This message is subject to the CSIR's copyright, terms and conditions and
e-mail legal notice. Views expressed herein do not necessarily represent the
views of the CSIR.
 
CSIR E-mail Legal Notice
http://mail.csir.co.za/CSIR_eMail_Legal_Notice.html 
 
CSIR Copyright, Terms and Conditions
http://mail.csir.co.za/CSIR_Copyright.html 
 
For electronic copies of the CSIR Copyright, Terms and Conditions and the CSIR
Legal Notice send a blank message with REQUEST LEGAL in the subject line to
HelpDesk@csir.co.za.


This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their support.


Mime
View raw message