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     [SOLVED] Event handling in webfocus maintain.

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Event handling in webfocus maintain.
 Login/Join
 
Guru
posted
Hi All,
I am using webfocus maintain to generate a form.In my form,I have a HTML table which is getting populated by datasource EMPDATA.In that form I want to add another column which gives user option to Approve/Reject a particular employee.For that, every row would have a combobox in the newly added column.User can simply select (Approve/Reject) from the dropdowns present in each cell of the new added column.Simultaneously , As user select a particular value,I want to update a column in datasource EMPDATA with the flag value Y/N based on the selection so that user gets the same values next time he logs in.
Any suggestion or reference would be very helpful.

Thanks in advance.

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


WF 8.1.04,Windows 7,
DataBase: Oracle 11g,Output :Excel,PDF,HTML
 
Posts: 281 | Location: India | Registered: April 21, 2007Report This Post
Guru
posted Hide Post
Can anybody help me regarding this?

Thanks.


WF 8.1.04,Windows 7,
DataBase: Oracle 11g,Output :Excel,PDF,HTML
 
Posts: 281 | Location: India | Registered: April 21, 2007Report This Post
Master
posted Hide Post
Here is the code you need. This assumes that you have a field in your Master called ANSWER that will store the value selected from the List box. After you load the stack you loop and add an HTML Column to that stack with the drop down values of blank, reject and approve. We can also preselect the value depending on the value from the database. That's the x1 and x2 values.

When you place this column in the HTMLTable, edit the column and do 2 things. First change the width in characters to 10 and second, change the content type to 1-HTML. That will do it.

Mark


MAINTAIN FILE empdata

$$Declarations

Case Top
for 10 next pin into stk
compute i/i2=1;
repeat stk.foccount
compute x1/a10 ='';
compute x2/a10='';
if stk(i).answer = 'Approve' then
Compute x1 = 'selected';
else if stk(i).answer = 'Rejected' then
Compute x2 = 'selected';

compute stk(i).app/a200 =
"< select name=list " || I || ">" |
" < option value=' '> " |
" < option value='Approve'" || x1 || ">Approve " |
" < option value='Reject'" || x2 || " >Reject " ;
compute i=i+1;
endrepeat
Winform Show Form1;
EndCase

case saver
compute i=1;
repeat stk.foccount
Compute Stk(I).answer = Form1.GetHTMLField('list' || I);
Update Answer from Stk(i);
compute i=i+1;
endrepeat
endcase

END

Please note that I had to include a space after the < character to make this display here properly. You will remove them when you enter your code.

This message has been edited. Last edited by: Maintain Wizard,
 
Posts: 663 | Location: New York | Registered: May 08, 2003Report This Post
Guru
posted Hide Post
Hi,
This is pretty much which i wanted.Thanks for your reply.One more question i have regarding this is when i am calling "saver" function(I am also calling other functions from javascript which directly updates data oracle database by using SYS_MGR.ENGINE ) in my javascript function OnHTMLTable_ClickLink ( ) by using
 IWCTrigger("saver"); 

Whole page is getting refreshed every time i click on the HTML table and all the values in dropdowns are reset to blank.What can be the possible reason for this?

Thanks.


WF 8.1.04,Windows 7,
DataBase: Oracle 11g,Output :Excel,PDF,HTML
 
Posts: 281 | Location: India | Registered: April 21, 2007Report This Post
Master
posted Hide Post
The values in the HTMLTable dropdowns are static. When you perform a Maintain case we reload the page and thus reset those values. However, if you reload the values from the database, the x1 and x2 values should preset the lists again.

Mark
 
Posts: 663 | Location: New York | Registered: May 08, 2003Report This Post
Guru
posted Hide Post
Thanks a lot.It worked for me.

Regards.


WF 8.1.04,Windows 7,
DataBase: Oracle 11g,Output :Excel,PDF,HTML
 
Posts: 281 | Location: India | Registered: April 21, 2007Report This Post
Guru
posted Hide Post
Hi,
I am again facing some issue while updating the empdata by calling saver function from javascript OnHTMLTable_ClickLink ( ).My javascript looks like :

 
function OnHTMLTable1_ClickLink ( )  {
var irows = document.getElementsByTagName("tr").length ;
for(K=1; k<=irows; k++)    
{
if(document.getElementById("list"+k).selectedIndex == 1)
{
document.getElementById("list"+k).options[1].style.backgroundColor = "green"; 
}
if(document.getElementById("list"+k).selectedIndex == 2)
{
document.getElementById("list"+k).options[2].style.backgroundColor = "Red"; 
}
IWCTrigger("saver");
IWCTrigger("Display");
}
}


Here I am actually coloring the dropdown cells based on the selection by user (Green for Approve and Red for Reject).Then I call saver function to update the datasource.The saver function is as below:
 
case saver
compute i=1;
repeat stk.foccount
Compute stk(I).answer = From1.GetHTMLField('list' || I);
Update empdata.answer from stk(i);
compute i=i+1;
endrepeat
Endcase


After that I call Display function to reload the values from database and display it again in the HTMLTable1.My Display function looks like :
 
case Display
for all next pin into stk
compute i/i2=1;
repeat stk.foccount
compute x1/a10 ='';
compute x2/a10='';
if stk(i).answer = 'Y' then
Compute x1 = 'selected';
else if stk(i).answer = 'N' then
Compute x2 = 'selected'; 

compute stk(i).app/a200 = 
"<select name=list " || I || ">" |
"<option value=' '> " |
"<option value='Y'" || x1 || ">Approve " |
"<option value='N'" || x2 || ">Reject " ;
compute i=i+1;
endrepeat
EndCase


The problem is when I am going to change the values in the dropdown,It is not giving me enough time to select the value and get refreshed instantly with previous values.Can you please suggest where this code is misbehaving?

Thanks.


WF 8.1.04,Windows 7,
DataBase: Oracle 11g,Output :Excel,PDF,HTML
 
Posts: 281 | Location: India | Registered: April 21, 2007Report This Post
Guru
posted Hide Post
Can anybody reply to this please?

Thanks.


WF 8.1.04,Windows 7,
DataBase: Oracle 11g,Output :Excel,PDF,HTML
 
Posts: 281 | Location: India | Registered: April 21, 2007Report This Post
Virtuoso
posted Hide Post
This is very basic maintain logic. You cannot have 2 IWCTrigger events called from javascript. The first call to IWCTrigger calls the maintain and leaves the form. The 2nd IWCTrigger cannot then be called.

Call the Display case from saver case if that is what is required.


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Master
posted Hide Post
There are a couple of things here to watch out for. Alan is correct as when you use IWCTRIGGER to return from your JS event to the Maintain code, you cannot perform another. So, in your SAVER code, you should perform DISPLAY.

case saver
compute i=1;
repeat stk.foccount
Compute stk(I).answer = From1.GetHTMLField('list' || I);
Update empdata.answer from stk(i);
compute i=i+1;
endrepeat
PERFORM DISPLAY
Endcase

But, be careful. Since you have ALREADY performed display you have to reset the stack and the database. So, at the beginning of display you should have:

case Display
stack clear stk
reposition PIN
for all next pin into stk
...


If you don't clear the stack and reposition, you will not get the correct results.

Mark
 
Posts: 663 | Location: New York | Registered: May 08, 2003Report This Post
Guru
posted Hide Post
Hi,
I tried with what you suggested but iam still facing same issue.My new maintain function looks like:


MAINTAIN FILE empdata

$$Declarations

Case Top
Infer empdata.EMPDATA.PIN into Stk;

Reposition empdata.EMPDATA.PIN ;
Stack clear Stk ;

Perform Display( );

Winform Show Form1; 
EndCase

case Display
stack clear stk
reposition PIN
for all next pin into stk
compute i/i2=1;
repeat stk.foccount
compute x1/a10 ='';
compute x2/a10='';
if stk(i).answer = 'Y' then
Compute x1 = 'selected';
else if stk(i).answer = 'N' then
Compute x2 = 'selected'; 

compute stk(i).app/a200 = 
"<select name=list " || I || ">" |
"<option value=' '> " |
"<option value='Y'" || x1 || ">Approve " |
"<option value='N'" || x2 || ">Reject " ;
compute i=i+1;
endrepeat
EndCase
case saver
compute i=1;
repeat stk.foccount
Compute stk(I).answer = Form1.GetHTMLField('list' || I);
Update empdata.answer from stk(i);
compute i=i+1;
endrepeat
Perform Display( );
Endcase
END


And My JS looks like:

 
function OnHTMLTable1_ClickLink ( )  {

var irows = document.getElementById("HTMLTable1").getElementsByTagName('tr');
var iRowCount = irows.length;

for(i=1; i<=iRowCount; i++)    
{
if(document.getElementById("list"+i).selectedIndex == 1)
{
document.getElementById("list"+i).options[1].style.backgroundColor = "green"; 
}
if(document.getElementById("list"+i).selectedIndex == 2)
{
document.getElementById("list"+i).options[2].style.backgroundColor = "Red"; 
}
}
IWCTrigger("Display");
}


Still When I am going to select dropdown values,It is not giving me enough time to select the value and get refreshed instantly.Update statements are getting fired but for all the rows in HTML table but with the same previous values and hence the new form which is displayed hold same old values.Please help with the above issue.

Thanks.
 
Posts: 281 | Location: India | Registered: April 21, 2007Report This Post
Guru
posted Hide Post
One correction

IWCTrigger("saver"); instead of IWCTrigger("Display"); in js function OnHTMLTable1_ClickLink ().

Thanks.


WF 8.1.04,Windows 7,
DataBase: Oracle 11g,Output :Excel,PDF,HTML
 
Posts: 281 | Location: India | Registered: April 21, 2007Report This Post
Virtuoso
posted Hide Post
Ok, I think I see. You have declared the cells in the table as having an event handler. So as soon as you click the mouse on that cell, the event fires. You need the event on the select, normally an onchange event would work.

This would have to be manually coded into the select itself, and remove the event on the HTML table itself.


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Master
posted Hide Post
Please send me your MNT file and repro instructions. I'll see what you are getting and how to get to where you want to be:
Mark _Derwin@ibi.com

Mark
 
Posts: 663 | Location: New York | Registered: May 08, 2003Report This Post
Guru
posted Hide Post
Hi Mark,
My MNT file is as:

MAINTAIN FILE empdata

$$Declarations

Case Top
Infer empdata.EMPDATA.PIN into stk;
Display( );
Winform Show Form1; 
-* Replace the Winform Show command with the following code
-* when to display your form in a non-persistent state
-* Winform Show_And_Exit Form1;
EndCase

Case Display
Reposition empdata.EMPDATA.PIN ;
Stack clear stk ;
For all next empdata.EMPDATA.PIN into stk ;

compute i/i2=1;
repeat stk.foccount
compute x1/a10 ='';
compute x2/a10='';
if stk(i).Midinitial = 'Y' then
Compute x1 = 'selected';
else if stk(i).Midinitial = 'N' then
Compute x2 = 'selected';

compute stk(i).app/a200 = 
"<select name=list " || I || ">" |
"<option value=' '> " |
"<option value='Y'" || x1 || ">Approve " |
"<option value='N'" || x2 || ">Reject " ;
compute i=i+1;
endrepeat

EndCase


case saver
compute i=1;
repeat stk.foccount
Compute stk(i).Midinitial = Form1.GetHTMLField('list' || i);
Update empdata.EMPDATA.Midinitial from stk(i);
compute i=i+1;
endrepeat
Display( );
endcase

END
  


And My Javascript function is as:

  
function OnHTMLTable1_ClickLink ( )  {
var irows = document.getElementsByTagName("tr").length ;
for(k=1; k<=irows; k++)    
{
if(document.getElementById("list"+k).selectedIndex == 1)
{
document.getElementById("list"+k).options[1].style.backgroundColor = "green"; 
}
if(document.getElementById("list"+k).selectedIndex == 2)
{
document.getElementById("list"+k).options[2].style.backgroundColor = "Red"; 
}
}
IWCTrigger("saver");
}


Here I am just displaying some column from EMPDATA source in HTMLTable1 alongwith a new computed column "app" which will show a combobox in each row of the table.Each combobox has two values 'Approve' and 'Reject'.As user select any one of the values from Maintain screen "Midinitial" column of datasource EMPDATA should be updated with Y or N flag values (handled in 'saver' function)for Approve and Reject respectively and the screen should also updated simultaneously (which is handled in 'Display' function).Also,When user login next time he should see the dropdown values as 'Approve/Reject' as per the updated value of 'Midinitial' column of EMPDATA.
The color of dropdown should be turned on to 'GREEN' for 'Approved' and 'RED' for 'Reject' which is handled in OnHTMLTable1_ClickLink javascript function(This feature is also not working for me).After which I am calling 'saver' function to update the datasource and display the updated values on the screen.
The problem is when I am going to change the values in the dropdown,It is not giving me enough time to select the value and get refreshed instantly with previous values (as stored in datasource column 'Midinitial').Can you please have a look into this and let me know if you need any further details regarding this.

Thanks.


WF 8.1.04,Windows 7,
DataBase: Oracle 11g,Output :Excel,PDF,HTML
 
Posts: 281 | Location: India | Registered: April 21, 2007Report This Post
Master
posted Hide Post
Please zip up the files and send them to me. It's easier than me having to recreate your files here.

Mark
 
Posts: 663 | Location: New York | Registered: May 08, 2003Report This Post
Guru
posted Hide Post
Hi Mark,
Actually my company policy does not allow me to send mails with attachment outside it.I hope you understand that.Can you please have a look over the piece of code above and advcie accordingly?

Thanks.


WF 8.1.04,Windows 7,
DataBase: Oracle 11g,Output :Excel,PDF,HTML
 
Posts: 281 | Location: India | Registered: April 21, 2007Report This Post
Virtuoso
posted Hide Post
Shankar

I assume that your company policy also restricts the training budget!

Anyway. Start by creating a file test.js. Put this in:
function selectChange ( )  {
  IWCTrigger("saver");
}

function initialSelectChange ( )  {
  var irows = document.getElementsByTagName("tr").length ;
  for(k=1; k<irows; k++) {
    if(document.getElementById("list"+k).selectedIndex == 1) {
      document.getElementById("list"+k).options[1].style.backgroundColor = "green"; 
    }
    if(document.getElementById("list"+k).selectedIndex == 2) {
      document.getElementById("list"+k).options[2].style.backgroundColor = "Red"; 
    }
  }
}

function addEvent(obj, evType, fn){
  if (obj.addEventListener){
    obj.addEventListener(evType, fn, true);
    return true;
  } else if (obj.attachEvent){
    var r = obj.attachEvent("on"+evType, fn);
    return r;
  } else {
    return false;
 }
}
addEvent(window, 'load', initialSelectChange);


In your maintain:
MAINTAIN FILE empdata

$$Declarations

Case Top

stk.app/a0;

getData();

Display();

Winform Show Form1; 

EndCase

Case Display
Declare (i/i4;x1/a0;x2/a0);

  repeat stk.foccount i = 1;

    if stk(i).Midinitial eq 'Y' begin
      x1 = 'selected' ;
      x2 = '';
    endbegin else
    if stk(i).Midinitial eq 'N' begin
      x1 = '';
      x2 = 'selected';
    endbegin else
    if stk(i).Midinitial eq ' ' begin
      x1 = '';
      x2 = '';
    endbegin	

    stk(i).app = "<select name=list " || I || " onchange='selectChange()'>" |
                 "<option value=' '> " |
                 "<option value='Y'" || x1 || ">Approve " |
                 "<option value='N'" || x2 || ">Reject " ;
  
  endrepeat i = i + 1;

EndCase

case saver
Declare (i/i4;);

  repeat stk.foccount i = 1;
    stk(i).Midinitial = Form1.GetHTMLField('list' || i);
  endrepeat i = i+1;

  For all update empdata.EMPDATA.Midinitial from stk;

  Display();

endcase

case getData

  Reposition empdata.EMPDATA.PIN ;

  Stack clear stk ;

  For all next empdata.EMPDATA.PIN into stk ;

endcase

END


Link the test.js file to the maintain form, Form1. Do this by dragging from other in 'Exploring - developer Studio Desktop…' (Not project Explorer on the Left) onto Form1. When prompted click Link. (Mark isn't there a better way of doing it, I know I cheat, but it's not official).

The onchange event is on the selects, not the Table row. So you need to remove the event handler for the table link.

Then run.

Because you are running persistent, there is no need to retrieve the data on every call, just update. The Stack is in sync with the data anyway. In the real world you would only update the one changed row at a time, but that gets more complicated.

I've tidied your code a bit.

Please take some training.


Alan.
WF 7.705/8.007
 
Posts: 1451 | Location: Portugal | Registered: February 07, 2007Report This Post
Guru
posted Hide Post
Hi Alan,
I am not able to link js file to Form1.It is not allowing me to drag test.js to Form1 in 'Exploring - developer Studio Desktop..'. Is there any other way to link js to maintain form?

Thanks.


WF 8.1.04,Windows 7,
DataBase: Oracle 11g,Output :Excel,PDF,HTML
 
Posts: 281 | Location: India | Registered: April 21, 2007Report This Post
Guru
posted Hide Post
Thanks Alan.I got it how to do it.


WF 8.1.04,Windows 7,
DataBase: Oracle 11g,Output :Excel,PDF,HTML
 
Posts: 281 | Location: India | Registered: April 21, 2007Report 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     [SOLVED] Event handling in webfocus maintain.

Copyright © 1996-2020 Information Builders