How can I make a combobox value not selectable by user?
String [] names = {"john", "jack", "frank"};
JComboBox box = new JComboBox(names);
lezioniBox.insertItemAt("-- Choose a name --", 0);
lezioniBox.setSelectedIndex(0); \\ I wanted to have a sort of hint
But I don't want to have -- Choose a name -- selectable. How can I do?
You can't, however, you can add some validation code for when the user attempts to do something with your JComboBox. If they choose that option, then you can throw an error. This can be done with an event listener on the JComboBox, or if this is being submitted in a form-like format it can validate when the user selects OK, Save, or whenever you have your submit button set to.
Related
I had created a popuplov and selected data from a shared component, I need to pass the selected value to a select query in the interactive report.
And I've select query in the interactive report, I need to pass the selected value to the select query in the report
Add WHERE to your IR like
SELECT ...
FROM ...
WHERE ... = :V_DC
Set "Page Items To Submit" property of IR to your PopupLOV name, so when IR refreshed by something, value of PopupLOV will be set into session state.
Add dynamic action on Change of PopupLOV
It means "Run this action when value of item P61011189_DEPT (PopupLOV) has changed".
Add one action to True branch of created Dynamic Action - Refresh IR Region.
It means "When Dynamic Action starts refresh Emps region".
You can check my example here: https://apex.oracle.com/pls/apex/f?p=54028:61011189
Use it in IR's query, in its WHERE clause, e.g.
select ...
from ...
where data_center = :V_DC
As Popup LoV item doesn't have "Page action on selection" property which would enable to submit the page and "force" IR to refresh, one option is to create a button on that page which will do the same. So:
choose value from Popup Lov
push the button
IR will refresh
That might be done differently, but I don't know how. Someone else might, though.
I have a model with two fields, Name and Token. In my app, the user will select a record from a Dropdown populated with the Name field of all records. When this happens, I need to assign the record's corresponding Token value to a variable in a server script, but am not sure how to accomplish this.
There are two options that are suitable. As a first option you could implement a server script that returns the token of the field when you edit the widget.
function checkToken(widgetValue) {
var query = app.models.YourModel.newQuery();
query.filters.Field._equals = widgetValue;
var records = query.run();
return records[0].Token;
}
You can add the script caller checkToken(widget.value) to the onValueEdit event of widget, so that it runs every time you select another dropdown item. If you want to use another event, please look at https://developers.google.com/appmaker/ui/logic#events.
As a second option you could add a secondary label to your form which you bind to the dropdown item selection. The binding would look something like this:
#pages.MyPage.descendants.DropDown.value.Token
When you configure Dropdown you need to set three important properties:
options
An array of string representations of options that makes up the content of the dropdown
#datasources.MyDatasource.items..Token
names
An array of strings to be displayed in place of options' default strings. The array must be the same length as options.
#datasources.MyDatasource.items..Name
value
The value assigned to the databound property, based on the user's dropdown selection
// Assuming that dropdown is added to form
// or any other container bound to proper datasource.
#datasource.item.Token
Note
double dot .. syntax is used for projections
Which FormDataSource method to use to determine that the record is not saved yet?
i.e.
I mean when my grid line is in this situation I want my mennuItemButton to throw the error.
Thanks...
You can check the RecId == 0, but in your case it would be simpler to set the NeedsRecord attribute of the menu item. This will disable the button if there is no active record.
I would like an Unbound combobox located in the header of a form to match or filter by any character (s) that a User inputs. I would like those matches only to display in the combobox itself. Once the User selects one of the choices have the form go to that selection and reset the combobox to a complete list.
I tried a parameter query, but that only works once and does not reset. I also looked into LIKE and CONTAINS , but have had no luck.
Use the following in the combo RowSource property:
SELECT [Value for combobox list] FROM tbl WHERE [Value for combobox list] LIKE '*' & forms!MyForm!txtInput & '*'
You need to do cmb.Requery at some stage after a change is made in txtInput. If you do it on the txtInput_OnChange event, you will need to access the Text property of txtInput, so you would need to change the above SQL slightly.
Simplest would be to have a button to be pressed after typing in the filter and putting the Requery method in cmdFilter_Click event
Q:
I have the following question about an interface issue.
I have a drop down list contains a list of items . Sometimes ,the user needs to select an item not exist in this drop down list(others).I wanna the user to enter his item and added to the list. What is the best practice to do this from interface(point of view).(usability).and(How to validate the user entry).
If the user selects the Other option from the dropdownlist, you can provide the textbox to the user that use will be able to enter a new entry. When the user presses OK, after defining the value, you can check the value in the DB, whether this exist or not, if not existed, you can add the value to DB.
I hope, I am able to explain the idea.
Edit: Referring to your comment, it will be like..
DropDownList1.DataSource = DataSource;
DropDownList1.DataTextField = "TextField";
DropDownList1.DataValueField = "ValueField"
DropDownList1.DataBind();
// Now add the other option, it will be added in the last
DropDownList1.Items.Add("Other");
the best option would be, allow other option in list box when user selects this option add text box dynamically via javascript and once user answers it validate via ajax at server side and then add it to your options.