import com.marcozanon.macaco.conversion.MDateConverter;
import com.marcozanon.macaco.conversion.MFormatConversionException;
+import java.util.Date;
public class MWebDateBox extends MWebTextBox {
this.setText(text);
}
+ public MWebDateBox(MWebApplicationContext applicationContext, MDateConverter dateConverter, Date date) {
+ this(applicationContext, dateConverter);
+ //
+ this.setDate(date);
+ }
+
/* Date converter */
protected MDateConverter getDateConverterReference() {
return this.getDateConverterReference().clone();
}
+ /* Date conversion */
+
+ public void setDate(Date date) {
+ if (null == date) {
+ this.setText("");
+ }
+ else {
+ try {
+ this.setText(this.getDateConverterReference().getStringFromDate(date));
+ }
+ catch (MFormatConversionException exception) { // cannot happen
+ }
+ }
+ }
+
+ public Date getDate() throws MFormatConversionException {
+ Date date = null;
+ String text = this.getText();
+ if (!"".equals(text)) {
+ return this.getDateConverterReference().getDateFromString(text);
+ }
+ return date;
+ }
+
/* Validation */
public void validate() throws MValidationWebException {
import com.marcozanon.macaco.conversion.MFormatConversionException;
import com.marcozanon.macaco.conversion.MNumberConverter;
+import java.math.BigDecimal;
public class MWebNumberBox extends MWebTextBox {
this.setText(text);
}
+ public MWebNumberBox(MWebApplicationContext applicationContext, MNumberConverter numberConverter, BigDecimal number) {
+ this(applicationContext, numberConverter);
+ //
+ this.setNumber(number);
+ }
+
/* Number converter */
protected MNumberConverter getNumberConverterReference() {
return this.getNumberConverterReference().clone();
}
+ /* Number conversion */
+
+ public void setNumber(BigDecimal number) {
+ if (null == number) {
+ this.setText("");
+ }
+ else {
+ try {
+ this.setText(this.getNumberConverterReference().getStringFromNumber(number));
+ }
+ catch (MFormatConversionException exception) { // cannot happen
+ }
+ }
+ }
+
+ public BigDecimal getNumber() throws MFormatConversionException {
+ BigDecimal number = null;
+ String text = this.getText();
+ if (!"".equals(text)) {
+ return this.getNumberConverterReference().getNumberFromString(text);
+ }
+ return number;
+ }
+
/* Validation */
public void validate() throws MValidationWebException {