Improving PageFlows

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Improving PageFlows

graemer
Hi Guys,

I really like the work Steven did on page flows and want to see that
improve along with the rest of Grails.. so this thread is proposals on
what we have no and how it could be improved, Steven please approve or
veta any suggestions if you have time.

Few things at the moment the flow is defined with a builder like this:

    @Property grails.pageflow.Flow flow = new PageFlowBuilder().flow {
        loadBooks(action:loadBooks) {
            success('listBooks')
        }
    }

with a few meta class tweaks this coud be shortened to

    @Property flow =  {
        loadBooks(action:loadBooks) {
            success('listBooks')
        }
    }

Many of the actions use syntax like this:

    Closure loadBooks = { requestContext ->
        requestContext.flowScope[key] = value
        return "success"
    }

Again with meta class improvements this could be shortened to:

    def loadBooks = {
        this.flowScope[key] = value
        return "success"
    }

Actions that use commands are currently like this:

    Closure saveBook = { requestContext ->
        def bookCommand = requestContext.requestScope[BOOK_DETAIL_KEY]
    def book = getBooks(requestContext).find{it.id == bookCommand.id}
        if (book) {
            println('Saving book id:' + book.id)
            book.title = bookCommand.title
            book.author = bookCommand.author
        }
        return "success"
    }

Could this not be shortened to this using the same injection of
properties we use in controllers:

def saveBook = { command ->
    def book = getBooks().find{it.id == command.id}
        if(book) {
               book.properties = command.properties
        }
        return "success"
}

Your thoughts?
Graeme
Reply | Threaded
Open this post in threaded view
|

Re: Improving PageFlows

Guillaume Laforge-2
On 16/12/05, Graeme Rocher <[hidden email]> wrote:
> [...]
> Your thoughts?

Those simplifications look good to me!
I love the concise syntax Grails bring to web app development!
So I'd vote for them :-)

--
Guillaume Laforge
Groovy Project Manager
http://glaforge.free.fr/blog/groovy
Reply | Threaded
Open this post in threaded view
|

RE: Improving PageFlows

Dierk König
In reply to this post by graemer
What is absolutely crucial about web application is that you can
easily manage the 'pageflow'. This concerns not only the pages but
also actions, validations, forwards, etc.

Most recent attempts to make this simpler have failed
(e.g. Struts/JSP). They have made things even more complex.

The proposed improvements help much in making it easier to
create and read the pageflow. We also need some easy means to
visualize it graphically (like we did with the nodebuilder).
Is this still possible with the suggested improvements?

cheers
Mittie

P.S. my vision for the 'flow' is that a graphical representation is
rendered live on the server showing the workflow that the 'current'
page is involed in and nodes are clickable for jumping into the
sourcecode :-)


> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]On Behalf
> Of Graeme Rocher
> Sent: Freitag, 16. Dezember 2005 11:53
> To: [hidden email]
> Subject: [grails-dev] Improving PageFlows
>
>
> Hi Guys,
>
> I really like the work Steven did on page flows and want to see that
> improve along with the rest of Grails.. so this thread is proposals on
> what we have no and how it could be improved, Steven please approve or
> veta any suggestions if you have time.
>
> Few things at the moment the flow is defined with a builder like this:
>
>     @Property grails.pageflow.Flow flow = new PageFlowBuilder().flow {
>         loadBooks(action:loadBooks) {
>             success('listBooks')
>         }
>     }
>
> with a few meta class tweaks this coud be shortened to
>
>     @Property flow =  {
>         loadBooks(action:loadBooks) {
>             success('listBooks')
>         }
>     }
>
> Many of the actions use syntax like this:
>
>     Closure loadBooks = { requestContext ->
>         requestContext.flowScope[key] = value
>         return "success"
>     }
>
> Again with meta class improvements this could be shortened to:
>
>     def loadBooks = {
>         this.flowScope[key] = value
>         return "success"
>     }
>
> Actions that use commands are currently like this:
>
>     Closure saveBook = { requestContext ->
>         def bookCommand = requestContext.requestScope[BOOK_DETAIL_KEY]
>     def book = getBooks(requestContext).find{it.id == bookCommand.id}
>         if (book) {
>             println('Saving book id:' + book.id)
>             book.title = bookCommand.title
>             book.author = bookCommand.author
>         }
>         return "success"
>     }
>
> Could this not be shortened to this using the same injection of
> properties we use in controllers:
>
> def saveBook = { command ->
>     def book = getBooks().find{it.id == command.id}
>         if(book) {
>                book.properties = command.properties
>         }
>         return "success"
> }
>
> Your thoughts?
> Graeme
Reply | Threaded
Open this post in threaded view
|

Re: Improving PageFlows

graemer
On 16/12/05, Dierk Koenig <[hidden email]> wrote:

> What is absolutely crucial about web application is that you can
> easily manage the 'pageflow'. This concerns not only the pages but
> also actions, validations, forwards, etc.
>
> Most recent attempts to make this simpler have failed
> (e.g. Struts/JSP). They have made things even more complex.
>
> The proposed improvements help much in making it easier to
> create and read the pageflow. We also need some easy means to
> visualize it graphically (like we did with the nodebuilder).
> Is this still possible with the suggested improvements?

Yes my improvements are only to make the syntax more concise your node
builder should work and would be great if you were able to integrate
it into grails somehow (as a task like "grails draw-flows" or
something

>
> cheers
> Mittie
>
> P.S. my vision for the 'flow' is that a graphical representation is
> rendered live on the server showing the workflow that the 'current'
> page is involed in and nodes are clickable for jumping into the
> sourcecode :-)

Now that would be cool :-)

>
>
> > -----Original Message-----
> > From: [hidden email] [mailto:[hidden email]]On Behalf
> > Of Graeme Rocher
> > Sent: Freitag, 16. Dezember 2005 11:53
> > To: [hidden email]
> > Subject: [grails-dev] Improving PageFlows
> >
> >
> > Hi Guys,
> >
> > I really like the work Steven did on page flows and want to see that
> > improve along with the rest of Grails.. so this thread is proposals on
> > what we have no and how it could be improved, Steven please approve or
> > veta any suggestions if you have time.
> >
> > Few things at the moment the flow is defined with a builder like this:
> >
> >     @Property grails.pageflow.Flow flow = new PageFlowBuilder().flow {
> >         loadBooks(action:loadBooks) {
> >             success('listBooks')
> >         }
> >     }
> >
> > with a few meta class tweaks this coud be shortened to
> >
> >     @Property flow =  {
> >         loadBooks(action:loadBooks) {
> >             success('listBooks')
> >         }
> >     }
> >
> > Many of the actions use syntax like this:
> >
> >     Closure loadBooks = { requestContext ->
> >         requestContext.flowScope[key] = value
> >         return "success"
> >     }
> >
> > Again with meta class improvements this could be shortened to:
> >
> >     def loadBooks = {
> >         this.flowScope[key] = value
> >         return "success"
> >     }
> >
> > Actions that use commands are currently like this:
> >
> >     Closure saveBook = { requestContext ->
> >         def bookCommand = requestContext.requestScope[BOOK_DETAIL_KEY]
> >       def book = getBooks(requestContext).find{it.id == bookCommand.id}
> >         if (book) {
> >             println('Saving book id:' + book.id)
> >             book.title = bookCommand.title
> >             book.author = bookCommand.author
> >         }
> >         return "success"
> >     }
> >
> > Could this not be shortened to this using the same injection of
> > properties we use in controllers:
> >
> > def saveBook = { command ->
> >       def book = getBooks().find{it.id == command.id}
> >         if(book) {
> >                book.properties = command.properties
> >         }
> >         return "success"
> > }
> >
> > Your thoughts?
> > Graeme
>
Reply | Threaded
Open this post in threaded view
|

Re: Improving PageFlows

graemer
Oh and the other thing is I think PageFlows and Controllers should be
aligned so that for example the same dynamic properties available to
controllers are also available in flow actions (this.params,
this.session etc.)  plus any additional flow specific ones
(this.flowScope)

Graeme

On 16/12/05, Graeme Rocher <[hidden email]> wrote:

> On 16/12/05, Dierk Koenig <[hidden email]> wrote:
> > What is absolutely crucial about web application is that you can
> > easily manage the 'pageflow'. This concerns not only the pages but
> > also actions, validations, forwards, etc.
> >
> > Most recent attempts to make this simpler have failed
> > (e.g. Struts/JSP). They have made things even more complex.
> >
> > The proposed improvements help much in making it easier to
> > create and read the pageflow. We also need some easy means to
> > visualize it graphically (like we did with the nodebuilder).
> > Is this still possible with the suggested improvements?
>
> Yes my improvements are only to make the syntax more concise your node
> builder should work and would be great if you were able to integrate
> it into grails somehow (as a task like "grails draw-flows" or
> something
>
> >
> > cheers
> > Mittie
> >
> > P.S. my vision for the 'flow' is that a graphical representation is
> > rendered live on the server showing the workflow that the 'current'
> > page is involed in and nodes are clickable for jumping into the
> > sourcecode :-)
>
> Now that would be cool :-)
>
> >
> >
> > > -----Original Message-----
> > > From: [hidden email] [mailto:[hidden email]]On Behalf
> > > Of Graeme Rocher
> > > Sent: Freitag, 16. Dezember 2005 11:53
> > > To: [hidden email]
> > > Subject: [grails-dev] Improving PageFlows
> > >
> > >
> > > Hi Guys,
> > >
> > > I really like the work Steven did on page flows and want to see that
> > > improve along with the rest of Grails.. so this thread is proposals on
> > > what we have no and how it could be improved, Steven please approve or
> > > veta any suggestions if you have time.
> > >
> > > Few things at the moment the flow is defined with a builder like this:
> > >
> > >     @Property grails.pageflow.Flow flow = new PageFlowBuilder().flow {
> > >         loadBooks(action:loadBooks) {
> > >             success('listBooks')
> > >         }
> > >     }
> > >
> > > with a few meta class tweaks this coud be shortened to
> > >
> > >     @Property flow =  {
> > >         loadBooks(action:loadBooks) {
> > >             success('listBooks')
> > >         }
> > >     }
> > >
> > > Many of the actions use syntax like this:
> > >
> > >     Closure loadBooks = { requestContext ->
> > >         requestContext.flowScope[key] = value
> > >         return "success"
> > >     }
> > >
> > > Again with meta class improvements this could be shortened to:
> > >
> > >     def loadBooks = {
> > >         this.flowScope[key] = value
> > >         return "success"
> > >     }
> > >
> > > Actions that use commands are currently like this:
> > >
> > >     Closure saveBook = { requestContext ->
> > >         def bookCommand = requestContext.requestScope[BOOK_DETAIL_KEY]
> > >       def book = getBooks(requestContext).find{it.id == bookCommand.id}
> > >         if (book) {
> > >             println('Saving book id:' + book.id)
> > >             book.title = bookCommand.title
> > >             book.author = bookCommand.author
> > >         }
> > >         return "success"
> > >     }
> > >
> > > Could this not be shortened to this using the same injection of
> > > properties we use in controllers:
> > >
> > > def saveBook = { command ->
> > >       def book = getBooks().find{it.id == command.id}
> > >         if(book) {
> > >                book.properties = command.properties
> > >         }
> > >         return "success"
> > > }
> > >
> > > Your thoughts?
> > > Graeme
> >
>
Reply | Threaded
Open this post in threaded view
|

RE: Improving PageFlows

Dierk König
In reply to this post by graemer
> Yes my improvements are only to make the syntax more concise your node
> builder should work and would be great if you were able to integrate
> it into grails somehow (as a task like "grails draw-flows" or
> something

*hehe* great

Mittie
Reply | Threaded
Open this post in threaded view
|

Re: Improving PageFlows

Steven Devijver
+1.

The improvements look good. I think this will have a major impact on
the current implementation of the SWF integration which basically
happens in the builder.

On 12/16/05, Dierk Koenig <[hidden email]> wrote:
> > Yes my improvements are only to make the syntax more concise your node
> > builder should work and would be great if you were able to integrate
> > it into grails somehow (as a task like "grails draw-flows" or
> > something
>
> *hehe* great
>
> Mittie
>


--
"If you want to be a different fish, you gotta jump out of the school."
-- Captain Beefheart
Reply | Threaded
Open this post in threaded view
|

Re: Improving PageFlows

graemer
It should actually be easier to implement then in controllers because
it is a builder.. it will still be a builder, but essentially the
closure will delegate to the builder .. I will have to have a close
look at how it works at the moment because it is obviously important
to make it threadsafe as with controllers ( still need to implement
prototype support to fix the dependency injection btw, I think I know
how to do this)

Graeme

On 16/12/05, Steven Devijver <[hidden email]> wrote:

> +1.
>
> The improvements look good. I think this will have a major impact on
> the current implementation of the SWF integration which basically
> happens in the builder.
>
> On 12/16/05, Dierk Koenig <[hidden email]> wrote:
> > > Yes my improvements are only to make the syntax more concise your node
> > > builder should work and would be great if you were able to integrate
> > > it into grails somehow (as a task like "grails draw-flows" or
> > > something
> >
> > *hehe* great
> >
> > Mittie
> >
>
>
> --
> "If you want to be a different fish, you gotta jump out of the school."
> -- Captain Beefheart
>