Re: GWT MVP Architecture
I don't know if i am missing something, but, why yo don't create a clientFactory in order to get the View? In that way you only create the view once and you avoid the problem of having multiple handlers attached. 2012/9/14 Aryan saurabh.bl...@gmail.com On 14 Sep, 14:21, stuckagain david.no...@gmail.com wrote: Why does the view need to be a singleton ? I guess why I am having view as singleton is having better performance as I see views are expensive to create. Not creating em everytime saves operation deep down like Document.create - appendChild. and so the DOM manipulation that saves time. Anyway, when you are done with the presenter, then you need to tell it so. In that case it can unregister any installed handlers. David On Thursday, September 13, 2012 8:09:30 PM UTC+2, Aryan wrote: Hi all, lets look at the code: public class MyView implements IMyView { Button click; . public HasClickHandlers getClick(){ return click; } } public class MyPresenter { public interface IMyView { public HasClickHandlers getClick(); } private IMyView view; public MyPresenter(IMyView view){ this.view = view; bind(); } private void bind(){ view.addClickHandler(new ClickHandler(){ public void onClick(ClickEvent e){ Window.alert(heeo); } }//binds end }// class ends //(We are not using Activities or any MVP framework) ok tats it. Now in applicaton the view is singleton. but the presenter are not, so they are made as and when needed like : MyPresenter p = new MyPresenter(view); //view is singleton throughout the application; assume getting it by some factory Now suppose after a while if I have created *10 MyPresenter *instance that will add *10 clickHandler *to button c*lick . So one click event will be handled 10 times by 10 different handlers.* ** I can see here it as happening when click the button I get 10 times alert window. So where I misunderstood the MVP architecture, what I am missing. please help ** Thanks in advance.- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en. -- El precio es lo que pagas. El valor es lo que recibes. Warren Buffet -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: GWT MVP Architecture
Why does the view need to be a singleton ? Anyway, when you are done with the presenter, then you need to tell it so. In that case it can unregister any installed handlers. David On Thursday, September 13, 2012 8:09:30 PM UTC+2, Aryan wrote: Hi all, lets look at the code: public class MyView implements IMyView { Button click; . public HasClickHandlers getClick(){ return click; } } public class MyPresenter { public interface IMyView { public HasClickHandlers getClick(); } private IMyView view; public MyPresenter(IMyView view){ this.view = view; bind(); } private void bind(){ view.addClickHandler(new ClickHandler(){ public void onClick(ClickEvent e){ Window.alert(heeo); } }//binds end }// class ends //(We are not using Activities or any MVP framework) ok tats it. Now in applicaton the view is singleton. but the presenter are not, so they are made as and when needed like : MyPresenter p = new MyPresenter(view); //view is singleton throughout the application; assume getting it by some factory Now suppose after a while if I have created *10 MyPresenter *instance that will add *10 clickHandler *to button c*lick . So one click event will be handled 10 times by 10 different handlers.* ** I can see here it as happening when click the button I get 10 times alert window. So where I misunderstood the MVP architecture, what I am missing. please help ** Thanks in advance. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/kqPCgpq2N1IJ. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: GWT MVP Architecture
On 14 Sep, 14:21, stuckagain david.no...@gmail.com wrote: Why does the view need to be a singleton ? I guess why I am having view as singleton is having better performance as I see views are expensive to create. Not creating em everytime saves operation deep down like Document.create - appendChild. and so the DOM manipulation that saves time. Anyway, when you are done with the presenter, then you need to tell it so. In that case it can unregister any installed handlers. David On Thursday, September 13, 2012 8:09:30 PM UTC+2, Aryan wrote: Hi all, lets look at the code: public class MyView implements IMyView { Button click; . public HasClickHandlers getClick(){ return click; } } public class MyPresenter { public interface IMyView { public HasClickHandlers getClick(); } private IMyView view; public MyPresenter(IMyView view){ this.view = view; bind(); } private void bind(){ view.addClickHandler(new ClickHandler(){ public void onClick(ClickEvent e){ Window.alert(heeo); } }//binds end }// class ends //(We are not using Activities or any MVP framework) ok tats it. Now in applicaton the view is singleton. but the presenter are not, so they are made as and when needed like : MyPresenter p = new MyPresenter(view); //view is singleton throughout the application; assume getting it by some factory Now suppose after a while if I have created *10 MyPresenter *instance that will add *10 clickHandler *to button c*lick . So one click event will be handled 10 times by 10 different handlers.* ** I can see here it as happening when click the button I get 10 times alert window. So where I misunderstood the MVP architecture, what I am missing. please help ** Thanks in advance.- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
GWT MVP Architecture
Hi all, lets look at the code: public class MyView implements IMyView { Button click; . public HasClickHandlers getClick(){ return click; } } public class MyPresenter { public interface IMyView { public HasClickHandlers getClick(); } private IMyView view; public MyPresenter(IMyView view){ this.view = view; bind(); } private void bind(){ view.addClickHandler(new ClickHandler(){ public void onClick(ClickEvent e){ Window.alert(heeo); } }//binds end }// class ends //(We are not using Activities or any MVP framework) ok tats it. Now in applicaton the view is singleton. but the presenter are not, so they are made as and when needed like : MyPresenter p = new MyPresenter(view); //view is singleton throughout the application; assume getting it by some factory Now suppose after a while if I have created *10 MyPresenter *instance that will add *10 clickHandler *to button c*lick . So one click event will be handled 10 times by 10 different handlers.* ** I can see here it as happening when click the button I get 10 times alert window. So where I misunderstood the MVP architecture, what I am missing. please help ** Thanks in advance. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/VQpvCfRbzLoJ. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: GWT MVP Architecture
As your view is singleton you have to tell the presenter that it should detach itself from the view, e.g. by introducing a public Presenter.unbind() method. You then have to call that unbind() method before you throw away your presenter instance. Your presenter needs to remember the HandlerRegistration instances so unbind() can use them to remove the handlers from the view. Alternative: Let the view know its presenter and let it delegate to the presenter once an event has occurred. If the view does not know any presenter, nothing will happen. That way you can swap presenters or remove the presenter by calling view.setPresenter(null). public MyView extends Composite implements View { Presenter presenter = ...; Button createNoteButton = ...; public void setPresenter(Presenter p) { presenter = p; } @UiHandler(createNoteButton) //if you use UiBinder. Otherwise you have to register the ClickHandler yourself in the view. void onClick(ClickEvent event) { if(presenter != null) { presenter.onCreateNote() }; } } -- J. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/zUz9ytH1c6YJ. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: GWT MVP architecture redirect link page with URL parameters passing
Hi Mahmoud, Yes, this is very possible to do. Have any widget add a history handler, and watch for any history change event, and then fire the widget state accordingly as you see fit. I like doing it this way. You can pass any number of parameters in to change the widgets/app state. domain.tld#historyToken?[?params1=aparams2=b] I do this in my core project I am building. http://code.google.com/p/gwt-examples/source/browse/trunk/Core/src/org/gonevertical/core/client/global/QueryString.java Here is how I manage the default History Observations: http://code.google.com/p/gwt-examples/source/browse/trunk/DemoCoreEngine/src/com/gawkat/demo/client/DemoCoreEngine.java private void initHistory() { String historyToken = History.getToken(); if (historyToken.length() == 0) { History.newItem(account_Things); } } This will watch/observe the the querystring events (url): History.addValueChangeHandler(this); Hope that helps, Brandon Donnelson http://gwt-examples.googlecode.com On Apr 23, 8:38 pm, Mahmoud mahmoud.abounas...@gmail.com wrote: Hello, I have followed the MVP structure while developing my project. Once I hit the site URL, the History Manager loads the module by inserting the default token to the history stack and then from there the user can redirect himself to any part of the application by changing the History token, which is basically the bit that comes after the pound symbol (#) in the URL My problem is: I'm unable to redirect a user to a specific token without having to go through the default token and from there to anywhere I want. In other words, the URLs history usual follows this:http://domain#defaultToken and from there I can go tohttp://domain#page1orhttp://domain#page2 without any problem. But if i want to go directly tohttp://domain#page1i will be redirected to the default token which ishttp://domain#defaultToken... mainly due to this snippet of code: this.container = container; if (.equals(History.getToken())) { History.newItem(defaultToken); } else { History.fireCurrentHistoryState(); } So my question is: Is it possible to redirect a user to any part of the application without having to start from the defaultToken page? And can we pass in parameters using the URL only (i.e: how can the user hit the following link without errors?:http://domain#page3?param1=aparam2=b) ? How those it work? To concertize the problem, I'm trying to implement an activation link that if once the user clicks on it he will activate his account given the userID and a encrypted code (i.e:http://domain#activate?userID=12code=ht2oj34j2k5j6pk3 ) Any advice will do, Cheers, Mahmoud -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: GWT MVP architecture redirect link page with URL parameters passing
Use something like History.newItem(page3?param1=aparam2=b); This will rewrite the current URL and store it in the browsers history. The onChange history event will then be fired. On Apr 23, 11:38 pm, Mahmoud mahmoud.abounas...@gmail.com wrote: Hello, I have followed the MVP structure while developing my project. Once I hit the site URL, the History Manager loads the module by inserting the default token to the history stack and then from there the user can redirect himself to any part of the application by changing the History token, which is basically the bit that comes after the pound symbol (#) in the URL My problem is: I'm unable to redirect a user to a specific token without having to go through the default token and from there to anywhere I want. In other words, the URLs history usual follows this:http://domain#defaultToken and from there I can go tohttp://domain#page1orhttp://domain#page2 without any problem. But if i want to go directly tohttp://domain#page1i will be redirected to the default token which ishttp://domain#defaultToken... mainly due to this snippet of code: this.container = container; if (.equals(History.getToken())) { History.newItem(defaultToken); } else { History.fireCurrentHistoryState(); } So my question is: Is it possible to redirect a user to any part of the application without having to start from the defaultToken page? And can we pass in parameters using the URL only (i.e: how can the user hit the following link without errors?:http://domain#page3?param1=aparam2=b) ? How those it work? To concertize the problem, I'm trying to implement an activation link that if once the user clicks on it he will activate his account given the userID and a encrypted code (i.e:http://domain#activate?userID=12code=ht2oj34j2k5j6pk3 ) Any advice will do, Cheers, Mahmoud -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: GWT MVP architecture redirect link page with URL parameters passing
That's parameter passing within the web application, what about the first part of my question? the most important one to me On Apr 24, 7:46 am, Paul Stockley pstockl...@gmail.com wrote: Use something like History.newItem(page3?param1=aparam2=b); This will rewrite the currentURLand store it in the browsers history. The onChange history event will then be fired. On Apr 23, 11:38 pm, Mahmoud mahmoud.abounas...@gmail.com wrote: Hello, I have followed the MVP structure while developing my project. Once I hit the siteURL, the History Manager loads the module by inserting the default token to the history stack and then from there the user can redirect himself to any part of the application by changing the History token, which is basically the bit that comes after the pound symbol (#) in theURL My problem is: I'm unable to redirect a user to a specific token without having to go through the default token and from there to anywhere I want. In other words, the URLs history usual follows this:http://domain#defaultToken and from there I can go tohttp://domain#page1orhttp://domain#page2 without any problem. But if i want to go directly tohttp://domain#page1iwill be redirected to the default token which ishttp://domain#defaultToken... mainly due to this snippet of code: this.container = container; if (.equals(History.getToken())) { History.newItem(defaultToken); } else { History.fireCurrentHistoryState(); } So my question is: Is it possible to redirect a user to any part of the application without having to start from the defaultToken page? And can we pass in parameters using theURLonly (i.e: how can the user hit the following link without errors?:http://domain#page3?param1=aparam2=b) ? How those it work? To concertize the problem, I'm trying to implement an activation link that if once the user clicks on it he will activate his account given the userID and a encrypted code (i.e:http://domain#activate?userID=12code=ht2oj34j2k5j6pk3 ) Any advice will do, Cheers, Mahmoud -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/google-web-toolkit?hl=en. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
GWT MVP architecture redirect link page with URL parameters passing
Hello, I have followed the MVP structure while developing my project. Once I hit the site URL, the History Manager loads the module by inserting the default token to the history stack and then from there the user can redirect himself to any part of the application by changing the History token, which is basically the bit that comes after the pound symbol (#) in the URL My problem is: I'm unable to redirect a user to a specific token without having to go through the default token and from there to anywhere I want. In other words, the URLs history usual follows this: http://domain#defaultToken and from there I can go to http://domain#page1 or http://domain#page2 without any problem. But if i want to go directly to http://domain#page1 i will be redirected to the default token which is http://domain#defaultToken... mainly due to this snippet of code: this.container = container; if (.equals(History.getToken())) { History.newItem(defaultToken); } else { History.fireCurrentHistoryState(); } So my question is: Is it possible to redirect a user to any part of the application without having to start from the defaultToken page? And can we pass in parameters using the URL only (i.e: how can the user hit the following link without errors?: http://domain#page3?param1=aparam2=b) ? How those it work? To concertize the problem, I'm trying to implement an activation link that if once the user clicks on it he will activate his account given the userID and a encrypted code (i.e: http://domain#activate?userID=12code=ht2oj34j2k5j6pk3 ) Any advice will do, Cheers, Mahmoud -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.