Binding a combo box vaadin 8How to bind a LazyQueryContainer and a Combobox in a Form in Vaadin?Vaadin 8 Converter behaves different than Vaadin 7 Converter (doesn't update UI)?Vaadin Grid vs. Persistence when displaying boolean as IconVaadin 8 - How to bind items of RadioButtonGroup?Install4j - combo box component configuration conditionsVaadin-8 ComboBox click has no effectInvoke validation user-feedback without binder & bean in Vaadin 8Vaadin Binding API and IdsIs a Binder the only way to have automatic handling for a data-entry field being required in Vaadin 8 layout?Vaadin Combobox - New Item

Are language and thought the same?

Ceiling fan electrical box missing female screw holes

Where on Earth is it easiest to survive in the wilderness?

My Friend James

Who are these people in this satirical cartoon of the Congress of Verona?

Shoes for commuting

Does POSIX guarantee the paths to any standard utilities?

Darwin alternative to `lsb_release -a`?

If I sell my PS4 game disc and buy a digital version, can I still access my saved game?

Are there mathematical concepts that exist in the fourth dimension, but not in the third dimension?

Combinatorics problems that can be solved more easily using probability

Bidirectional Dictionary

Is it risky to move from broad geographical diversification into investing mostly in less developed markets?

Is it possible to observe space debris with Binoculars?

Why there are construction cranes on apparently completed buildings in New York?

Why does the UK Prime Minister need the permission of Parliament to call a general election?

How were the names on the memorial stones in Avengers: Endgame chosen, out-of-universe?

How many people can lift Thor's hammer?

Why did Boris Johnson call for new elections?

Do 643,000 Americans go bankrupt every year due to medical bills?

Left my gmail logged in when I was fired

Is there any difference between these two sentences? (Adverbs)

Did the US Climate Reference Network Show No New Warming Since 2005 in the US?

How do I delete cookies from a specific site?



Binding a combo box vaadin 8


How to bind a LazyQueryContainer and a Combobox in a Form in Vaadin?Vaadin 8 Converter behaves different than Vaadin 7 Converter (doesn't update UI)?Vaadin Grid vs. Persistence when displaying boolean as IconVaadin 8 - How to bind items of RadioButtonGroup?Install4j - combo box component configuration conditionsVaadin-8 ComboBox click has no effectInvoke validation user-feedback without binder & bean in Vaadin 8Vaadin Binding API and IdsIs a Binder the only way to have automatic handling for a data-entry field being required in Vaadin 8 layout?Vaadin Combobox - New Item






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I'am trying to convert vaadin 7 code to vaadin 8 code Instead of using BeanFieldGroup vaadin 8 docs uses Binder instead to bind form fields to a class. This does not seem to work for combo box's.



I've looked for a way to use converter which does not seem to be available for combo box. As used in binding data to form in the vaadin documentation here



For one field the converter worked:



binder.forField(age).withConverter(
new
StringToIntegerConverter("Must enter a number")).bind(
Student::getAge,
Student::setAge);


But for a combo box I'am unsure how this will work.



ComboBox<String> gender = new ComboBox<String>("Gender");

Binder binder = new Binder<Student>(Student.class);

binder.bind(gender, Student::getGender, Student::setGender);


Which I know will not work is there a way to write a converter for a combo box or should another way be used altogether.










share|improve this question


























  • Which I know will not work - why not? looks good to me. Did you set items for the ComboBox? There should never be a need for a Converter on a ComboBox - You can always add an ItemLabelGenerator where you can define the conversion from the original type to how it should be displayed (default is toString, but you could convert it to Vaadin Components for example. see how it is done in the documentation)

    – Kaspar Scherrer
    Mar 28 at 8:50












  • I got a error message The method bind(HasValue, ValueProvider, Setter) in the type Binder is not applicable for the arguments (ComboBox<String>, Student::getGender, Student::setGender) but when I tried to replicate the error no error was there. But using bindInstanceFields was easier though.

    – recurseuntilfor
    Mar 28 at 10:43












  • is gender actually an Enum or is it a String in your student object? using bindInstanceFields can be easier but IIRC then it only works for very basic bindings - no converters, validators, nullRepresentations, or readOnly (no setter) can be set, and you can't bind nested fields of the Student object. it basically applies binder.forField(field).bind("propertyName") for each HasValue-component in your view

    – Kaspar Scherrer
    Mar 28 at 10:50












  • It is an Enum in a string utils with a toString method

    – recurseuntilfor
    Mar 28 at 10:53






  • 1





    aha! you should define your ComboBox as ComboBox<Gender> then!

    – Kaspar Scherrer
    Mar 28 at 10:55

















0















I'am trying to convert vaadin 7 code to vaadin 8 code Instead of using BeanFieldGroup vaadin 8 docs uses Binder instead to bind form fields to a class. This does not seem to work for combo box's.



I've looked for a way to use converter which does not seem to be available for combo box. As used in binding data to form in the vaadin documentation here



For one field the converter worked:



binder.forField(age).withConverter(
new
StringToIntegerConverter("Must enter a number")).bind(
Student::getAge,
Student::setAge);


But for a combo box I'am unsure how this will work.



ComboBox<String> gender = new ComboBox<String>("Gender");

Binder binder = new Binder<Student>(Student.class);

binder.bind(gender, Student::getGender, Student::setGender);


Which I know will not work is there a way to write a converter for a combo box or should another way be used altogether.










share|improve this question


























  • Which I know will not work - why not? looks good to me. Did you set items for the ComboBox? There should never be a need for a Converter on a ComboBox - You can always add an ItemLabelGenerator where you can define the conversion from the original type to how it should be displayed (default is toString, but you could convert it to Vaadin Components for example. see how it is done in the documentation)

    – Kaspar Scherrer
    Mar 28 at 8:50












  • I got a error message The method bind(HasValue, ValueProvider, Setter) in the type Binder is not applicable for the arguments (ComboBox<String>, Student::getGender, Student::setGender) but when I tried to replicate the error no error was there. But using bindInstanceFields was easier though.

    – recurseuntilfor
    Mar 28 at 10:43












  • is gender actually an Enum or is it a String in your student object? using bindInstanceFields can be easier but IIRC then it only works for very basic bindings - no converters, validators, nullRepresentations, or readOnly (no setter) can be set, and you can't bind nested fields of the Student object. it basically applies binder.forField(field).bind("propertyName") for each HasValue-component in your view

    – Kaspar Scherrer
    Mar 28 at 10:50












  • It is an Enum in a string utils with a toString method

    – recurseuntilfor
    Mar 28 at 10:53






  • 1





    aha! you should define your ComboBox as ComboBox<Gender> then!

    – Kaspar Scherrer
    Mar 28 at 10:55













0












0








0








I'am trying to convert vaadin 7 code to vaadin 8 code Instead of using BeanFieldGroup vaadin 8 docs uses Binder instead to bind form fields to a class. This does not seem to work for combo box's.



I've looked for a way to use converter which does not seem to be available for combo box. As used in binding data to form in the vaadin documentation here



For one field the converter worked:



binder.forField(age).withConverter(
new
StringToIntegerConverter("Must enter a number")).bind(
Student::getAge,
Student::setAge);


But for a combo box I'am unsure how this will work.



ComboBox<String> gender = new ComboBox<String>("Gender");

Binder binder = new Binder<Student>(Student.class);

binder.bind(gender, Student::getGender, Student::setGender);


Which I know will not work is there a way to write a converter for a combo box or should another way be used altogether.










share|improve this question
















I'am trying to convert vaadin 7 code to vaadin 8 code Instead of using BeanFieldGroup vaadin 8 docs uses Binder instead to bind form fields to a class. This does not seem to work for combo box's.



I've looked for a way to use converter which does not seem to be available for combo box. As used in binding data to form in the vaadin documentation here



For one field the converter worked:



binder.forField(age).withConverter(
new
StringToIntegerConverter("Must enter a number")).bind(
Student::getAge,
Student::setAge);


But for a combo box I'am unsure how this will work.



ComboBox<String> gender = new ComboBox<String>("Gender");

Binder binder = new Binder<Student>(Student.class);

binder.bind(gender, Student::getGender, Student::setGender);


Which I know will not work is there a way to write a converter for a combo box or should another way be used altogether.







java vaadin8






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 28 at 8:36







recurseuntilfor

















asked Mar 28 at 4:09









recurseuntilforrecurseuntilfor

2373 silver badges8 bronze badges




2373 silver badges8 bronze badges















  • Which I know will not work - why not? looks good to me. Did you set items for the ComboBox? There should never be a need for a Converter on a ComboBox - You can always add an ItemLabelGenerator where you can define the conversion from the original type to how it should be displayed (default is toString, but you could convert it to Vaadin Components for example. see how it is done in the documentation)

    – Kaspar Scherrer
    Mar 28 at 8:50












  • I got a error message The method bind(HasValue, ValueProvider, Setter) in the type Binder is not applicable for the arguments (ComboBox<String>, Student::getGender, Student::setGender) but when I tried to replicate the error no error was there. But using bindInstanceFields was easier though.

    – recurseuntilfor
    Mar 28 at 10:43












  • is gender actually an Enum or is it a String in your student object? using bindInstanceFields can be easier but IIRC then it only works for very basic bindings - no converters, validators, nullRepresentations, or readOnly (no setter) can be set, and you can't bind nested fields of the Student object. it basically applies binder.forField(field).bind("propertyName") for each HasValue-component in your view

    – Kaspar Scherrer
    Mar 28 at 10:50












  • It is an Enum in a string utils with a toString method

    – recurseuntilfor
    Mar 28 at 10:53






  • 1





    aha! you should define your ComboBox as ComboBox<Gender> then!

    – Kaspar Scherrer
    Mar 28 at 10:55

















  • Which I know will not work - why not? looks good to me. Did you set items for the ComboBox? There should never be a need for a Converter on a ComboBox - You can always add an ItemLabelGenerator where you can define the conversion from the original type to how it should be displayed (default is toString, but you could convert it to Vaadin Components for example. see how it is done in the documentation)

    – Kaspar Scherrer
    Mar 28 at 8:50












  • I got a error message The method bind(HasValue, ValueProvider, Setter) in the type Binder is not applicable for the arguments (ComboBox<String>, Student::getGender, Student::setGender) but when I tried to replicate the error no error was there. But using bindInstanceFields was easier though.

    – recurseuntilfor
    Mar 28 at 10:43












  • is gender actually an Enum or is it a String in your student object? using bindInstanceFields can be easier but IIRC then it only works for very basic bindings - no converters, validators, nullRepresentations, or readOnly (no setter) can be set, and you can't bind nested fields of the Student object. it basically applies binder.forField(field).bind("propertyName") for each HasValue-component in your view

    – Kaspar Scherrer
    Mar 28 at 10:50












  • It is an Enum in a string utils with a toString method

    – recurseuntilfor
    Mar 28 at 10:53






  • 1





    aha! you should define your ComboBox as ComboBox<Gender> then!

    – Kaspar Scherrer
    Mar 28 at 10:55
















Which I know will not work - why not? looks good to me. Did you set items for the ComboBox? There should never be a need for a Converter on a ComboBox - You can always add an ItemLabelGenerator where you can define the conversion from the original type to how it should be displayed (default is toString, but you could convert it to Vaadin Components for example. see how it is done in the documentation)

– Kaspar Scherrer
Mar 28 at 8:50






Which I know will not work - why not? looks good to me. Did you set items for the ComboBox? There should never be a need for a Converter on a ComboBox - You can always add an ItemLabelGenerator where you can define the conversion from the original type to how it should be displayed (default is toString, but you could convert it to Vaadin Components for example. see how it is done in the documentation)

– Kaspar Scherrer
Mar 28 at 8:50














I got a error message The method bind(HasValue, ValueProvider, Setter) in the type Binder is not applicable for the arguments (ComboBox<String>, Student::getGender, Student::setGender) but when I tried to replicate the error no error was there. But using bindInstanceFields was easier though.

– recurseuntilfor
Mar 28 at 10:43






I got a error message The method bind(HasValue, ValueProvider, Setter) in the type Binder is not applicable for the arguments (ComboBox<String>, Student::getGender, Student::setGender) but when I tried to replicate the error no error was there. But using bindInstanceFields was easier though.

– recurseuntilfor
Mar 28 at 10:43














is gender actually an Enum or is it a String in your student object? using bindInstanceFields can be easier but IIRC then it only works for very basic bindings - no converters, validators, nullRepresentations, or readOnly (no setter) can be set, and you can't bind nested fields of the Student object. it basically applies binder.forField(field).bind("propertyName") for each HasValue-component in your view

– Kaspar Scherrer
Mar 28 at 10:50






is gender actually an Enum or is it a String in your student object? using bindInstanceFields can be easier but IIRC then it only works for very basic bindings - no converters, validators, nullRepresentations, or readOnly (no setter) can be set, and you can't bind nested fields of the Student object. it basically applies binder.forField(field).bind("propertyName") for each HasValue-component in your view

– Kaspar Scherrer
Mar 28 at 10:50














It is an Enum in a string utils with a toString method

– recurseuntilfor
Mar 28 at 10:53





It is an Enum in a string utils with a toString method

– recurseuntilfor
Mar 28 at 10:53




1




1





aha! you should define your ComboBox as ComboBox<Gender> then!

– Kaspar Scherrer
Mar 28 at 10:55





aha! you should define your ComboBox as ComboBox<Gender> then!

– Kaspar Scherrer
Mar 28 at 10:55












2 Answers
2






active

oldest

votes


















1
















You mentioned in a comment that the gender field in your Student object is actually an Enum and not a String.



Your mistake was that you defined the ComboBox with type String instead of your Gender enum.



Assuming your gender enum class is called Gender, this will work:



ComboBox<Gender> gender = new ComboBox<Gender>("Gender");
Binder binder = new Binder<Student>(Student.class);
binder.bind(gender, Student::getGender, Student::setGender);


You can add an ItemLabelGenerator to the ComboBox to define how your Gender enum should be displayed. By default it will use toString() of the class. But you could use it to build Vaadin Components for example if you want. see how it is done in the documentation).






share|improve this answer


































    0
















    I have found that in vaadin 8 uses bindInstanceFields to bind form data to a class.



    Binder binder = new Binder<Student>(Student.class);

    binder.bindInstanceFields(this);
    binder.readBean(student);





    share|improve this answer



























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55390021%2fbinding-a-combo-box-vaadin-8%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1
















      You mentioned in a comment that the gender field in your Student object is actually an Enum and not a String.



      Your mistake was that you defined the ComboBox with type String instead of your Gender enum.



      Assuming your gender enum class is called Gender, this will work:



      ComboBox<Gender> gender = new ComboBox<Gender>("Gender");
      Binder binder = new Binder<Student>(Student.class);
      binder.bind(gender, Student::getGender, Student::setGender);


      You can add an ItemLabelGenerator to the ComboBox to define how your Gender enum should be displayed. By default it will use toString() of the class. But you could use it to build Vaadin Components for example if you want. see how it is done in the documentation).






      share|improve this answer































        1
















        You mentioned in a comment that the gender field in your Student object is actually an Enum and not a String.



        Your mistake was that you defined the ComboBox with type String instead of your Gender enum.



        Assuming your gender enum class is called Gender, this will work:



        ComboBox<Gender> gender = new ComboBox<Gender>("Gender");
        Binder binder = new Binder<Student>(Student.class);
        binder.bind(gender, Student::getGender, Student::setGender);


        You can add an ItemLabelGenerator to the ComboBox to define how your Gender enum should be displayed. By default it will use toString() of the class. But you could use it to build Vaadin Components for example if you want. see how it is done in the documentation).






        share|improve this answer





























          1














          1










          1









          You mentioned in a comment that the gender field in your Student object is actually an Enum and not a String.



          Your mistake was that you defined the ComboBox with type String instead of your Gender enum.



          Assuming your gender enum class is called Gender, this will work:



          ComboBox<Gender> gender = new ComboBox<Gender>("Gender");
          Binder binder = new Binder<Student>(Student.class);
          binder.bind(gender, Student::getGender, Student::setGender);


          You can add an ItemLabelGenerator to the ComboBox to define how your Gender enum should be displayed. By default it will use toString() of the class. But you could use it to build Vaadin Components for example if you want. see how it is done in the documentation).






          share|improve this answer















          You mentioned in a comment that the gender field in your Student object is actually an Enum and not a String.



          Your mistake was that you defined the ComboBox with type String instead of your Gender enum.



          Assuming your gender enum class is called Gender, this will work:



          ComboBox<Gender> gender = new ComboBox<Gender>("Gender");
          Binder binder = new Binder<Student>(Student.class);
          binder.bind(gender, Student::getGender, Student::setGender);


          You can add an ItemLabelGenerator to the ComboBox to define how your Gender enum should be displayed. By default it will use toString() of the class. But you could use it to build Vaadin Components for example if you want. see how it is done in the documentation).







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 28 at 11:51

























          answered Mar 28 at 11:03









          Kaspar ScherrerKaspar Scherrer

          2,4721 gold badge8 silver badges27 bronze badges




          2,4721 gold badge8 silver badges27 bronze badges


























              0
















              I have found that in vaadin 8 uses bindInstanceFields to bind form data to a class.



              Binder binder = new Binder<Student>(Student.class);

              binder.bindInstanceFields(this);
              binder.readBean(student);





              share|improve this answer





























                0
















                I have found that in vaadin 8 uses bindInstanceFields to bind form data to a class.



                Binder binder = new Binder<Student>(Student.class);

                binder.bindInstanceFields(this);
                binder.readBean(student);





                share|improve this answer



























                  0














                  0










                  0









                  I have found that in vaadin 8 uses bindInstanceFields to bind form data to a class.



                  Binder binder = new Binder<Student>(Student.class);

                  binder.bindInstanceFields(this);
                  binder.readBean(student);





                  share|improve this answer













                  I have found that in vaadin 8 uses bindInstanceFields to bind form data to a class.



                  Binder binder = new Binder<Student>(Student.class);

                  binder.bindInstanceFields(this);
                  binder.readBean(student);






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 28 at 8:32









                  recurseuntilforrecurseuntilfor

                  2373 silver badges8 bronze badges




                  2373 silver badges8 bronze badges






























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55390021%2fbinding-a-combo-box-vaadin-8%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                      Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                      Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript