As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.
Join the TIBCO Community TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.
From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
Request access to the private WebFOCUS User Group (login required) to network with fellow members.
Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.
How do you add an onClick event handler for a radio button control?
The "control" is a set of three radio buttons. In HTML Composer, these are considered one control, hence only one onClick event handler in the Properties window - from the GUI you cannot add an event handler for an individual radiobutton.This message has been edited. Last edited by: Francis Mariani,
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
I have three radio buttons. When I attempted to use the GUI onClick, I determined that the function was called twice, I suppose for every button I did NOT click on - this is when I gave up.
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
We do not allow adding the event to an individual radio button because if it is dynamically populated, it is created on the fly and we have no idea how many there will be.
We would need it to be completely static in order for this to work.
David Glick Director WebFOCUS App Studio and WebFOCUS Developer Studio WebFOCUS Division Information Builders, Inc. Direct (917) 339-5560 Voice Mail (212) 736-6250 x3560 Fax (212) 947-5168 Email david_glick@ibi.com
Originally posted by Francis Mariani: [QUOTE]We do not allow adding the event to an individual radio button... We would need it to be completely static in order for this to work.
My radio button control is clearly marked as Static, by a radio button set called Data type.
Why does the onClick execute twice? Is this a bug, or this is by design? And if this is by design, please explain...
The following DS HTML Composer composed HTML page has one four-radio-button control with an onClick call to a function with an alert. Why does the alert pop up twice? How do I, in the DS HTML Composer world, figure out which one of the four radio buttons was clicked on? The alert displays "radio1" (twice) - nothing about the radio button actually clicked on?
We stopped allowing this in 769 because in 769 westarted allowing chaining of statically populated controls so the values can change and become a different set of static values. In 768, the values were static and could never change.
You can create an onClick event for the entire control and then use the IbComposer_getCurrentSelection() api call to pass the selected value. You muct be at release 7702 or 7703 to have this functionality though.
Francis, I believe you manually modified the HTML page to create your onClick event and we do not support that. If you are at 7702 or 7703, please use the method I described above.
David Glick Director WebFOCUS App Studio and WebFOCUS Developer Studio WebFOCUS Division Information Builders, Inc. Direct (917) 339-5560 Voice Mail (212) 736-6250 x3560 Fax (212) 947-5168 Email david_glick@ibi.com
Francis, I believe you manually modified the HTML page to create your onClick event and we do not support that. If you are at 7702 or 7703, please use the method I described above.
But that method does not cover all applicable events. Some, such as onbeforeload and onafterload, are documented but do not appear in the list of the Events tab (in 7.7.03).
I suppose one can avoid editing the HTML tags directly, by letting javascript do the equivalent when the page is loaded --
function onInitialUpdate() {
var node=document.getHtmlElementById('myid');
node.onbeforeload= function(ctrl){
...
};
}
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005
In 7703, these events, onbeforeload and onafterload are protected from showing by a registry key. They will be surfaced in release 7704 and 80. For now you can set HKEY_CURRENT_USER\Software\Information Builders\DeveloperStudio\77\FOCSHELL\WebFOCUS Developer Studio\ResourceLayout\allowSpecialEvents to 1 and the events will display.
If you feel an event you would like is missing, please open a case with justification and we will look into adding it.
David Glick Director WebFOCUS App Studio and WebFOCUS Developer Studio WebFOCUS Division Information Builders, Inc. Direct (917) 339-5560 Voice Mail (212) 736-6250 x3560 Fax (212) 947-5168 Email david_glick@ibi.com
The code I posted above is a non manually modified HTML page created in HTML Composer from Dev Studio v7.7.03. As you can see in the code, the onClick is called once, from the span tag surrounding the three radio buttons. You can copy it and create an HTML Composer page. Why does the onClick function "radio1_onclick" get triggered twice?
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
So, apparently some code in ibirls3.js decided to be smart and call the function again...
The relevant code from our ibirls3.js is here (implementation tends to differ between WF versions): @9450/9454
Ib_eventHandlerObject.prototype.execute = function ()
{
if(this.eventHandlerFunction)
this.eventHandlerFunction.call(this.htmlControl);
}
@11404/11459
Ib_inputControlObject.prototype.prepareToRun = function(objNodeList)
{
var nTabIndex = this.htmlInputControl.getAttribute('tabIndex');
if (!nTabIndex)
nTabIndex = this.htmlInputControl.getAttribute('tabIndexSaved');
this.htmlInputControl.removeAttribute('tabIndex');
this.htmlInputControl.setAttribute('tabIndexSaved', nTabIndex);
var uniqueId = this.getName();
var inputs = this.htmlInputControl.getElementsByTagName("INPUT");
var object = this;
var needToReselect = isLoadingFromSavedParamLocation() || bResetting;
var listOfSelectedValues = [];
for (var k = 0; k < objNodeList.length; k++)
{
if (objNodeList[k].selected)
listOfSelectedValues.push(objNodeList[k]);
}
var bSpanHasEvent = getHtmlElementEventHandler(this.htmlInputControl, "onclick", this.htmlInputControl.onclick);
var spanEvent = null;
if (bSpanHasEvent)
spanEvent = getHtmlElementEventHandler(this.htmlInputControl, "onclick", null);
for (var j = 0; j < inputs.length; j++)
{
var temp = inputs[j];
temp.setAttribute('tabIndex', nTabIndex);
if (getHtmlElementEventHandler(temp, "onclick", temp.onclick) == true || spanEvent)
{
temp.onclick = function(e)
{
var element = e && e.target ? e.target : window.event.srcElement;
var oldFuncObj = getHtmlElementEventHandler(element, "onclick", null);
if (oldFuncObj)
oldFuncObj.execute();
if (spanEvent)
/* here!! */ spanEvent.execute();
OnResetDownChainControls(uniqueId, e);
}
}
if (needToReselect)
{
var selected = false;
for (var x = 0; x < listOfSelectedValues.length; x++)
{
if (temp.value == listOfSelectedValues[x].value)
{
selected = true;
break;
}
}
temp.checked = selected;
}
}
}
WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010 : Member of User Group Benelux :
Givem just the id of (the SPAN containing) a radiogroup, is there a simple means of determining the index of the checked radio button? Or, for that matter, the number of buttons within the group?
Using DS 7.7.03
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005
That's a bit off-topic, really... Anyway, you can find out with:
function radioInfo(radioId) {
var span = document.getElementById(radioId);
var radioList = span.getElementsByTagName('input');
var length = radioList.length;
var selected = -1;
for (var i = 0; i < length; i++) {
if (radioList[i].checked) {
selected = i;
break;
}
}
alert('length: ' + length + ', selected: ' + selected);
}
That's assuming you don't add any other inputs to that radio-group (ones that aren't radio buttons of the same name), but that would probably break IBI handling of those items as well.
Unfortunately, due to the bug this topic is about, the first time this function gets called none of the radio buttons is checked yet.
WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010 : Member of User Group Benelux :
David Glick Director WebFOCUS App Studio and WebFOCUS Developer Studio WebFOCUS Division Information Builders, Inc. Direct (917) 339-5560 Voice Mail (212) 736-6250 x3560 Fax (212) 947-5168 Email david_glick@ibi.com
Wep5622, thanks for digging so deep into this issue. I am working on a short project with a very tight deadline and have no time to open tech support cases.
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
Francis, did you ever get a solution to this stuff?
I was in need of something like that today and after banging my head and lots of trial-and-error (much more of the latter) I found a way to make it happen. See image:
So, the trick here is:
1) When selecting the group box in the GUI, a SPAN element gets chosen in the properties windows. We have to browse in the properties up to the main FIELDSET (groupbox) element tag that shields the radio buttons (in my example, that is the "gbDate" element).
2) Click the "events" tab, and add a new "onclick" event to the selected groupbox.
After a lot of fun (yeah, right), I managed to determine that even though the event must be created on the groupbox (because doing it in the SPAN element will cause a double-triggered event), we actually have to evaluate the value of the SPAN element itself ("pPeriod" in my example) to determine the selected value.
This is the piece of code:
//Begin function gbDate_onclick
function gbDate_onclick(ctrl) {
// Get selected radio button's value
var vPeriod = IbComposer_getCurrentSelection('pPeriod');
if (vPeriod == 'RANGE') {
// Do range stuff ...
null;
} else {
// Do non-range stuff ...
null;
}
}
//End function gbDate_onclick
Hopefully this will save someone an afternoon of frustrations
By the way, does someone know how to stop the Run/Submit event from running the report?
I need to add a few validations that need to be satisfied before the report runs. I added an 'onclick' event on the Run button that composer automatically creates with the form.
In the event handler I have my validation stuff but as soon as it finishes the target report is still invoked even when using the classic "return false;" statement in the function.
Is there perhaps an IbComposer_xyz function or variable or whatever that can be set to something so the submission stops when needed?
Hopefully I won't have to resort to creating a customized button to handle everything and then use "IbComposer_execute(....)". It's not necessarily "bad" but I may need to implement something similar or the Run Deferred and Scheduled buttons ...
To paraphrase Steve Jobs, Developer Studio HTML Composer is "a bag of hurt".
I'll take a look at your suggestion regarding the radio buttons, meanwhile, here is what I've done for screen validation:
function myOnExecute(form)
{
submitFlag = true;
validateForm();
if (submitFlag)
{
OnExecute(form)
}
}
function validateForm()
{
...
formObject1 = document.getElementById('combobox1');
...
if (formObject1.options[formObject1.selectedIndex].text == '!IBI.AMP.lsel_opt;...')
{
alert('!IBI.AMP.m_sel_reg;');
formObject1.focus();
submitFlag = false;
}
...
Through trial and a Christmas stockingful of error, I discovered there is a difference between an HTML Composer screen designed with and without a form. With a form, you can intercept the submit in a normal fashion. I'll try to dig out my posting about this.
Francis
Give me code, or give me retirement. In FOCUS since 1991
Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
Where and how exactly do you invoke myOnExecute()? As an onclick event from the standard Run button created by HTML composer in the form or through a customized button of your own?
I ask because as soon as I click the Run button, even though my custom onclick event gets executed, the reports proceeds to be generated right after regardless of what I do in the function ... sorry, that behaviour is rather confusing and the only documentation I've found so far about Javascript use in HTML composer has no more than 10 pages and covers barely 6 to 10 functions ... none of them indicating how to intercept form submissions and stop them based on business logic. Just to clarify, I am using a form in the HTML document.
Hmmm, perhaps I have to create an "onsubmit" event in the form control itself and try the validation there with a "return false;" to stop it?
For some reason I thought that the product did not rely on standard form submission as defined by HTML but used instead IBI Javascript functions to parse the parameters, build the URL to invoke WFServlet + parameters and open a new document (window or iframe) using that.
I'll try the onsubmit approach next week to see if it makes a difference anyway.This message has been edited. Last edited by: njsden,
Just to clarify, I am using a form in the HTML document.
Hey Francis, no worries. I am indeed using a form and the link you provided confirmed that I needed to alter the "onsubmit" event and use instead a customized JS function which, after each validation is passed, should call "OnExecute(form);" to continue with the execution of the report -or- "return false;" to abort, and things are much better now.
No need for onclick events on the Run button at all.
I wonder what would happen when "Run Deferred" and the "Schedule" buttons are clicked? do they also cause a form submission and therefore my validation function gets used as well? I'll try to find sometime to test that but it is not a priority right now.