Converters used in the JGoodies Framework

  • Thread starter srinivas.veeranki
  • Start date
S

srinivas.veeranki

Hi All...

I wrote one converter DateTimeNullableConverter which extends
AbstractConverter. In this class, i overwrite the methods of
convertFromSubject() and setValue() methods. Actually these methods
will invoke when ever i changed in the corresponding components fields
or change of the value in the corresponding attribute. But in my case
these ,methods are firing when ever i press the tab key in that widget
and also firing when ever i minimize the window as well as restoring
the window. This is not require for me. Can i restrict the this type of
firings..?

Thanks in advance... for ur help. Thank you much more....

I am giving the source code for this converter.

package com.calpers.uicommons;

import java.text.SimpleDateFormat;
import java.util.Date;

import com.gtl.ftoj.framework.DateTimeNullable;
import com.jgoodies.binding.value.AbstractConverter;
import com.jgoodies.binding.value.ValueModel;

public class DateTimeNullableConverter extends AbstractConverter {
/**
* Constructor
* @param booleanSubject ValueModel
*/
public DateTimeNullableConverter(ValueModel booleanSubject) {
super(booleanSubject);
}
/**
* This method returns the formated date value for the given
objectvalue
* @param subjectValue Object
* @return Object
*/
public Object convertFromSubject(Object subjectValue) {

DateTimeNullable utlDateObj = null;
if( subjectValue != null ) {
utlDateObj = (DateTimeNullable)subjectValue;
}

if(utlDateObj != null && utlDateObj.theValue != null) {
SimpleDateFormat sDf = new SimpleDateFormat("MM/dd/yyyy");
return sDf.format(new
Date(utlDateObj.theValue.getTimeInMillis()));
}
return null;
}
/**
* This method sets the given object value
* @param newValue Object
*/
public void setValue(Object newValue) {
DateTimeNullable date = new DateTimeNullable();
if(newValue != null)
{
if ((((String) newValue).indexOf("*") > 0)) {
date.setNull(true);
subject.setValue(date);
return;
}

date = new
DateTimeNullable(date.setDate((String)newValue,"MM/dd/yyyy"));
subject.setValue(date);

} else {
date.setNull(true);
subject.setValue(date);
}
}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top