this is a good post about opening windows in various ways and their implications:
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/1bbdece5faa96018/0a2585172e66a671?lnk=gst&q=open+separate+window#0a2585172e66a671 On Nov 17, 11:54 am, gregor <[EMAIL PROTECTED]> wrote: > Clearly if a module is using a class declared in another module it > must explicitly inherit the other module in it's module.get.xml file > otherwise the GWT compiler won't have access to the class's source > which it needs. Frankly I'm not sure how this would work in the > situation as you describe since I have always followed the canonical > GWT approach which is using a single HTML page and EntryPoint for each > separate application. I'm not sure what your motivation is in having > two EntryPoints. I think this results in two separate javascript .js > files loaded into your HTML page, therefore there will be a "wall" > between them that accounts for your difficulties. I think it is > possible to communicate between separate javascript files using JSNI > but that would make your life much more difficult. > > On the other hand there is no reason not to have your > com.try.popup.client.PopUp.java in a separate module (i.e. having it's > own module.gwt.xml file) and have this inherited by the > com.try.client.Page1.java module. That way it would be compiled as > part of your main application (making your problem go away) but still > be usable in other applications as well. As I say, what is your > motivation for having two EnrtyPoints? > > regards > gregor > > On Nov 17, 9:42 am, mives29 <[EMAIL PROTECTED]> wrote: > > > The problem is im using two entrypoints, running on two windows, where > > the 2nd composite is shown thru Window.open(). I need the first > > entrypoint's composite to listen to the second entrypoint's composite, > > but I cant do that since the second entrypoint's composite is > > instantiated on the second composite, not the first one, so I cant add > > the first entrypoint's composite as a listener of the second > > entrypoint's composite. > > > Anyone knows a work around/alternative method of implementing observer > > pattern on my problem? > > > On Nov 17, 4:00 pm, mives29 <[EMAIL PROTECTED]> wrote: > > > > I tested it on same module, this implementation of the observer > > > pattern works. however, when using this on two modules it doesn't. Do > > > I need to do deferred binding here? I hope not coz I dont know how to. > > > =) > > > > On Nov 17, 1:29 pm, mives29 <[EMAIL PROTECTED]> wrote: > > > > > oops CnP mistake. on this line: > > > > buttons.addChangeListener(this); //where "this" pertains to > > > > Page1Compo1 > > > > > i meant > > > > xx.addChangeListener(this); //where "this" pertains to Page1Compo1 > > > > > On Nov 17, 1:22 pm, mives29 <[EMAIL PROTECTED]> wrote: > > > > > > Hi. I tried your recommendations but there are some errors that I > > > > > encounter that I think is related to my project's structure > > > > > compatibility with your code. As I said above, my project has two > > > > > entrypoints. First entrypoint(com.try.client.Page1.java) contains a > > > > > vertical panel that contains three composites. Second entrypoint > > > > > (com.try.popup.client.PopUp.java) contains a vertical panel than > > > > > contains two composites. (Note: they(entrypoints) are from different > > > > > modules, same app.) > > > > > > Now I need Page1.java's panel's contained composites to become > > > > > listeners of PopUp.java's horizontal panel's contained composites. For > > > > > example, I click something on PopUp.java, Page1.java would show a > > > > > reaction thru its composites that are listeners of PopUp.java's > > > > > composite # 2. However, as I followed your instruction, I got this > > > > > errror: > > > > > > First, my CODE: > > > > > //On Page1.java's first composite: Page1Compo1.java, I included the > > > > > following > > > > > //declaration of composite # 2 > > > > > XXXX xx; > > > > > > //somewhere on the code > > > > > buttons.addChangeListener(this); //where "this" pertains to > > > > > Page1Compo1 > > > > > > THE ERROR: > > > > > No source code is available for type com.xxxzzz.client.XXXX.java; did > > > > > you forget to inherit a required module? > > > > > > note: XXXX.java above is composite # 2 of PopUp.java vertical panel. > > > > > > It seems I cannot use XXXX.java on Page1Compo1.java.. What am I > > > > > missing? > > > > > > On Nov 14, 8:50 pm, gregor <[EMAIL PROTECTED]> wrote: > > > > > > > Oh, as to why, well as you see ConfigPanel has no real knowledge of > > > > > > the other panels that are listening to it and does need to call any > > > > > > methods on them. As a result any number of panels can be registered > > > > > > as > > > > > > a listener with it, and subsequently swapped out for new ones if > > > > > > required, without affecting ConfigPanel's code at all. It is up to > > > > > > the > > > > > > listeners to decide for themselves, individually, what they need to > > > > > > do > > > > > > when they receive a change event. So there is a very weak > > > > > > association > > > > > > between ConfigPanel and it's listeners and none at all between the > > > > > > listeners == low coupling == application components easy to change > > > > > > and > > > > > > maintain. > > > > > > > On Nov 14, 12:40 pm, gregor <[EMAIL PROTECTED]> wrote: > > > > > > > > GWT has a range of Observer/Observable gadgets off the shelf: > > > > > > > SourcesxxxxEvents & xxxxListener and xxxListenerCollection > > > > > > > utility > > > > > > > classes. If they don't work quite right for you, it's easy to > > > > > > > copy the > > > > > > > principle and design your own event handling interfaces. > > > > > > > > You could have your config Composite implement > > > > > > > SourcesChangeEvents, > > > > > > > for example. Then Comps 1 & 2 can implement ChangeListener and are > > > > > > > registered with the config Comp. It might work like so: > > > > > > > > public class ConfigPanel extends Composite implements > > > > > > > SourcesChangeEvents { > > > > > > > > private ChangeListenerCollection listeners = new > > > > > > > ChangeListenerCollection(); > > > > > > > private Button saveBtn = new Button("Save",new ClickListener() { > > > > > > > public void onClick(Widget widget) { > > > > > > > // you want to send the ConfigPanel itself, not > > > > > > > the > > > > > > > Button! > > > > > > > // if you just used this it would send the > > > > > > > button > > > > > > > listeners.fireChange(ConfigPanel.this).; > > > > > > > } > > > > > > > }); > > > > > > > > } > > > > > > > > public class Comp1 extends Composite implements changeListener { > > > > > > > > public void onChange(Widget sender) { > > > > > > > is (sender instanceof ConfigPanel) { > > > > > > > ConfigPanel configPanel = (ConfigPanel) sender; > > > > > > > // call whatever methods you need > > > > > > > } > > > > > > > > } > > > > > > > > Don't forget you have to register Comp1 as a lister with > > > > > > > ConfigPanel > > > > > > > somewhere or it won't work, e.g.: > > > > > > > > confPanel.addChangeListener(comp1); > > > > > > > > And that's about it - goodbye to your static method calls. > > > > > > > > regards > > > > > > > gregor > > > > > > > > On Nov 14, 8:45 am, mives29 <[EMAIL PROTECTED]> wrote: > > > > > > > > > i meant static methods, not static classes (2nd paragraph 2nd > > > > > > > > line) > > > > > > > > > On Nov 14, 4:43 pm, mives29 <[EMAIL PROTECTED]> wrote: > > > > > > > > > > I'd go straight to what I want to do. > > > > > > > > > > I have 3 composites in 1 panel, in 1 entrypoint. I have > > > > > > > > > another > > > > > > > > > entrypoint that pops up when you click a link on the 2nd > > > > > > > > > composite on > > > > > > > > > the 1st entrypoint. on that second entrypoint you can > > > > > > > > > configure stuff, > > > > > > > > > that will affect the displayed data on the first entrypoint's > > > > > > > > > composites. now, im thinking (actually, a friend thought of > > > > > > > > > it, not > > > > > > > > > me) that the observer pattern is great to use in here, as the > > > > > > > > > 3 > > > > > > > > > composites of the 1st entrypoint will listen to whatever the > > > > > > > > > second > > > > > > > > > entrypoint configures, then change themselves according to the > > > > > > > > > specified configurations on the second entrypoint. > > > > > > > > > > Currently, I do the changes on the first entrypoint's > > > > > > > > > composites by > > > > > > > > > calling their static classes (from the second entrypoint's > > > > > > > > > clicklisteners and stuff) that configures them, which I think > > > > > > > > > is not a > > > > > > > > > very good practice to implement because it's not easily > > > > > > > > > extensible and > > > > > > > > > not that good of a design. > > > > > > > > > > Now, is it wise to use the observer pattern(personally, I > > > > > > > > > think it > > > > > > > > > is)? If yes, how do you implement that on GWT 1.5? (we use > > > > > > > > > GWT 1.5.2) > > > > > > > > > > thanks in advance > > > > > > > > > mives29 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
