You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Vjeran Marcinko (JIRA)" <ta...@jakarta.apache.org> on 2005/12/22 09:20:30 UTC
[jira] Created: (TAPESTRY-817) Translator for BigDecimal values
Translator for BigDecimal values
--------------------------------
Key: TAPESTRY-817
URL: http://issues.apache.org/jira/browse/TAPESTRY-817
Project: Tapestry
Type: New Feature
Versions: 4.0
Reporter: Vjeran Marcinko
Tapestry currently lacks Translator for BigDecimal values. NumberTranslator is no good since it uses DecimalFormat underneath which converts String value into Double object, which then cannot accurately be converted to BigDecimal by it's very nature.
Solution is to introduce new BigDecimalTranslator, something like :
import org.apache.hivemind.ApplicationRuntimeException;
import org.apache.tapestry.form.IFormComponent;
import org.apache.tapestry.form.ValidationMessages;
import org.apache.tapestry.form.translator.AbstractTranslator;
import org.apache.tapestry.valid.ValidationConstraint;
import org.apache.tapestry.valid.ValidationStrings;
import org.apache.tapestry.valid.ValidatorException;
import java.math.BigDecimal;
import java.util.Locale;
public class BigDecimalTranslator extends AbstractTranslator {
public BigDecimalTranslator() {
}
// Needed until HIVEMIND-134 fix is available
public BigDecimalTranslator(String initializer) {
super(initializer);
}
protected String formatObject(IFormComponent field, Locale locale, Object object) {
if (!(object instanceof BigDecimal)) {
throw new ApplicationRuntimeException("BigDecimalTranslator translates values of type BigDecimal, not: " + object.getClass());
}
return object.toString();
}
protected Object parseText(IFormComponent field, ValidationMessages messages, String text) throws ValidatorException {
try {
return new BigDecimal(text);
} catch (NumberFormatException e) {
throw new ValidatorException(buildMessage(messages, field, ValidationStrings.INVALID_NUMBER), ValidationConstraint.NUMBER_FORMAT);
}
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
[jira] Resolved: (TAPESTRY-817) Translator for BigDecimal values
Posted by "Jesse Kuhnert (JIRA)" <de...@tapestry.apache.org>.
[ https://issues.apache.org/jira/browse/TAPESTRY-817?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jesse Kuhnert resolved TAPESTRY-817.
------------------------------------
Resolution: Fixed
Assignee: Jesse Kuhnert (was: Andreas Andreou)
> Translator for BigDecimal values
> --------------------------------
>
> Key: TAPESTRY-817
> URL: https://issues.apache.org/jira/browse/TAPESTRY-817
> Project: Tapestry
> Issue Type: New Feature
> Components: Framework
> Affects Versions: 4.0
> Reporter: Vjeran Marcinko
> Assigned To: Jesse Kuhnert
> Fix For: 4.1.2
>
>
> Tapestry currently lacks Translator for BigDecimal values. NumberTranslator is no good since it uses DecimalFormat underneath which converts String value into Double object, which then cannot accurately be converted to BigDecimal by it's very nature.
> Solution is to introduce new BigDecimalTranslator, something like :
> import org.apache.hivemind.ApplicationRuntimeException;
> import org.apache.tapestry.form.IFormComponent;
> import org.apache.tapestry.form.ValidationMessages;
> import org.apache.tapestry.form.translator.AbstractTranslator;
> import org.apache.tapestry.valid.ValidationConstraint;
> import org.apache.tapestry.valid.ValidationStrings;
> import org.apache.tapestry.valid.ValidatorException;
> import java.math.BigDecimal;
> import java.util.Locale;
> public class BigDecimalTranslator extends AbstractTranslator {
> public BigDecimalTranslator() {
> }
> // Needed until HIVEMIND-134 fix is available
> public BigDecimalTranslator(String initializer) {
> super(initializer);
> }
> protected String formatObject(IFormComponent field, Locale locale, Object object) {
> if (!(object instanceof BigDecimal)) {
> throw new ApplicationRuntimeException("BigDecimalTranslator translates values of type BigDecimal, not: " + object.getClass());
> }
> return object.toString();
> }
> protected Object parseText(IFormComponent field, ValidationMessages messages, String text) throws ValidatorException {
> try {
> return new BigDecimal(text);
> } catch (NumberFormatException e) {
> throw new ValidatorException(buildMessage(messages, field, ValidationStrings.INVALID_NUMBER), ValidationConstraint.NUMBER_FORMAT);
> }
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org
[jira] Updated: (TAPESTRY-817) Translator for BigDecimal values
Posted by "Brian K. Wallace (JIRA)" <ta...@jakarta.apache.org>.
[ http://issues.apache.org/jira/browse/TAPESTRY-817?page=all ]
Brian K. Wallace updated TAPESTRY-817:
--------------------------------------
Component: Framework
> Translator for BigDecimal values
> --------------------------------
>
> Key: TAPESTRY-817
> URL: http://issues.apache.org/jira/browse/TAPESTRY-817
> Project: Tapestry
> Type: New Feature
> Components: Framework
> Versions: 4.0
> Reporter: Vjeran Marcinko
>
> Tapestry currently lacks Translator for BigDecimal values. NumberTranslator is no good since it uses DecimalFormat underneath which converts String value into Double object, which then cannot accurately be converted to BigDecimal by it's very nature.
> Solution is to introduce new BigDecimalTranslator, something like :
> import org.apache.hivemind.ApplicationRuntimeException;
> import org.apache.tapestry.form.IFormComponent;
> import org.apache.tapestry.form.ValidationMessages;
> import org.apache.tapestry.form.translator.AbstractTranslator;
> import org.apache.tapestry.valid.ValidationConstraint;
> import org.apache.tapestry.valid.ValidationStrings;
> import org.apache.tapestry.valid.ValidatorException;
> import java.math.BigDecimal;
> import java.util.Locale;
> public class BigDecimalTranslator extends AbstractTranslator {
> public BigDecimalTranslator() {
> }
> // Needed until HIVEMIND-134 fix is available
> public BigDecimalTranslator(String initializer) {
> super(initializer);
> }
> protected String formatObject(IFormComponent field, Locale locale, Object object) {
> if (!(object instanceof BigDecimal)) {
> throw new ApplicationRuntimeException("BigDecimalTranslator translates values of type BigDecimal, not: " + object.getClass());
> }
> return object.toString();
> }
> protected Object parseText(IFormComponent field, ValidationMessages messages, String text) throws ValidatorException {
> try {
> return new BigDecimal(text);
> } catch (NumberFormatException e) {
> throw new ValidatorException(buildMessage(messages, field, ValidationStrings.INVALID_NUMBER), ValidationConstraint.NUMBER_FORMAT);
> }
> }
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org
[jira] Assigned: (TAPESTRY-817) Translator for BigDecimal values
Posted by "Andreas Andreou (JIRA)" <ta...@jakarta.apache.org>.
[ http://issues.apache.org/jira/browse/TAPESTRY-817?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andreas Andreou reassigned TAPESTRY-817:
----------------------------------------
Assignee: Andreas Andreou
> Translator for BigDecimal values
> --------------------------------
>
> Key: TAPESTRY-817
> URL: http://issues.apache.org/jira/browse/TAPESTRY-817
> Project: Tapestry
> Issue Type: New Feature
> Components: Framework
> Affects Versions: 4.0
> Reporter: Vjeran Marcinko
> Assigned To: Andreas Andreou
> Fix For: 4.1.2
>
>
> Tapestry currently lacks Translator for BigDecimal values. NumberTranslator is no good since it uses DecimalFormat underneath which converts String value into Double object, which then cannot accurately be converted to BigDecimal by it's very nature.
> Solution is to introduce new BigDecimalTranslator, something like :
> import org.apache.hivemind.ApplicationRuntimeException;
> import org.apache.tapestry.form.IFormComponent;
> import org.apache.tapestry.form.ValidationMessages;
> import org.apache.tapestry.form.translator.AbstractTranslator;
> import org.apache.tapestry.valid.ValidationConstraint;
> import org.apache.tapestry.valid.ValidationStrings;
> import org.apache.tapestry.valid.ValidatorException;
> import java.math.BigDecimal;
> import java.util.Locale;
> public class BigDecimalTranslator extends AbstractTranslator {
> public BigDecimalTranslator() {
> }
> // Needed until HIVEMIND-134 fix is available
> public BigDecimalTranslator(String initializer) {
> super(initializer);
> }
> protected String formatObject(IFormComponent field, Locale locale, Object object) {
> if (!(object instanceof BigDecimal)) {
> throw new ApplicationRuntimeException("BigDecimalTranslator translates values of type BigDecimal, not: " + object.getClass());
> }
> return object.toString();
> }
> protected Object parseText(IFormComponent field, ValidationMessages messages, String text) throws ValidatorException {
> try {
> return new BigDecimal(text);
> } catch (NumberFormatException e) {
> throw new ValidatorException(buildMessage(messages, field, ValidationStrings.INVALID_NUMBER), ValidationConstraint.NUMBER_FORMAT);
> }
> }
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org
[jira] Updated: (TAPESTRY-817) Translator for BigDecimal values
Posted by "Jesse Kuhnert (JIRA)" <ta...@jakarta.apache.org>.
[ http://issues.apache.org/jira/browse/TAPESTRY-817?page=all ]
Jesse Kuhnert updated TAPESTRY-817:
-----------------------------------
Fix Version/s: 4.1.2
> Translator for BigDecimal values
> --------------------------------
>
> Key: TAPESTRY-817
> URL: http://issues.apache.org/jira/browse/TAPESTRY-817
> Project: Tapestry
> Issue Type: New Feature
> Components: Framework
> Affects Versions: 4.0
> Reporter: Vjeran Marcinko
> Fix For: 4.1.2
>
>
> Tapestry currently lacks Translator for BigDecimal values. NumberTranslator is no good since it uses DecimalFormat underneath which converts String value into Double object, which then cannot accurately be converted to BigDecimal by it's very nature.
> Solution is to introduce new BigDecimalTranslator, something like :
> import org.apache.hivemind.ApplicationRuntimeException;
> import org.apache.tapestry.form.IFormComponent;
> import org.apache.tapestry.form.ValidationMessages;
> import org.apache.tapestry.form.translator.AbstractTranslator;
> import org.apache.tapestry.valid.ValidationConstraint;
> import org.apache.tapestry.valid.ValidationStrings;
> import org.apache.tapestry.valid.ValidatorException;
> import java.math.BigDecimal;
> import java.util.Locale;
> public class BigDecimalTranslator extends AbstractTranslator {
> public BigDecimalTranslator() {
> }
> // Needed until HIVEMIND-134 fix is available
> public BigDecimalTranslator(String initializer) {
> super(initializer);
> }
> protected String formatObject(IFormComponent field, Locale locale, Object object) {
> if (!(object instanceof BigDecimal)) {
> throw new ApplicationRuntimeException("BigDecimalTranslator translates values of type BigDecimal, not: " + object.getClass());
> }
> return object.toString();
> }
> protected Object parseText(IFormComponent field, ValidationMessages messages, String text) throws ValidatorException {
> try {
> return new BigDecimal(text);
> } catch (NumberFormatException e) {
> throw new ValidatorException(buildMessage(messages, field, ValidationStrings.INVALID_NUMBER), ValidationConstraint.NUMBER_FORMAT);
> }
> }
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org