Home » Developer & Programmer » Forms » Why Modal window closes?
Why Modal window closes? [message #208503] Mon, 11 December 2006 02:11 Go to next message
wency
Messages: 450
Registered: April 2006
Location: Philippines
Senior Member

I'm validating an item on key_commit of my form. The problem is when I call show_window (window set to modal=Yes) with stack canvas in it, it only appear for about 3 seconds after I clicked message that is placed after calling window and then disappear without waiting any response from the user.
When no message after, it doesn't show.

[Updated on: Mon, 11 December 2006 02:23]

Report message to a moderator

Re: Why Modal window closes? [message #208673 is a reply to message #208503] Mon, 11 December 2006 21:10 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
I suggest doing the validation in the When-Validate triggers and if you need to go to another item, for example on another window, then use a timer to do the navigation.

David
Re: Why Modal window closes? [message #209444 is a reply to message #208503] Thu, 14 December 2006 20:44 Go to previous messageGo to next message
wency
Messages: 450
Registered: April 2006
Location: Philippines
Senior Member

I did, it's running fine but I encountered a bug.
On validate I check whether date was changed or not.
If changed then the pop-up window appear. If the user choose cancel then the date restore the original date.

Now, when I changed the date den press F10,
the window pops up, but if I choose cancel,
the new date was saved to database. Seems like it was saved before I rstore the orig date. I wonder how it happnes cause I understand, the when-validate-item fires first before the commit.
Re: Why Modal window closes? [message #209780 is a reply to message #209444] Sun, 17 December 2006 20:24 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Please post the code (use 'code' tags) and say from which trigger AND item they came.

David
Re: Why Modal window closes? [message #209791 is a reply to message #208503] Sun, 17 December 2006 20:52 Go to previous messageGo to next message
wency
Messages: 450
Registered: April 2006
Location: Philippines
Senior Member

I call this proc on when-validate
CHECK_DT_CHANGE;


proc CHECK_DT_CHANGE:
PROCEDURE CHECK_DT_CHANGE IS
  v_due_dt	invstgtn_rep.due_dt%TYPE;
  v_timer         TIMER;  

BEGIN

   If variables.v_dt_instance = 'Y' Then --check if date touched

  Begin
    SELECT due_dt
      INTO v_due_dt
        FROM invstgtn_rep
        WHERE ref_year = :invstgtn_rep.ref_year
        AND ref_no = :invstgtn_rep.ref_no
        AND hist_seq_no = :invstgtn_rep.hist_seq_no
	AND line_cd = :invstgtn_rep.line_cd
	AND subline_cd = :invstgtn_rep.subline_cd
	AND iss_cd = :invstgtn_rep.iss_cd
	AND clm_yy = :invstgtn_rep.clm_yy
	AND clm_seq_no = :invstgtn_rep.clm_seq_no;
     EXCEPTION
     WHEN NO_DATA_FOUND Then
     v_due_dt := null;
  End;

	variables.v_orig_due_dt := v_due_dt;

	   If v_due_dt <> :invstgtn_rep.dsp_due_dt Then
	    v_timer := Find_Timer('DUE_DT_TIMER');	
	     IF Id_Null(v_timer) THEN    
		v_timer := create_timer('DUE_DT_TIMER',1,NO_REPEAT); 
	     END IF; 	
	   End If;

   End If;

END;



proc CHECK_DT_CHANGE2:
PROCEDURE CHECK_DT_CHANGE2 IS
  cur_item         VARCHAR2(100);

BEGIN

   cur_item := :system.cursor_item;

	      If UPPER(:SYSTEM.CURRENT_BLOCK) <> 'INVSTGTN_REP' Then
	    	go_block('invstgtn_rep');
		go_item('invstgtn_rep.dsp_due_dt');
	    	--go_block('reason2');
	      go_block('invstgtn_hdr');
	      go_item('invstgtn_hdr.ref_no');
	       show_view('main1');
	       show_view('main3');
	       show_view('main2');
	       hide_view('injury_can');
	       hide_view('inspect_can');
	      End If;

		show_window('reason');
		--show_view('reason');
		go_item('reason2.reason');

		--RAISE FORM_TRIGGER_FAILURE;

		variables.v_item := 'reason2.reason';


        variables.v_dt_instance:='N';

	variables.v_item := null;

END;



code for window OK button:
DECLARE
  v_cur_blk         VARCHAR2(100);
Begin
  v_cur_blk := :SYSTEM.CURRENT_BLOCK;

  If :reason2.reason is NULL Then
	message('Please specify reason for change of due date');
	message('Please specify reason for change of due date');
  Else
	--hide_view('reason');
	hide_window('reason');
     If variables.v_save = 'Y' Then
	Commit;
	go_block('invstgtn_dtls');
	execute_query;
	variables.v_save := 'N';
     End If;
	--go_block('invstgtn_hdr');
	--execute_query;
	go_item('invstgtn_rep.dsp_due_dt');
  End If;

--  go_block(v_cur_blk);  
End;


code for window CANCEL button:
:invstgtn_rep.dsp_due_dt := variables.v_orig_due_dt;
--hide_view('reason');
hide_window('reason');
go_item('invstgtn_rep.dsp_due_dt');



-->edit
I call CHECK_DT_CHANGE2 on when-timer-expired

[Updated on: Sun, 17 December 2006 20:53]

Report message to a moderator

Re: Why Modal window closes? [message #209999 is a reply to message #209791] Mon, 18 December 2006 20:33 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
What does F10 do on your system? Where is 'variables.v_save' set to 'Y'? Why do you use a 'select' to get 'v_due_dt' instead of getting it as another item in the 'invstgtn_rep' block (you can mark it as 'Update Allowed'='No')? Have you considered using 'get-item_property(database_value)' to fetch the 'old' value?

David
Re: Why Modal window closes? [message #210001 is a reply to message #208503] Mon, 18 December 2006 21:30 Go to previous messageGo to next message
wency
Messages: 450
Registered: April 2006
Location: Philippines
Senior Member

1) F10 = commit
2) 'variables.v_save' set to 'Y' on form key-commit
3) I use v_due_dt to know if date was altered by the user.
4) Im not used to it, I think it's always safe to fetch from table.
Re: Why Modal window closes? [message #210029 is a reply to message #210001] Tue, 19 December 2006 00:50 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Doh! Put a 'raise form_trigger_failure' at the end of the 'Cancel' button code otherwise the form will continue processing into the 'Commit' trigger.

David
Re: Why Modal window closes? [message #210049 is a reply to message #208503] Tue, 19 December 2006 02:30 Go to previous messageGo to next message
wency
Messages: 450
Registered: April 2006
Location: Philippines
Senior Member

The problem is that the 'when-validate-item only fires after executing the codes from form 'key-commit'. As I understand, 'when-validate-item' must fire first. Anyway I adjust my code to this situation and it's now running fine. I'm testing for some loopholes. Razz
Re: Why Modal window closes? [message #210207 is a reply to message #210049] Tue, 19 December 2006 18:49 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
I believe that the 'when-validate' fires before the key-commit. Put 'message/pause' pairs into the two triggers and see which fires first.

David
Re: Why Modal window closes? [message #210213 is a reply to message #208503] Tue, 19 December 2006 19:55 Go to previous messageGo to next message
wency
Messages: 450
Registered: April 2006
Location: Philippines
Senior Member

I did it but messages on key-commit displayed first.
Anyway I'm leaving this headache, I'm done testing and it's running perfectly.
thank you.
Re: Why Modal window closes? [message #210217 is a reply to message #210213] Tue, 19 December 2006 20:10 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
At what level or on which item/record/block/form do you have this(these) key-commit trigger(s)?

David
Re: Why Modal window closes? [message #210224 is a reply to message #208503] Tue, 19 December 2006 21:53 Go to previous message
wency
Messages: 450
Registered: April 2006
Location: Philippines
Senior Member

I have plenty of blocks, around 50. The item i'm validating is for example on block3 and doest contain key-commit. The master of block3 is block2 which has key-commit. Then form has key-commit.

The form key-commit fire first before the validate of item in block3. key-commit on block2 doesn't fire because i'm only working on items of block3.
Previous Topic: Transforming a data block into a control block without doing it one by one
Next Topic: Urgent: problem in if-else statment.
Goto Forum:
  


Current Time: Fri Sep 20 15:38:09 CDT 2024