Précédent   Forum des professionnels en informatique > Bases de données > Oracle > Outils > Forms
Forms Forum d'entraide sur Oracle Forms
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 14/06/2006, 14h45   #1
Membre habitué
 
Inscription : avril 2004
Messages : 365
Détails du profil
Informations forums :
Inscription : avril 2004
Messages : 365
Points : 121
Points : 121
Par défaut [Forms-PJC]Les events en dehors de mon wrapper

Bonjour,

Comment executer les evenements java avec les pjc ?

Mon package contient 2 classes java

Ma classe java à manipuler qui contient les méthodes, variables, actionlisteners
Mon wrapper, contion les ID, les set, get, dispathevent et une instance de ma classe java.

Normalement pour executer un evenement dans les pjc j'utilise la méthode suivante contenue dans mon Wrapper:
Code :
1
2
3
4
5
6
7
8
9
10
11
12
 
  private static final ID MOUSEDOWN = ID.registerProperty("MOUSE_DOWN");       
  ...
 
  public void dispatch_event( ID id )
  {
      CustomEvent ce = new CustomEvent(mHandler, id);
      dispatchCustomEvent(ce);
  }
  ...
 
  dispatch_event( MOUSEDOWN )
Ma question est comment faire cette operation en dehors du wrapper. C'est à dire dans la classe que je vais instancier.
Le problèmre est que dans ce cas on ne déclare pas les ID et mHandler, donc comment faire ?

merci
patmaba est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 14/06/2006, 15h14   #2
Rédacteur

 
Avatar de SheikYerbouti
 
Inscription : mai 2003
Messages : 6 530
Détails du profil
Informations forums :
Inscription : mai 2003
Messages : 6 530
Points : 6 460
Points : 6 460
Qu'est-ce qui vous empêche d'appeler une fonction de la classe A (wrapper) depuis une classe B ?
__________________
Rédacteur Oracle (Oracle ACE)
Guide Oracle ,Guide PL/SQL, Guide Forms 9i/10g, Index de recherche
Je ne réponds pas aux questions techniques par MP
Blogs: Forms-PL/SQL-J2EE - Forms Java Beans
SheikYerbouti est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 14/06/2006, 15h38   #3
Membre habitué
 
Inscription : avril 2004
Messages : 365
Détails du profil
Informations forums :
Inscription : avril 2004
Messages : 365
Points : 121
Points : 121
C'est çà le problème, je désire appeler dispatch_event.

Comment le feriez-vous ?
patmaba est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 14/06/2006, 16h05   #4
Rédacteur

 
Avatar de SheikYerbouti
 
Inscription : mai 2003
Messages : 6 530
Détails du profil
Informations forums :
Inscription : mai 2003
Messages : 6 530
Points : 6 460
Points : 6 460
N'appelez pas directement dispatch_event. placez-la dans une fonction de la classe wrapper et appelez cette fonction.
__________________
Rédacteur Oracle (Oracle ACE)
Guide Oracle ,Guide PL/SQL, Guide Forms 9i/10g, Index de recherche
Je ne réponds pas aux questions techniques par MP
Blogs: Forms-PL/SQL-J2EE - Forms Java Beans
SheikYerbouti est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/06/2006, 09h22   #5
Membre habitué
 
Inscription : avril 2004
Messages : 365
Détails du profil
Informations forums :
Inscription : avril 2004
Messages : 365
Points : 121
Points : 121
J'ai remis tous le code dans le wrapper a présent.

Je reçoit un problème lors du dispatching de l'evenenement.

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Exception occurred during event dispatching:
 
java.lang.IllegalArgumentException: NULL source
 
	at java.util.EventObject.<init>(Unknown Source)
 
	at oracle.forms.ui.CustomEvent.<init>(Unknown Source)
 
	at cadtest20060320.CADViewerWrapper6.dispatch_event(CADViewerWrapper6.java:276)
 
	at cadtest20060320.CADViewerWrapper6.HandleEventFromRemote(CADViewerWrapper6.java:299)
 
	at com.cadviewer.ViewerCanvas_core.handleEvent(ViewerCanvas_core.java:2398)
 
	at java.awt.Component.postEvent(Unknown Source)
 
	at java.awt.Component.dispatchEventImpl(Unknown Source)
 
	at java.awt.Component.dispatchEvent(Unknown Source)
 
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
 
	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
 
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
 
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
 
	at java.awt.EventDispatchThread.run(Unknown Source)
Il me semble que je fait bien les choses.
patmaba est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/06/2006, 09h30   #6
Rédacteur

 
Avatar de SheikYerbouti
 
Inscription : mai 2003
Messages : 6 530
Détails du profil
Informations forums :
Inscription : mai 2003
Messages : 6 530
Points : 6 460
Points : 6 460
Citation:
Envoyé par patmaba
Il me semble que je fait bien les choses.
Pas vraiment. Ce n'est pas la première fois que je vous demande de fournir un peu plus de matériel. Vous semblez toujours persuadé que l'on va "deviner" le code qui génère vos erreurs.
ça devient fatiguant...
__________________
Rédacteur Oracle (Oracle ACE)
Guide Oracle ,Guide PL/SQL, Guide Forms 9i/10g, Index de recherche
Je ne réponds pas aux questions techniques par MP
Blogs: Forms-PL/SQL-J2EE - Forms Java Beans
SheikYerbouti est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/06/2006, 10h09   #7
Membre habitué
 
Inscription : avril 2004
Messages : 365
Détails du profil
Informations forums :
Inscription : avril 2004
Messages : 365
Points : 121
Points : 121
Le code source complet du code java est le suivant :

L'endroit ou le problème à lieu est lors de l'appel à dispatch_event par
public void HandleEventFromRemote.

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
 
package cadtest20060320;
 
import sun.misc.BASE64Encoder;
import sun.misc.BASE64Decoder;
import javax.swing.*;
import java.awt.FileDialog;
import java.awt.Frame;
import java.awt.Button;
import java.awt.*;
import java.awt.event.*;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.util.zip.*;
import java.util.StringTokenizer;
import java.io.*;
import java.beans.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.net.*;
 
import javax.swing.filechooser.*;
 
import oracle.forms.ui.VBean;
import oracle.forms.ui.CustomEvent;
import oracle.forms.handler.IHandler;
import oracle.forms.properties.ID;
 
import oracle.ewt.meter.ProgressBar;
import oracle.ewt.meter.BoundedRangeModelImpl;
import oracle.ewt.thread.TaskScheduler;
import oracle.ewt.thread.Task;
import oracle.ewt.thread.TaskEvent;
import java.beans.PropertyChangeSupport;
 
import com.cadviewer.*;
 
 
 
 
public class CADViewerWrapper6 extends VBean 
	implements RemoteListener
{
 
	private static final ID time  = ID.registerProperty   ("time");
	private static final ID value = ID.registerProperty   ("val");
	public static final  ID changeEvent = ID.registerProperty ("CHANGE");
 
	public static final  ID setinit = ID.registerProperty ("INIT");			
	public static final  ID setcodebase = ID.registerProperty ("SETCODEBASE");				
 
    public static final  ID getmousex = ID.registerProperty ("GETMOUSEX");
	public static final  ID getmousey = ID.registerProperty ("GETMOUSEY");
 
	private int vx,vy,vw,vh;
	public static final  ID setviewx = ID.registerProperty ("SETVIEWX");
	public static final  ID setviewy = ID.registerProperty ("SETVIEWY");
    public static final  ID setviewwidth  = ID.registerProperty ("SETVIEWWIDTH");
	public static final  ID setviewheight = ID.registerProperty ("SETVIEWHEIGHT");	
	public static final  ID centerview = ID.registerProperty ("CENTERVIEW");
 
    public static final  ID getviewwidth  = ID.registerProperty ("GETVIEWWIDTH");
	public static final  ID getviewheight = ID.registerProperty ("GETVIEWHEIGHT");
 
    protected static final ID MOUSEDOWN = ID.registerProperty("MOUSE_DOWN");        
 
	static IHandler mHandler;
	private Component mComp;
 
    ViewerAWT cadv=NULL;
 
    private String thecodebasedir = "D:\\CV_AWT_SNCB2006_03_15\\";
    private Container contentpane ;
 
 
 
	public void init(IHandler handler) {
		try {		
  			System.out.println("__START CadWrapper public void init");
        	// InfoSystem();
  			System.out.println("  super.init(handler)");
  			super.init(handler);  			
        	System.out.println("  mHandler = handler");
  			mHandler = handler;  		  		  			
  			System.out.println("__END CadWrapper public void init");
  		}
		catch (Exception e) {
			System.out.println("__EXCEPTION CadWrapper public void init");
  			e.printStackTrace();
  		}  		 
 
  	}
 
 
 
 
 
	public CADViewerWrapper6() {
 
 
 
		super();
        contentpane = this ;		        
 
    	try {
 
    	   Msg("_____START CADViewerWrapper6() constructor_____");
 
           InitViewer("D:\\CV_AWT_SNCB2006_03_15\\",		   				 
		   				 "file:///d:/acad_B/es/cat/STIP/Extract/410009.dwf");		
 
		   this.ADD(cadv.GetViewerPanel());
		   this.setVisible(true);
		   this.setEnabled(true);
 
		   Msg("_____END CADViewerWrapper6() constructor_____");     	   		   
 
		}
		catch (Exception e) {
  			e.printStackTrace();
  		}  		 
}
 
 
 
 
 
	//SET the delay time FOR the timer
  	public BOOLEAN setProperty(ID pid, Object value) {
		try {			
			IF ( value != NULL ) {			
				IF ( pid  == setcodebase ) {
					thecodebasedir = String.valueOf(value);
					System.out.println("thecodebasedir="+thecodebasedir);
					RETURN true;
				}								
 
			    IF ( pid  == setinit ) {
  				   System.out.println("setProperty pid  == setinit ");			    	
				   String cad_file = String.valueOf(value); 
				   RETURN true;
			    }											
 
				IF ( pid  == setviewx ) {					
					vx = ((Integer)value).intValue();
					RETURN true;
				}								
				IF ( pid  == setviewy ) {					
					vy = ((Integer)value).intValue();
					RETURN true;
				}								
				IF ( pid  == setviewwidth ) {					
					vw = ((Integer)value).intValue();
					RETURN true;
				}								
				IF ( pid  == setviewheight ) {					
					vh = ((Integer)value).intValue();
					RETURN true;
				}											    
			}							
 
  		    IF ( pid  == centerview ) {					  		         		    
			   cadv.centerViewOn_DWG( vx, vy, vw, vh );			   
			   RETURN true;
			}								
 
		}
		catch( Exception e ) {
			System.out.println("Exception dans setProperty : " + e);
		}
 
 
		RETURN super.setProperty(pid, value);
  	}
 
 
 
 
 
 
 
 
 
	//IF the value CHANGE, send a msg
  	public Object getProperty(ID pid) {		
    	try {    		  	    
 
 			IF (pid==getmousex) {
            	String val;
            	val = Double.toString(cadv.getUnitsX());
            	RETURN val;
   			}
 
 			IF (pid==getmousey) {
            	String val;
            	val = Double.toString(cadv.getUnitsY());
            	RETURN val;
   			}
 
 			IF (pid==getviewwidth) {
            	String val;
            	val = Integer.toString(cadv.getViewWidth());
            	RETURN val;
   			}
 
 			IF (pid==getviewheight) {
            	String val;
            	val = Integer.toString(cadv.getViewHeight());
            	RETURN val;
   			}
 
 
   			RETURN "";   				
    	}
    	catch( Exception e ) {
    		e.printStackTrace();
    		RETURN NULL;
    	}   		
	}
 
    public void Msg( String s ) {
    	System.out.println(s);
    }
 
 
 
 
	public void InitViewer(String codebase, String pFile ) {	
		try
		{
            cadv = new ViewerAWT(codebase);
 
            URL url = new URL(pFile);
 
            byte[] arr = cadv.getData(url);            
            cadv.OpenFile(arr);
 
            Panel p = new Panel();
 
            setSize(1000,500);
			cadv.addActionListener((RemoteListener)this);
 
			/*
    			Get Viewer AWT Panel
			*/
            p = cadv.GetViewerPanel();
            ADD(p,BorderLayout.CENTER);
 
 
		}
		catch(Exception io)
		{
			//new MessagePanel(viewerControls.GetMessage("ERROR"),viewerControls.GetMessage("Cannot create parser")+": "+io.toString());
		}
	}
 
 
 /**
   * Send a message to the Forms module
   **/
  public void dispatch_event( ID id )
  {
      CustomEvent ce = new CustomEvent(mHandler, id);
      dispatchCustomEvent(ce);
  }
 
 
  public BOOLEAN PaintFromComponet() {RETURN true;}; 
 
  public void doPaint(WidgetGraphics wg,int xMin,double constX,int uMin,int yMin,double constY,int vMin, int maxY)
   { System.out.println("do nothing"); }
 
   public void HandleEventFromRemote(java.awt.Event evt)
   {
	   IF(evt.id == evt.MOUSE_DOWN)
	   {
			IF ( evt.clickCount == 2) {
		   		System.out.println("mouse pressed");
		   		System.out.println("Screen coord x="+evt.x+",y="+evt.y);
		   		System.out.println("Drawing coord x="+cadv.getX()+",y="+cadv.getY());		                  
                System.out.println("last x="+cadv.getUnitsX()+",y="+cadv.getUnitsY());                  
                System.out.println("ViewWidth="+cadv.getViewWidth());
                System.out.println("ViewHeight="+cadv.getViewHeight());              
                System.out.println("______________________________________________");              
 
           		dispatch_event(MOUSEDOWN);
           	}
	   }
   }
 
}
patmaba est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/06/2006, 10h21   #8
Rédacteur

 
Avatar de SheikYerbouti
 
Inscription : mai 2003
Messages : 6 530
Détails du profil
Informations forums :
Inscription : mai 2003
Messages : 6 530
Points : 6 460
Points : 6 460
et l'appel de la fonction ?
__________________
Rédacteur Oracle (Oracle ACE)
Guide Oracle ,Guide PL/SQL, Guide Forms 9i/10g, Index de recherche
Je ne réponds pas aux questions techniques par MP
Blogs: Forms-PL/SQL-J2EE - Forms Java Beans
SheikYerbouti est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/06/2006, 10h37   #9
Membre habitué
 
Inscription : avril 2004
Messages : 365
Détails du profil
Informations forums :
Inscription : avril 2004
Messages : 365
Points : 121
Points : 121
Ben c'est HandleEventFromRemote qui appel dispatch_event.

HandleEventFromRemote est une fonction géré par RemoteListener.

Le bean est un implements de RemoteListener

Et à chaque fois que mon composant à des evenenement. Ici dans mon exemple c'est un click souris. Ensuite, je teste si c'est un double click et à ce moment je fait le dispatch_event pour que forms reçoit l'event MOUSEDOWN.
patmaba est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/06/2006, 12h16   #10
Membre habitué
 
Inscription : avril 2004
Messages : 365
Détails du profil
Informations forums :
Inscription : avril 2004
Messages : 365
Points : 121
Points : 121
en debugguant j'ai vu que c'est la variable mHandler qui est null.

Comment l'initialiser ?
patmaba est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/06/2006, 14h10   #11
Rédacteur

 
Avatar de SheikYerbouti
 
Inscription : mai 2003
Messages : 6 530
Détails du profil
Informations forums :
Inscription : mai 2003
Messages : 6 530
Points : 6 460
Points : 6 460
Et si vous déclarez la variable de la sorte ?
Code :
  public IHandler  m_handler;
__________________
Rédacteur Oracle (Oracle ACE)
Guide Oracle ,Guide PL/SQL, Guide Forms 9i/10g, Index de recherche
Je ne réponds pas aux questions techniques par MP
Blogs: Forms-PL/SQL-J2EE - Forms Java Beans
SheikYerbouti est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/06/2006, 07h50   #12
Membre habitué
 
Inscription : avril 2004
Messages : 365
Détails du profil
Informations forums :
Inscription : avril 2004
Messages : 365
Points : 121
Points : 121
je viens de comprendre pourquoi ma variable m_handler est null et pourtant elle est bie nspécifié dans init.

Dans ma java console, j'ai regardé les messages. la fonction init( handler ) qui initialise mhandler n'est j'amais appelé par forms.

Je me suis dit comment est-ce possible alors que cela est initilasé par VBean.

La réponse est que mon composant java dans forms en enregistré en when new form instance par la méthode fbean.register. Cela signifie que mon champs forms
beanarea n'a pas l'iimplementation class définit dés le départ.

Lorsque l'implementation class est définit dés l'originie, alors forms passe par Init( Handler ) du wrapper java class.

Par contre lorsque c'est le mode fbean.register il ne passe jamais par la méthode Init.

En utilisant la dernière méthode, comment initialiser le mhandler ? En effet, il est nécessaire d'avoir sa valeur pour le dispatch d'event par CustomEvent.

Ou alors est-il possible de faire un dispatch d'event vers forms sans avoir un Handler définit ?
patmaba est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/06/2006, 10h59   #13
Rédacteur

 
Avatar de SheikYerbouti
 
Inscription : mai 2003
Messages : 6 530
Détails du profil
Informations forums :
Inscription : mai 2003
Messages : 6 530
Points : 6 460
Points : 6 460
Bonne question qu'il faudrait poser sur Metalink ou sur le forum Forms d'OTN.
__________________
Rédacteur Oracle (Oracle ACE)
Guide Oracle ,Guide PL/SQL, Guide Forms 9i/10g, Index de recherche
Je ne réponds pas aux questions techniques par MP
Blogs: Forms-PL/SQL-J2EE - Forms Java Beans
SheikYerbouti est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 16/06/2006, 12h05   #14
Membre habitué
 
Inscription : avril 2004
Messages : 365
Détails du profil
Informations forums :
Inscription : avril 2004
Messages : 365
Points : 121
Points : 121
je vous tiendrait au courant, en donnant une réponse à ce post.

D'ici à quand, je ne sais pas vous le dire.
patmaba est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 12h58.


 
 
 
 
Partenaires

Hébergement Web