Xpages Combobox -setting the default value - combobox

I have a combobox with values being populated from a managed bean like so:
keywordlist.setConnDB("jdbc:sqlserver://xx.xx.x.xx:1433;DatabaseName=xxx");
keywordlist.setConnUserName("xxx");
keywordlist.setConnPassword("xxx");
keywordlist.setSQLQuery("SELECT DisplayText as Keyword From Glossary WHERE SUBSTRING(DisplayText, 1, 2)= 'RV'");
keywordlist.keywords;
I'd like to be able to set the default to '--- Select ---', but no matter what I do the keyword list always picks the first of the returned keywords as the default.
Any assistance would be much appreciated.
Thanks,
Dan

Add another value pair (on first position), type "formula item" with the following SSJS return value:
"-- Select --|"
Notice the pipe!
That should display this at first position and should also be defaulted as "empty" is the default value. If not, set the "alias" (the value after the pipe) to something that you can define as default value porperty for the combo item.

It might be because you're binding to the bean directly. You might have to add that value to your keyword list itself. I think I have an example of this in a NotesIn9 show: http://notesin9.com/index.php/2014/03/13/notesin9-138-xpages-combobox-improvements/
I'm not sure. If I don't have a default in the java code you can probably see how it might be done.
Try that. If that doesn't work at all then maybe you don't bind the combo box to the bean directly. Maybe bind it to a viewScope var... since that can be anything it'll take a blank... then you just need to move the viewScope var value back up to your bean in the onChange event or something.
Just a quick thought...

Basically, the following pattern could be a start point for such a combobox:
<xp:comboBox
id="comboBox1"
defaultValue=""
value="#{document1.someField}">
<xp:selectItem
itemLabel="--- Select ---"
itemValue=""></xp:selectItem>
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:
// Your SSJS code...
// Should return some kind of list...
return items;
}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
Alternatively, you can grab the keyword values from a Java bean:
<xp:selectItems value=#{yourBean.yourValue}></xp:selectItems>
Still, it's important to return a list value. It might also have "label|value" format.

Related

Extjs 6.0 - ItemSelector: how to programmatically focus/highlight an element?

I have a ItemSelector component inside a Window. I have implemented a search functionality that dynamically finds the matching entry based on user's keyboard input.
Now I just want to highlight/focus such item inside the ItemSelector.
I'm looking for something like:
// when the search returned a result and got the related index in the store
function onSearchPerformed(index) {
var cmp = this;
cmp.itemSelector.setSelected(index); // here I'd be highlighting the entry
}
Example
Imagine a simple ItemSelector like this one taken from the web.
User types 'Delaw' and my search function detects that there is an entry with name Delaware and it's at position 3 in the store.
All I want to do is to programmatically highlight the row/entry 'Delaware' just as if you clicked on it.
This ux component uses a boundList, or better 2 of them.
A from and a toList.
You need to get a reference to the right boundlist.
More on that you will find here: http://docs.sencha.com/extjs/6.0.1/classic/src/ItemSelector.js.html
Basically you can do something like this:
https://fiddle.sencha.com/#view/editor&fiddle/24ec
afterrender: function(cmp){
Ext.defer(function(){
var boundlist = cmp.down('boundlist');
item = boundlist.all.item(1);
boundlist.highlightItem(item);
},300);
}
After you have a ref to the correct boundlist, you can simply highlight the item using:
http://docs.sencha.com/extjs/6.0.1/classic/Ext.view.BoundList.html#method-highlightItem
Take care that you may need to call following function before:
http://docs.sencha.com/extjs/6.0.1/classic/Ext.view.BoundList.html#method-clearHighlight
To find the correct item should't be too hard.
There are two ways to solve the issue
One is by following #devbnz answer, marked as correct. This is preferable, if you just want to graphically highlight the entry without triggering any event.
However, by hovering on other entries, you will lose the highlight on your current entry.
The second one, as suggested by #guilherme-lopes in the comments, may be preferable in cases in which you want the selection to act as if you actually clicked on an entry, which will trigger the selectionchange event and similar...
Depending on the situation, I ended up using either.

ADF-Jdeveloper How to set the first value by default of a RichSelectOneChoice?

I have a RichSelectOneChoice that is populated from a LOV, the default value is null, I know that it is a bad practice to leave default values in a SelectOneChoice but the user requires it. Thanks in advance.
The RichSelectOneChoice has an attribute called value, setting that value will set the default value. Selection comes from af:selectItems or other selectItem(s) alternatives, so there are no contradictions there!
I know is a bad practice set default values in comboboxes,
In my solution I set the default value in the current row of my viewModel of the field that I want to be selected by default in my select on choice, before to go to that page.
It´s something like this:
rowViewObjectRow.setCodeFieldReferenceSelectOneChoice(0);
The value "0" always be in the lov, is a bad practice, and if you find another solution without set the value by default could be better.

How to access to a Combo box value in Item Line on NetSuite?

In NETSUITE
is there any way to access to a value inside of a combo-box at the item line level?
I need to access to a value after inserting an item but all functions get me null value.
I have tried
nlapiGetCurrentLineItemValue
and
nlapiGetFieldValue
Both functions are getting me null values.
Thanks,
Pablo.
In general (for user event and client script) below code should work
nlapiGetLineItemValue(LINE_ITEM_TYPE, YOUR_FIELD_ID, LINE_NUMBER);
eg on SO to get the line item Id:
nlapiGetLineItemValue('item', 'item', 1);
PS: Syntax is independent of data type or field type
If you mean combo box as a mulitselect, and if you're trying to access via User Event Script, use:
nlapiGetLineItemValues(type, fldname, linenum);
Note the 's' in nlapiGetLineItemValues
If its just a standard field, nlapiGetLineItemValue(type, fldname, linenum) should work.
Which call to use depends on what event you are capturing.
For instance if you are trying to access the value in a post sourcing, field changed or line validate event of a client script you would use nlapiGetCurrentLineItemValue('item', 'fieldname');

In HaxeFlixel, What is Box object and how to use it?

I'm trying to use FlxUICheckBox. In the official documentation, the constructor looks like this:
new(X:Float = 0, Y:Float = 0, ?Box:Dynamic, ..)
What is the Box object?
How should I send a Box object as a parameter to this constructor?
I should probably change it to BoxAsset. It's the image asset you want to use for the box part of the checkbox.
A simple checkbox has three components, and looks a bit like this:
[X] Checkbox
Box means the box part, "[ ]"
Check means the check part, "X"
Label means the text that goes in the textfield next to the checkbox
If you don't provide Box or Check, it will use default FlxUIAssets automatically to skin your checkbox. If you provide your own asset (such as "assets/mybox.png" for example), it will use that instead. It is expecting the same sort of thing you would pass into FlxSprite.loadGraphic() -- a String, a BitmapData, or a FlxGraphic.
I should probably also update the type from :Dynamic to :FlxGraphicAsset, I originally wrote this code a long time ago before they added that new helper type.

How do get id & text from a dojo/dijit combobox?

How do you get the id for the underlying record in a combobox with dojo? I've tried altering the following sample but all I can get is the text shown to the user (the "name" property of each array element), and NOT the state's two-letter abbreviation ("id" property).
http://dojotoolkit.org/reference-guide/1.10/dijit/form/ComboBox.html#id3
thanks. PS, I'm a total noob with dojo. This is my first experiment with it.
It's like #CodeCrisis said, you can get the item by using dijit.byId('stateSelect').item. Though I'm not really pleased with how outdated the docs are (the dijit.byId()command is deprecated), this is a proper 1.10 solution:
query("button").on('click', function() {
console.log(comboBox.get('item'));
});
This will return the selected record in the store (containing both the id and name properties in this case).
A full, working example can be found here: http://jsfiddle.net/zt6xggL8/
How about this...
base on the link given
http://dojotoolkit.org/reference-guide/1.10/dijit/form/ComboBox.html#id3
change this onclick function
onClick="alert(dijit.byId('stateSelect').get('value'))"
into
onClick="alert(dijit.byId('stateSelect').item.id)"
i know this is not the best answer but i hope this will help you..
check out the answer of Philippe
Dojo : ComboBox selected and show data id
hehehe... :)
just passing by...
Not the prettiest but this works. Basically need to query the 'store' variable for the name that is being displayed when you just use 'value'. [0] denotes the first object in the store list, so if you have multiples with the same name, you'll need to use the foreach() function.
<button onClick="var namevar=dijit.byId('stateSelect').get('value');
alert(dijit.byId('stateSelect').get('store').query({name:namevar})[0].id);">
Get value
</button>

Resources