I want to be able to select a value in a radio button in XPages, then use that value to determine the choices in a set of checkboxes.
The choices for the radio button are found using a DbLookup to one view. There is some javascript that puts the text value of the radio button lookup into a hidden field. Based on that value, the checkbox choices are determined with another DbLookup.
I keep fiddling with the code and can never get it to use the updated value of the hidden field to recompute the choices for the checkboxes, even if I display it.
<xp:selectItems>
<xp:this.value>
<![CDATA[#{javascript: var viewName=reportDoc.getItemValueString("viewChoice");
var tmp = #DbLookup(#DbName(),"dbprofile",viewName,"Value");
#If(#IsError(tmp),"None",tmp)
}]]></xp:this.value>
</xp:selectItems>
I'm sure this is actually pretty simple, but I just can't figure it.
You need to set the onChange event of the radio button to partially refresh the checkBox control. This ensures that the values of the checkBox control are refreshed.
The checkBox control can read the value of the radio button control using getComponent("id of radio button control").getValue() and use this value instead of the hidden field for the DbLookup.
Related
I have a new form with fields called Field 1,Field 2 and one button. On click of that button, dialog box will display with some radio buttons. here i want to pass the selected radio button values to Field 2.
How to achieve it?
Appreciate if anyone help me out.
In dialog box, it looks like below
Just name your dialog box's radio button field the same like your target field in form (Field 2 in your case) and make sure
you don't use [NOFIELDUPDATE] option in #DialogBox
parameter noFieldUpdate is not set to True in notesUIWorkspace .DialogBox().
When editing the action button properties, it allows an #if statement to flip/flop two choices (lock/unlock). i.e. #If(enlock=1;"Unlock";"Lock") for the "Label" of the action button.
At the bottom of the Action properties, icons can be None, Notes, or Custom. When I select Custom, I want the #if to use either the Locked/Unlocked Notes icons. (actn084.gif and actn085.gif, respectively) Or numbers #62 (locked) and #(I don't know/can't find, the # for the unlock icon).
I've tried formula with the icon number, like in a view, "display as icons" for view column. Using an #if, I've tried the gif on local and server replica's and it didn't give any results.
Please see the example image below.
Image example: http://i.stack.imgur.com/UBac3.png
You have to add actn084.gif and actn085.gif to Resources/Images.
Then, you can use a formula
#If(enlock=1;"actn085.gif";"actn084.gif")
for calculating icon.
As an alternative, you could create two buttons and hide-when them depending on field enlock. You could assign label and icon direct to buttons without formula then.
The hide formula would be enlock=1 for first button and enlock!=1 for the second. In both buttons you would have to add #Command([RefreshHideFormulas]); at the end of your action formula to refresh the action buttons (or Call uiDoc.RefreshHideFormulas for LotusScript action code).
I have a viewPanel using DB2 for the datasource. I have created a comboBox containing all the possible viewPanel columns, a radioGroup to select ASC or DESC, a comboBox containing all the possible viewPanel columns with an onchange event to partially update the values in another comboBox, and a final comboBox that has all the values from DB2 according to the previous comboBox value that has an onchange event to partially update the viewPanel.
The onclick event for my button has this code and does a partial update of the viewPanel:
var sort:String = getComponent('comboBox1').getValue();
var order:String = getComponent('radioGroup1').getValue();
var vp = getComponent('panel_container').getData()[0];
vp.setDefaultOrderBy(sort + " " + order)
The problem is that I have to click the button twice to get the code to actually run. The first click is ensuring the onchange event is fired, then the second click activates the code. I have tried to use Full Update and checking the 'Set partial execution mode' with the partial update.
How do I get the onclick event for my button to work on the first click?
Too much event tango :-) Here is what I would do:
bind your combo boxes to viewScope variables. That's more robust than getValue() and allows to change the UI later (fancy some d&d)
use the combo box client side, not the server side onChange() event. This would require all values to be send down eg via Ajax
when you click the button make sure the fields are inside the panel you refresh
Hope that helps
I have a button that calls a Dialog that has a combo box bound to a sessionScope variable. The combo box contains a list of form names that I use to then call an XPage to create a new document. The first value in the forms list is "" so the user needs to select a value. I have a button with the onClick event of:
var c = getComponent("CreateDocDialog");
sessionScope.put("ssSelectedForm","")
c.show();
I have the button and dialog on a customControl with a repeatControl and when the button to open the dialog is clicked the ssSelectedForm is null and the current value of the combo is blank, which is exactly what I want it to be. However, if I add the same button and dialog to a customControl with a dataView control the dialog displays but ssSelectedForm is not null so the combo box displays the last value of ssSelected. I have placed the button outside the dataView, in several of the facets on the dataview, but all with the same results.
Very confusing.
Bill,
I am going to answer the same as my comment since I am pretty confident about what I said.
Go ahead and change the scope from sessionScope to viewScope. I had a similar issue once, and I 'fixed' it by clearing out the sessionScope variable after I used it. This worked, but I realized that it was not necessary, and that by changing to viewScope the lifecycle will be shorter and there was no need to clear out the value when I was done with it.
I don't know why this fails when added to the data view, but if this fixes it that would be all that matters.
I would like to place the radio buttons from a radio button group in different cells within a table. Is this possible?
You can set the groupName attribute of the radio button (not radio button group) control to group multiple radio buttons under the same name. Something like this:
<xp:radio text="Label" id="radio1" groupName="MyRadioGroup"></xp:radio>
You can then place these radio buttons at there respective cells in table. On the downside you wont be able to compute the list of items as you can in radio button group.
Another option is you could write your own custom renderer, like in this answer, that would generate the table with radio buttons for you.
Yes, totally possible. As long as the HTML "name" attribute is the same then they will be treated as the same group. You can add this to your radio button in the All Properties under "attrs". Give it a name of "name" and a value of something common between radio buttons you want to group.
I am not even sure, that you need to use the Radio Button Group if you don't want.