Re: A new way to handle page navigation in GWT

2015-05-20 Thread Gilberto
Glad you liked it =)

I just posted the v.1.1.0 with better support for dependency injection and 
some more improvements. Feedback is always welcome ;-)

--
Gilberto

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


Re: A new way to handle page navigation in GWT

2015-05-09 Thread Filipe Sousa
I really like it 

On Friday, May 8, 2015 at 4:09:05 AM UTC+1, Gilberto wrote:
>
> Hi folks,
>
> I just opensourced a project I was using in several GWT projects to handle 
> page navigation. It is something between Activities and Places and the full 
> featured GWTP:
>
> GWT Views - https://github.com/gilberto-torrezan/gwt-views
>
> It's a framework to define Views using simple annotations. A View is a 
> page with a unique URL token. Something like this:
>
> @View("home")
> public class HomeView extends Composite {
> //...
> }
>
> Typing "youapp#home" at the address bar will render the HomeView Widget. 
> As simple as that. All the code-splitting, presenter layer, Google 
> Analytics tracking is done automatically for you.
>
> The framework supports user roles based authorization for Views as well. 
> You can define the allowed roles by using:
>
> @View(value = "admin", rolesAllowed = "ADMIN")
> public class AdminView extends Composite {
> //...
> }
>
> And there's a lot more. The project is published at Maven Central, so it 
> is simple to download and try it out. Please access the project page for 
> more information.
>
> And of course, feedback and pull requests are always welcome!
>
> Thanks.
>
> --
> Gilberto
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


A new way to handle page navigation in GWT

2015-05-07 Thread Gilberto
Hi folks,

I just opensourced a project I was using in several GWT projects to handle 
page navigation. It is something between Activities and Places and the full 
featured GWTP:

GWT Views - https://github.com/gilberto-torrezan/gwt-views

It's a framework to define Views using simple annotations. A View is a page 
with a unique URL token. Something like this:

@View("home")
public class HomeView extends Composite {
//...
}

Typing "youapp#home" at the address bar will render the HomeView Widget. As 
simple as that. All the code-splitting, presenter layer, Google Analytics 
tracking is done automatically for you.

The framework supports user roles based authorization for Views as well. 
You can define the allowed roles by using:

@View(value = "admin", rolesAllowed = "ADMIN")
public class AdminView extends Composite {
//...
}

And there's a lot more. The project is published at Maven Central, so it is 
simple to download and try it out. Please access the project page for more 
information.

And of course, feedback and pull requests are always welcome!

Thanks.

--
Gilberto

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


Re: Page navigation in GWT

2008-12-10 Thread fargo...@googlemail.com

Hi,

I am just prototyping an app with GWT and surely miss the page
navigation handling. But suppose i agree with taking the things in or
out from the container. How one can handle the following scenario:

* I have my main.html and this html has a loading_div, that shows
loading message when the app is first getting loaded. One the login
page is displayed, the user authenticates itself and then we make the
container in/out etc. But if user refreshes the page, the loading_div
is again coming into picture, displaying the message...so, what
exactly i want is to display the loading_div only once when the user
first requested the page and not afterwards!

How is this possible?

Thanks for your help.

Regards,
fargo

On Nov 22, 11:13 pm, quentin <[EMAIL PROTECTED]> wrote:
> Jon,
>
> I *strongly* suggest that you learn and embrace the GWT History
> subsystem early on in your prototyping. Your users will be thankful
> you did because then they will be able to bookmark pages, use the back
> and forward buttons, etc. The History system will also force you into
> a loose coupling between "pages", making your application much less
> brittle.
>
> Here is 30 thousand foot view of an approach that has worked extremely
> well for us:
>
> - We have a HistoryCommand interface that extends Command(), adding a
> getHistoryToken() method. The AbstractHistoryCommand superclass
> provides a final implementation for execute() that looks like:
>    public void execute()
>    {
>       History.newItem(getHistoryToken());
>    }
>
> - We implement HistoryCommands for any UI state transition that the
> end-user would consider a new "page request". These commands use
> utility classes to serialize their state into your typical URL
> parameter string (e.g. "#command=ViewUser&id=100").
>
> - We register a singleton HistoryCommandManager as a GWT
> HistoryListener. This class is responsible for listening to History
> change events and deserializing history token strings into
> HistoryCommand objects.
>
> - We use Visitor pattern to visit each type of HistoryCommand and
> render the appropriate page:
>
> ...
> public void visit(ViewUserCommand command)
> {
>    UserEditPagepage =UserEditPage.getInstance();
>     page.setUserId(command.getUserId());
>     // render the page to a SimplePanel viewport
>     viewportPanel.setWidget(page);
>
> }
>
> Our Page objects follow a few conventions to make them easy to work
> with:
>
> 1. They are all singletons.
> 2. They assume no contextual state has been loaded prior to being
> rendered. In other words, each page must assume that the user has
> bookmarked it, closed the browser, reopened the browser, and clicked
> the bookmark. So, ourUserEditPagemight look like:
>
> public classUserEditPage
> {
>    private staticUserEditPageinstance;
>    public staticUserEditPagegetInstance()
>    {
>       if (instance == null)
>          instance = newUserEditPage();
>    }
>
>    private AsyncCallback loadCallback = new AsyncCallback()
>    {
>        public void onSuccess(User user)
>        {
>            // update page widgets with the user's info
>            // hide loading indicator
>        }
>
>        public void onFailure(Throwable cause)
>        {
>            // whatever our app never fails :)
>            Window.alert(cause.getMessage());
>            // hide loading indicator
>        }
>    }
>
>    privateUserEditPage()
>    {
>       // initialize and layout page widgets
>    }
>
>    public void setUserId(int userId)
>    {
>       // show loading indicator
>       UserController.getInstance().lookup(userId, loadCallback);
>    }
>  }
>
> The UserController is responsible for maintaining any local cache of
> users and short-circuiting the async callback. The important thing is
> that this is transparent to the Page object.
>
> So, now after all that you can do things like this:
>
> MenuBar userMenu = new MenuBar();
> userMenu.addItem("Create a new user", new NewUserCommand());
>
> or
>
> new Hyperlink("Create a new user", new NewUserCommand().getHistoryToken
> ());
>
> Hope this helps.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: Page navigation in GWT

2008-11-23 Thread Transplant

On Nov 21, 1:02 pm, jonbutler88 <[EMAIL PROTECTED]> wrote:
> Hi all
>
> I am new to GWT, though I have dabbled in C#/Java before so the
> language itself doesn't boggle me that much, but it seems some of the
> simpler concepts aren't sticking. Im pretty sure the answer to my
> question is so obvious, as I have not seen it answered in any of the
> tutorials on GWT on the web. What I wanted to know is, how do you do
> page navigation in GWT? For example I have my new class, with its
> onModuleLoad function, which is fine, but say I want to click a link
> and load a new page with a different onModuleLoad function?

As others have pointed out, the Right(TM) way to do this is using the
History mechanism. There are many strategies for working this into
your application's internal syntax and structure. However, there are a
few other basic concepts I think you might want some clarification on.

First, you should think of your GWT app as a single HTML page, in
which user and application events cause PORTIONS of the page (ie DOM
elements) to change, be replaced, or loaded with content from the
server or internal application logic. In general you will not be
sending the user/browser to another "real" URL. Your initial HTML page
is basically a canvas on which your GWT application spews up content
in response to user or server events (the typical AJAX model).

In the example of your login function, when your app has successfully
received authentication credentials from the user, its next job will
be to kick the login widgets off the page, and replace them with
"whatever is next".

Second, you will probably find that the majority (if not all) of your
user navigation paths are not coded in raw HTML. The GWT ui classes
provide all the event handling and navigational connectivity that you
would find in a typical desktop application. Although it is possible
use raw HTML links to navigate your application, the GWT widgets are
much easier to work with, test, and maintain than raw HTML files. So
instead of following an blah and "going
somewhere else", you will create event listeners that respond to mouse
or key clicks which cause your app to change what is already there.

Finally, you typically will only have one EntryPoint implementation
with an onModuleLoad method in your application. That class will be
responsible for initializing your application - probably by creating
classes for the UI, classes for handling UI events, and classes for
managing your applications internal state. In a lot of the samples,
the class which implements EntryPoint also implements all of the UI,
the event handlers, and the application logic, but that's only to
reduce the amount of code you have to read. In any serious application
you will want to factor those things out into different classes (as in
MVC).

It might be helpful to think of your EntryPoint.onModuleLoad() as if
it were simply the main() method of a more traditional application.

Hope that helps!



--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: Page navigation in GWT

2008-11-22 Thread quentin

Jon,

I *strongly* suggest that you learn and embrace the GWT History
subsystem early on in your prototyping. Your users will be thankful
you did because then they will be able to bookmark pages, use the back
and forward buttons, etc. The History system will also force you into
a loose coupling between "pages", making your application much less
brittle.


Here is 30 thousand foot view of an approach that has worked extremely
well for us:

- We have a HistoryCommand interface that extends Command(), adding a
getHistoryToken() method. The AbstractHistoryCommand superclass
provides a final implementation for execute() that looks like:
   public void execute()
   {
  History.newItem(getHistoryToken());
   }

- We implement HistoryCommands for any UI state transition that the
end-user would consider a new "page request". These commands use
utility classes to serialize their state into your typical URL
parameter string (e.g. "#command=ViewUser&id=100").

- We register a singleton HistoryCommandManager as a GWT
HistoryListener. This class is responsible for listening to History
change events and deserializing history token strings into
HistoryCommand objects.

- We use Visitor pattern to visit each type of HistoryCommand and
render the appropriate page:

...
public void visit(ViewUserCommand command)
{
UserEditPage page = UserEditPage.getInstance();
page.setUserId(command.getUserId());
// render the page to a SimplePanel viewport
viewportPanel.setWidget(page);
}

Our Page objects follow a few conventions to make them easy to work
with:

1. They are all singletons.
2. They assume no contextual state has been loaded prior to being
rendered. In other words, each page must assume that the user has
bookmarked it, closed the browser, reopened the browser, and clicked
the bookmark. So, our UserEditPage might look like:

public class UserEditPage
{
   private static UserEditPage instance;
   public static UserEditPage getInstance()
   {
  if (instance == null)
 instance = new UserEditPage();
   }

   private AsyncCallback loadCallback = new AsyncCallback()
   {
   public void onSuccess(User user)
   {
   // update page widgets with the user's info
   // hide loading indicator
   }

   public void onFailure(Throwable cause)
   {
   // whatever our app never fails :)
   Window.alert(cause.getMessage());
   // hide loading indicator
   }
   }

   private UserEditPage()
   {
  // initialize and layout page widgets
   }

   public void setUserId(int userId)
   {
  // show loading indicator
  UserController.getInstance().lookup(userId, loadCallback);
   }
 }


The UserController is responsible for maintaining any local cache of
users and short-circuiting the async callback. The important thing is
that this is transparent to the Page object.

So, now after all that you can do things like this:

MenuBar userMenu = new MenuBar();
userMenu.addItem("Create a new user", new NewUserCommand());

or

new Hyperlink("Create a new user", new NewUserCommand().getHistoryToken
());

Hope this helps.




--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: Page navigation in GWT

2008-11-21 Thread jonbutler88

Ah I see, thats a very 'ajax' way of doing things.

Thanks for the help :D

On Nov 22, 12:22 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> The GWT (actually Ajax) way to look at navigation is not going from
> one page to another, but rather staying on the same page and moving
> your content in and out.  Take a look at most samples and you'll see
> something like
>
> public void onModuleLoad() {
>
>         RootPanel.get().add(new MyCoolNewWidget());
>
> }
>
> where MyCoolNewWidget is something you've created that is your first
> "page".  Perhaps on there is some widget that the user clicks to
> "navigate" to the next page.  It would look something like:
>
> final Button moveMe = new Button("Next page");
>         moveMe.addClickListener(new ClickListener() {
>                 public void onClick(Widget sender) {
>                     RootPanel.remove(0);
>                     RootPanel.get().add(new AnotherReallyCoolWidget
> ());
>                 }
>             });
>
> In the click listener for the button, you first remove the content
> from the RootPanel (basically the Window object in Javascript) and
> then insert the new "page" in it's space.
>
> The whole page based navigation methodology is really a web thing, any
> heavy client, like those written in C# WinForms, SWT, Swing or MFC or
> even OWL, you moved content in and out of the "container" which is
> what the browser really becomes.
>
> Later,
>
> Shaffer
> On Nov 21, 2:02 pm, jonbutler88 <[EMAIL PROTECTED]> wrote:
>
> > Hi all
>
> > I am new to GWT, though I have dabbled in C#/Java before so the
> > language itself doesn't boggle me that much, but it seems some of the
> > simpler concepts aren't sticking. Im pretty sure the answer to my
> > question is so obvious, as I have not seen it answered in any of the
> > tutorials on GWT on the web. What I wanted to know is, how do you do
> > page navigation in GWT? For example I have my new class, with its
> > onModuleLoad function, which is fine, but say I want to click a link
> > and load a new page with a different onModuleLoad function?
>
> > After a user logs in, I want them to be transported to a different
> > page (different class as well I assume...). I tried adding a new
> > servlet line in the .gwt.xml file, but as its not strictly a servlet
> > (doesnt extend RemoteService), it fails to load.
>
> > Where abouts should I be looking to edit? A new .html file? And if so,
> > what script should I include, as there is only 1 nocache.js file...
>
> > Thanks in advance,
> > Jon
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Re: Page navigation in GWT

2008-11-21 Thread mikedshaf...@gmail.com

The GWT (actually Ajax) way to look at navigation is not going from
one page to another, but rather staying on the same page and moving
your content in and out.  Take a look at most samples and you'll see
something like

public void onModuleLoad() {

RootPanel.get().add(new MyCoolNewWidget());
}

where MyCoolNewWidget is something you've created that is your first
"page".  Perhaps on there is some widget that the user clicks to
"navigate" to the next page.  It would look something like:

final Button moveMe = new Button("Next page");
moveMe.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
RootPanel.remove(0);
RootPanel.get().add(new AnotherReallyCoolWidget
());
}
});

In the click listener for the button, you first remove the content
from the RootPanel (basically the Window object in Javascript) and
then insert the new "page" in it's space.

The whole page based navigation methodology is really a web thing, any
heavy client, like those written in C# WinForms, SWT, Swing or MFC or
even OWL, you moved content in and out of the "container" which is
what the browser really becomes.

Later,

Shaffer
On Nov 21, 2:02 pm, jonbutler88 <[EMAIL PROTECTED]> wrote:
> Hi all
>
> I am new to GWT, though I have dabbled in C#/Java before so the
> language itself doesn't boggle me that much, but it seems some of the
> simpler concepts aren't sticking. Im pretty sure the answer to my
> question is so obvious, as I have not seen it answered in any of the
> tutorials on GWT on the web. What I wanted to know is, how do you do
> page navigation in GWT? For example I have my new class, with its
> onModuleLoad function, which is fine, but say I want to click a link
> and load a new page with a different onModuleLoad function?
>
> After a user logs in, I want them to be transported to a different
> page (different class as well I assume...). I tried adding a new
> servlet line in the .gwt.xml file, but as its not strictly a servlet
> (doesnt extend RemoteService), it fails to load.
>
> Where abouts should I be looking to edit? A new .html file? And if so,
> what script should I include, as there is only 1 nocache.js file...
>
> Thanks in advance,
> Jon
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---



Page navigation in GWT

2008-11-21 Thread jonbutler88

Hi all

I am new to GWT, though I have dabbled in C#/Java before so the
language itself doesn't boggle me that much, but it seems some of the
simpler concepts aren't sticking. Im pretty sure the answer to my
question is so obvious, as I have not seen it answered in any of the
tutorials on GWT on the web. What I wanted to know is, how do you do
page navigation in GWT? For example I have my new class, with its
onModuleLoad function, which is fine, but say I want to click a link
and load a new page with a different onModuleLoad function?

After a user logs in, I want them to be transported to a different
page (different class as well I assume...). I tried adding a new
servlet line in the .gwt.xml file, but as its not strictly a servlet
(doesnt extend RemoteService), it fails to load.

Where abouts should I be looking to edit? A new .html file? And if so,
what script should I include, as there is only 1 nocache.js file...

Thanks in advance,
Jon

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~--~~~~--~~--~--~---