The Artima Developer Community
Sponsored Link

Java Answers Forum
BeansBinding issue

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
mohammed AlRefaii

Posts: 1
Nickname: mohref
Registered: Oct, 2009

BeansBinding issue Posted: Oct 6, 2009 10:20 AM
Reply to this message Reply
Advertisement
Hi all

I am using BeansBinding from java.net and i have a problem.
When i sync String property from my model with the (Text) property of some (jTextField) the validator does not run when i do .bind for the first time only (my validator is to check if the jtextField is not null).
While sync Float proerty from my model with the (Text) property of other (jTextField) the validator work very will.
Did i misunderstod or what is the problem.

GUI code



# BeanProperty<JTextField,String> textProperty = BeanProperty.create("text");
#
#
# BeanProperty<CurrencyPM,Float> bpDefalutPrice = BeanProperty.create("defaultPrice");
# binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ_WRITE,
# currencyPM,bpDefalutPrice,txtPrice,textProperty);
# binding.setConverter(new FloatConverter());
# binding.setValidator(new FloatValidator());
# bindingGroup.addBinding(binding);
#
# BeanProperty<CurrencyPM,String> bpName = BeanProperty.create("name");
#
# ELProperty<CurrencyPM,String> testName = ELProperty.create("${name}");
# binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ_WRITE,
# currencyPM,testName,txtName,textProperty);
#
#
# binding.setValidator(new StringNotNullValidator());
# binding.setConverter(new StringConverter());
#
# bindingGroup.addBinding(binding);
# bindingGroup.addBindingListener(this);
# bindingGroup.bind();



String Validator




# package view.helper.validator;
#
# import org.jdesktop.beansbinding.Validator;
#
# /**
# *
# * @author mrefaii
# */
# public class StringNotNullValidator extends Validator<String>{
# public Validator.Result validate(String arg) {
# System.out.println("in validator String : " + arg);
# if(arg.trim().equalsIgnoreCase("")){
# return new Result(null, "1X1");
# }
# return null;
# }
#
#
# }




String converter



# package view.helper.converter;
#
# import org.jdesktop.beansbinding.Converter;
#
# /**
# *
# * @author mrefaii
# */
# public class StringConverter extends Converter<String,String>{
#
# public String convertForward(String arg){
# System.out.println("in string converter forward");
# return arg;
# }
#
# public String convertReverse(String arg){
# System.out.println("in String converter reverse");
# return arg;
# }
#
# }




Float validator



# package view.helper.validator;
#
#
# import org.jdesktop.beansbinding.Validator;
# /**
# *
# * @author mrefaii
# */
# public class FloatValidator extends Validator<Float>{
# public Validator.Result validate(Float arg) {
# System.out.println("in validator Float : " + arg);
# if(arg <=0){
# return new Result(null, "1X3");
# }
# return null;
# }
#
#
# }




Float Converter



# package view.helper.converter;
#
# import org.jdesktop.beansbinding.Converter;
#
# public class FloatConverter extends Converter<Float,String>{
#
#
# public String convertForward(Float arg){
# return String.valueOf(arg);
# }
#
# public Float convertReverse(String arg){
# float value;
# try {
# value = (arg == null) ? 0 : Float.parseFloat(arg);
# } catch (NumberFormatException ex) {
# System.out.println("in vali");
# value = 0;
# }
# return value;
#
# }
# }



lease if anyone can help.
Very thanks.

Topic: Pass the array please.. Previous Topic   Next Topic Topic: class not found exception

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use