Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Multi select does not work when binding options from REST call

2930948Apr 5 2016 — edited Apr 12 2016

Hello,

I am having trouble with multi select. The problem is when I get the data for the options from the REST call then upon selecting the option it shows it's value in the select and not the label.

Here is some example code for the problem (for the simplicity of the example let's assume that the view model is properly bind to the select element, $ variable is jQuery object, url is variable containing the endpoint url of the server, the REST call is successful and the returned data is in following format:

     [{value: '1', label:'Label for item 1'}, {value: '2', label: 'Label for item 2'}, {value: '3', label: 'Label for item 3'}]

):

HTML snippet:

<label for="select">Select with options array</label>

<select id="select" data-bind="ojComponent: {component: 'ojSelect', options: browsers, multiple: true,

                                             rootAttributes: {style:'max-width:20em'}}">

</select>

and Javascript

function selectModel () {

    var self = this;

    this.browsers = ko.observableArray([]);

     $.getJSON(url, function(data) {

          self.browsers(data);

     });

  }

The problem is that in this example the options in the select are correct - Label for item 1, Label for item 2, .... But when one of them is selected then inside the select box it's value is shown eg. '1' instead of the label. This is problem only with multi select and when setting options in the callback from the REST call, single select works fine.

Any ideas how to solve this?

Thank you

Vasek Stebra

This post has been answered by Jim.Marion-Oracle on Apr 6 2016
Jump to Answer

Comments

Jeff Martin

Your query might win the award for the "shortest question with the longest answer", but I'll try for a short answer. For the first part, you need to fetch data from the database. For this you could use anything from raw JDBC to an Object Relational Mapping (ORM) tool, like Hibernate. For the second part, I would recommend a reporting tool, like Jasper Reports, BIRT or ReportMill. Currently, only ReportMill has generated reports in JavaFX. But they all generate PDF - and that would be my suggestion: generate PDF and use the platform PDF viewer to display and print reports. You could spend years trying to duplicate all the nice display and print functionality found in Acrobat Reader and Mac OS X Preview.

As it happens, ReportMill (disclosure: me) is working on a tool to do exactly what your question asks for:

http://www.reportmill.com/javi/gallery/AddressBook

There is also a very cool database tool that has JavaFX support called XDEV. We'll both be at JavaOne.

1 - 1

Post Details

Added on Apr 5 2016
5 comments
3,395 views