Developing Java Beans private void readObject(ObjectInputStream stream) throws

Developing Java Beans } // add an action object to listen for, along with the// method to call on the target when the action event// is receivedpublic void registerActionEventHandler(Button b, String methodName) throws NoSuchMethodException { addMapping(b, methodName); b.addActionListener(this); } // add a method mappingprotected void addMapping(Button b, String methodName) throws NoSuchMethodException { if (mappingTable == null) { mappingTable = new Hashtable(); } Method m = theTargetClass.getMethod(methodName, paramClasses); mappingTable.put(b, m); } // implement the listener methodpublic void actionPerformed(ActionEvent evt) { try { // invoke the registered method on the target Method m = (Method)mappingTable.get(evt.getSource()); Object[] params = { evt }; m.invoke(theTarget, params); } catch (InvocationTargetException e) { System.out.println(e); } catch (IllegalAccessException e) { System.out.println(e); } } // handle the writing of the object stateprivate void writeObject(ObjectOutputStream stream) throws IOException { // use default serialization for the non-transient membersstream.defaultWriteObject(); // store the number of mappings int cnt = 0; if (mappingTable == null) { // there are no mappings, so store a 0 count and returnstream.writeInt(cnt); return; } // get a clone of the mapping table Hashtable tempmapping; page 85
Note: If you are looking for cheap and reliable provider to host and run your servlet application check Vision servlet hosting services

Comments are closed.