springdao.support.IntDaoPropertyEditor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sd4j Show documentation
Show all versions of sd4j Show documentation
Spring Dao Libray for easy using JPA
The newest version!
package springdao.support;
import org.springframework.util.StringUtils;
import springdao.RepositoryManager;
/**
*
* @author Kent Yeh
*/
public class IntDaoPropertyEditor extends DaoPropertyEditor {
public IntDaoPropertyEditor(RepositoryManager> daoManager) {
super(daoManager);
}
@Override
public void setAsText(String text) throws IllegalArgumentException {
try {
setValue(StringUtils.hasText(text) ? getDaoManager().findByPrimaryKey(Integer.valueOf(text)) : null);
} catch (RuntimeException e) {
setValue(null);
}
}
}