Focal Point Banner


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.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED]Java function won't show up with Embedded JavaScript

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED]Java function won't show up with Embedded JavaScript
 Login/Join
 
Gold member
posted
Hey all!

I've made several attempts but none of them works. I am trying to create a function. So when the selection of radio button change to different value, it will run different animation. However after I add the code to Embedded JavaScript/CSS tab, when I create task to call this JavaScript, nothing show up.

Here's my current code from 'Embedded JavaScript/CSS' tab. Can somebody help me where did I get it wrong?

if(typeof(bRuntime) != 'undefined') {
// TODO: Add your inline runtime code here
}
//Begin function window_onload
function window_onload() {
UpdateData();
// TODO: Add your event handler code here
//add onInitialUpdate() function to make changes before initial run of the reports
}
//End function window_onload
//Begin function check_reporttype
function check_reporttype(){
var report_type = IbComposer_getCurrentSelection('reportselectioncontrol');
if (report_type == 'Measurables'){
IbComposer_runAnimation('ShowMeasurables');
}
else {
IbComposer_runAnimation('HideMeasurables');
}
}
//End function check_reporttype

Thank you

This message has been edited. Last edited by: WebFocusDiver,


WebFOCUS 8.1.05
Windows, All Outputs
 
Posts: 60 | Registered: March 02, 2015Report This Post
Master
posted Hide Post
If you want the animation to happen when the radio button changes, go to the Properties panel, click the yellow lightning bolt, and add "check_reporttype" to the Value Changed box.

You may need to call your function when the window first loads, too.

if(typeof(bRuntime) != 'undefined') {
// TODO: Add your inline runtime code here
}
//Begin function window_onload
function window_onload() {
UpdateData();
// TODO: Add your event handler code here
//add onInitialUpdate() function to make changes before initial run of the reports

//Call function after window has loaded
check_reporttype();
}
//End function window_onload

//Begin function check_reporttype
function check_reporttype(){
var report_type = IbComposer_getCurrentSelection('reportselectioncontrol');
if (report_type == 'Measurables'){
IbComposer_runAnimation('ShowMeasurables');
}
else {
IbComposer_runAnimation('HideMeasurables');
}
}
//End function check_reporttype


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
Gold member
posted Hide Post
I added it to the properties panel. The problem now is when I try to create task say when selection changed, request/actions of JavaScript Call. Under the target type -JavaScript function, there is no function show up. I don't know much about JavaScript. What is missing?

Thanks


WebFOCUS 8.1.05
Windows, All Outputs
 
Posts: 60 | Registered: March 02, 2015Report This Post
Master
posted Hide Post
You do not need to create a task if you add function "check_reporttype" to "Value Changed" in the Properties panel for the radio buttons.

Click on radio buttons first, then go to Properties, then click the yellow lightning bolt. Type in "check_reporttype" in the "Value Changed" box.

When the radio button selection is changed, the check_reporttype function should be called automatically without a task.


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
Gold member
posted Hide Post
Thank you Squatch.

It works now except this one issue. Here is my revised code here
 if(typeof(bRuntime) != 'undefined') {
// TODO: Add your inline runtime code here
}
//Begin function window_onload
function window_onload() {
UpdateData();
// TODO: Add your event handler code here
//add onInitialUpdate() function to make changes before initial run of the reports
//Call function after window has loaded
check_rpttype();
}
//End function window_onload
//Begin function check_rpttype
function check_rpttype(){
var rpt_type = IbComposer_getCurrentSelection('ReportSelectionControl');
if (rpt_type == 'Measurable'){
IbComposer_runAnimation('ShowMeasure');
IbComposer_runAnimation('ShowMeasureDate');
}
else {
IbComposer_runAnimation('ShowCashFlow');
IbComposer_runAnimation('ShowCashFlowDate');
}
}
//End function check_rpttype 


It seems working with load since both 'ShowCashFlow' and 'ShowCashFlowDate' show up. But when I change the radio button selection to 'Measurable', I do expect to see "ShowMeasure" and "ShowMeasureDate" show but it didn't.

I don't know if the condition in if statement really works - I am if the variable does get the value that I selected.

Many thanks in advance


WebFOCUS 8.1.05
Windows, All Outputs
 
Posts: 60 | Registered: March 02, 2015Report This Post
Master
posted Hide Post
Try this code. It will show you what "rpt_type" is:

//Begin function check_rpttype
function check_rpttype(){
var rpt_type = IbComposer_getCurrentSelection('ReportSelectionControl');
alert(rpt_type);
if (rpt_type == 'Measurable'){
IbComposer_runAnimation('ShowMeasure');
IbComposer_runAnimation('ShowMeasureDate');
}
else {
IbComposer_runAnimation('ShowCashFlow');
IbComposer_runAnimation('ShowCashFlowDate');
}
}
//End function check_rpttype 


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
Gold member
posted Hide Post
Thanks.

The value did not get pass to the variable after selection changed. How to fix it?


WebFOCUS 8.1.05
Windows, All Outputs
 
Posts: 60 | Registered: March 02, 2015Report This Post
Master
posted Hide Post
The value is defined in the radio control's Settings panel.

Click on the radio control, then open Settings panel. You should see a "Value" column and a "Display" column.

Value should be "Measurables" for the first radio selection, and some other name for the second radio selection.

if (report_type == 'Measurables'){

The Display can be the same as Value, or it can be different. Display is what the user sees next to the radio controls.

Both radio control selections should be in the same radio control. Do not create two radio controls with one selection in each.

Also, make sure the radio control with both selections has a Unique Identifier of "ReportSelectionControl" in the Properties panel.

var rpt_type = IbComposer_getCurrentSelection('ReportSelectionControl');


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
Gold member
posted Hide Post
I checked all of these and they all correct. Do I switch it to some onclick event or onchange event for radio control?

Thanks


WebFOCUS 8.1.05
Windows, All Outputs
 
Posts: 60 | Registered: March 02, 2015Report This Post
Master
posted Hide Post
The "IbComposer_getCurrentSelection" function is returning the same selection no matter which one I select during my testing. This is strange. I try not to use the IBI functions because of strange behavior like this.

I will post some code that will retrieve the selection the standard way.

When you change selection, do you still get a small window that shows nothing for the selection?

alert(rpt_type);


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
Gold member
posted Hide Post
No. When I change selection, I got the small window that shows the same value before the change (Since i have two values, it shows the default value).

Thanks


WebFOCUS 8.1.05
Windows, All Outputs
 
Posts: 60 | Registered: March 02, 2015Report This Post
Master
posted Hide Post
I get the same thing. Maybe "IbComposer_getCurrentSelection" is not the correct IBI function for a radio control?


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
Master
posted Hide Post
I think I figured it out.

I had mixed results (mostly bad) with the IBI function to get the current selection of the radio control. The reason seems to be that the radio control needs time to update the selections after a new choice has been made.

I don't think this is a problem the vast majority of the time, because radio controls are typically changed before a user clicks on a button to have something run -- plenty of time to update the control before any code checks the new selection. But in this case, an animation needs to run immediately after the radio control has been changed, so we need to give the radio control a little more time.

I did not test this code fully, but I think it is correct (or at least very close to it):

if (typeof(bRuntime) != 'undefined') {
    // TODO: Add your inline runtime code here
}

// Begin function window_onload
function window_onload() {
    UpdateData();

    // TODO: Add your event handler code here
    // add onInitialUpdate() function to make changes before initial run of the reports

    // Call check_reporttype function after window has loaded. This function is
    // normally triggered during a Value Changed event on the radio control. It is
    // called here after the window has opened so that an animation can show for
    // the first time. It is assumed that "Measurables" is the default choice.

    check_reporttype();
}

// Begin function check_reporttype
function check_reporttype() {
    // The following timeout is necessary to give the radio control time to
    // update radio selections to reflect the user's new choice. For a brief
    // time, at least two selections can both be checked until this update is
    // finished.

    setTimeout(
        function() {
            selection_checked();
        },
    150);

    // Note that the timeout now exits immediately, and gives up control of the
    // Value Changed event. The selection_checked function will run 150 milliseconds
    // later (A long delay for a computer if it's not running IE 9).
}

// Begin function selection_checked, which actually does the important work.
function selection_checked() {
    // IBI radio controls consist of a DIV tag with the Unique Identifier of the radio control.
    // Inside the DIV is an HTML table that formats the appearance of the radio selections.
    // INPUT tags of type "radio" are the selections, so we find all of them inside the DIV.

    var rpt_type = document.getElementById('reportselectioncontrol').getElementsByTagName('input');

    // Since we have delayed checking the radio control by 150 milliseconds, it should
    // be safe (Famous last words. Thank you IE 9!) to see which radio selection has been
    // "checked".

    for (var i = 0; i < rpt_type.length; i++) {
        if (rpt_type[i].checked) {
            if (rpt_type[i].value == 'Measurables') {
                IbComposer_runAnimation('ShowMeasurables');
            } else {
                IbComposer_runAnimation('HideMeasurables');
            }
        }
    }
}

Note: I discovered that on Internet Explorer 9, 100 milliseconds is not enough time, so I've changed it to 150 milliseconds.

This message has been edited. Last edited by: Squatch,


App Studio
WebFOCUS 8.1.05M
Windows, All Outputs
 
Posts: 594 | Location: Michigan | Registered: September 04, 2015Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED]Java function won't show up with Embedded JavaScript

Copyright © 1996-2020 Information Builders