New Scaffolding Docs

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

New Scaffolding Docs

graemer
With screenshots: http://grails.codehaus.org/Scaffolding

Next thing to do is the movie...

Graeme
Reply | Threaded
Open this post in threaded view
|

Re: New Scaffolding Docs

Steven Devijver
Hey Graeme,

This is perfect, it really is. The movie is going to be awesome!

One thing I would like to change is a small detail in the Validation
section. It's not entirely clear where the constraints have to be
added: in the controller or in the domain class.

Also, how to these constraints work if I use Java domain classes? I
would also point out how to register your Java classes with the
SessionFactory.

Steven

On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> With screenshots: http://grails.codehaus.org/Scaffolding
>
> Next thing to do is the movie...
>
> Graeme
>


--
Steven Devijver
Senior Consultant
Interface21
Spring Services from the Source
http://www.interface21.com

Co-author, "Expert Spring MVC and Web Flow"
(February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
http://www.amazon.com/gp/product/159059584X

Interface21 NL B.V.
Donker Curtiusstraat 7-400c
1051JL Amsterdam
The Netherlands
Phone: +31 (0)20 486 47 63
Fax: +31 (0)20 475 08 28
Mail: [hidden email]
Skype: devijvers
Reply | Threaded
Open this post in threaded view
|

RE: New Scaffolding Docs

Dierk König
In reply to this post by graemer
Yam, yam.

very nice (both, the documentation and the functionality)
Mittie

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]On Behalf
> Of Graeme Rocher
> Sent: Montag, 27. Februar 2006 13:21
> To: [hidden email]
> Subject: [grails-dev] New Scaffolding Docs
>
>
> With screenshots: http://grails.codehaus.org/Scaffolding
>
> Next thing to do is the movie...
>
> Graeme
Reply | Threaded
Open this post in threaded view
|

Re: New Scaffolding Docs

graemer
In reply to this post by Steven Devijver
On 27/02/06, Steven Devijver <[hidden email]> wrote:
> Hey Graeme,
>
> This is perfect, it really is. The movie is going to be awesome!
>
> One thing I would like to change is a small detail in the Validation
> section. It's not entirely clear where the constraints have to be
> added: in the controller or in the domain class.

Good point. I will change this.

>
> Also, how to these constraints work if I use Java domain classes? I
> would also point out how to register your Java classes with the
> SessionFactory.

There is an example in CVS in "samples/recipes" that demonstrates java
integration.  Its something like:

    @Transient
    public Map getConstraints() {
        ConstrainedProperty titleConstraint = new
ConstrainedPersistentProperty(getClass(), "title", String.class );
        titleConstraint.setOrder(1);
        titleConstraint.setLength(new IntRange(5,15));
        ConstrainedProperty descConstraint = new
ConstrainedPersistentProperty(getClass(), "title", String.class );
        descConstraint.setOrder(2);
        descConstraint.setWidget("textarea");


        List constraints = new ArrayList();
        constraints.add(titleConstraint);
        constraints.add(descConstraint);

        return constraints;
    }

The example in CVS uses Hibernate annotations and the entry in
hibernate.cfg.xml looks like:

<hibernate-configuration>
    <session-factory>
        <mapping package="com.recipes" />
        <mapping class="com.recipes.Recipe" />
    </session-factory>
</hibernate-configuration>

Maybe I will add a section on scaffolding hibernate mapped classes

Graeme


>
> Steven
>
> On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > With screenshots: http://grails.codehaus.org/Scaffolding
> >
> > Next thing to do is the movie...
> >
> > Graeme
> >
>
>
> --
> Steven Devijver
> Senior Consultant
> Interface21
> Spring Services from the Source
> http://www.interface21.com
>
> Co-author, "Expert Spring MVC and Web Flow"
> (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> http://www.amazon.com/gp/product/159059584X
>
> Interface21 NL B.V.
> Donker Curtiusstraat 7-400c
> 1051JL Amsterdam
> The Netherlands
> Phone: +31 (0)20 486 47 63
> Fax: +31 (0)20 475 08 28
> Mail: [hidden email]
> Skype: devijvers
>
Reply | Threaded
Open this post in threaded view
|

Re: New Scaffolding Docs

graemer
On 27/02/06, Steven Devijver <[hidden email]> wrote:

> On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > Hey Graeme,
> > >
> > > This is perfect, it really is. The movie is going to be awesome!
> > >
> > > One thing I would like to change is a small detail in the Validation
> > > section. It's not entirely clear where the constraints have to be
> > > added: in the controller or in the domain class.
> >
> > Good point. I will change this.
> >
> > >
> > > Also, how to these constraints work if I use Java domain classes? I
> > > would also point out how to register your Java classes with the
> > > SessionFactory.
> >
> > There is an example in CVS in "samples/recipes" that demonstrates java
> > integration.  Its something like:
> >
> >     @Transient
> >     public Map getConstraints() {
> >         ConstrainedProperty titleConstraint = new
> > ConstrainedPersistentProperty(getClass(), "title", String.class );
> >         titleConstraint.setOrder(1);
> >         titleConstraint.setLength(new IntRange(5,15));
> >         ConstrainedProperty descConstraint = new
> > ConstrainedPersistentProperty(getClass(), "title", String.class );
> >         descConstraint.setOrder(2);
> >         descConstraint.setWidget("textarea");
> >
> >
> >         List constraints = new ArrayList();
> >         constraints.add(titleConstraint);
> >         constraints.add(descConstraint);
> >
> >         return constraints;
> >     }
>
> Do you think it's possible to put the constraints in the controller?

Anythings possible :-)
The constraints are just built up by instances of
org.codehaus.groovy.grails.orm.hibernate.validation.ConstrainedPersistentProperty
using a builder.. so these could be placed anywere really..
The builder used is
org.codehaus.groovy.grails.validation.ConstrainedPropertyBuilder.

What do you have in mind anyway?

BTW the docs on Hibernate Integration have been updated with more info
on java integration: http://grails.codehaus.org/Hibernate+Integration

and I've added more to the original scaffolding docs about java integration

Graeme

>
> >
> > The example in CVS uses Hibernate annotations and the entry in
> > hibernate.cfg.xml looks like:
> >
> > <hibernate-configuration>
> >     <session-factory>
> >         <mapping package="com.recipes" />
> >         <mapping class="com.recipes.Recipe" />
> >     </session-factory>
> > </hibernate-configuration>
> >
> > Maybe I will add a section on scaffolding hibernate mapped classes
> >
> > Graeme
> >
> >
> > >
> > > Steven
> > >
> > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > With screenshots: http://grails.codehaus.org/Scaffolding
> > > >
> > > > Next thing to do is the movie...
> > > >
> > > > Graeme
> > > >
> > >
> > >
> > > --
> > > Steven Devijver
> > > Senior Consultant
> > > Interface21
> > > Spring Services from the Source
> > > http://www.interface21.com
> > >
> > > Co-author, "Expert Spring MVC and Web Flow"
> > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > http://www.amazon.com/gp/product/159059584X
> > >
> > > Interface21 NL B.V.
> > > Donker Curtiusstraat 7-400c
> > > 1051JL Amsterdam
> > > The Netherlands
> > > Phone: +31 (0)20 486 47 63
> > > Fax: +31 (0)20 475 08 28
> > > Mail: [hidden email]
> > > Skype: devijvers
> > >
> >
>
>
> --
> Steven Devijver
> Senior Consultant
> Interface21
> Spring Services from the Source
> http://www.interface21.com
>
> Co-author, "Expert Spring MVC and Web Flow"
> (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> http://www.amazon.com/gp/product/159059584X
>
> Interface21 NL B.V.
> Donker Curtiusstraat 7-400c
> 1051JL Amsterdam
> The Netherlands
> Phone: +31 (0)20 486 47 63
> Fax: +31 (0)20 475 08 28
> Mail: [hidden email]
> Skype: devijvers
>
Reply | Threaded
Open this post in threaded view
|

Re: New Scaffolding Docs

graemer
On 27/02/06, Steven Devijver <[hidden email]> wrote:

> On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > > > Hey Graeme,
> > > > >
> > > > > This is perfect, it really is. The movie is going to be awesome!
> > > > >
> > > > > One thing I would like to change is a small detail in the Validation
> > > > > section. It's not entirely clear where the constraints have to be
> > > > > added: in the controller or in the domain class.
> > > >
> > > > Good point. I will change this.
> > > >
> > > > >
> > > > > Also, how to these constraints work if I use Java domain classes? I
> > > > > would also point out how to register your Java classes with the
> > > > > SessionFactory.
> > > >
> > > > There is an example in CVS in "samples/recipes" that demonstrates java
> > > > integration.  Its something like:
> > > >
> > > >     @Transient
> > > >     public Map getConstraints() {
> > > >         ConstrainedProperty titleConstraint = new
> > > > ConstrainedPersistentProperty(getClass(), "title", String.class );
> > > >         titleConstraint.setOrder(1);
> > > >         titleConstraint.setLength(new IntRange(5,15));
> > > >         ConstrainedProperty descConstraint = new
> > > > ConstrainedPersistentProperty(getClass(), "title", String.class );
> > > >         descConstraint.setOrder(2);
> > > >         descConstraint.setWidget("textarea");
> > > >
> > > >
> > > >         List constraints = new ArrayList();
> > > >         constraints.add(titleConstraint);
> > > >         constraints.add(descConstraint);
> > > >
> > > >         return constraints;
> > > >     }
> > >
> > > Do you think it's possible to put the constraints in the controller?
>
> It doesn't make sense to me to add constraints to domain classes that
> are related to the view and that are specific to Grails. That's why it
> sounds like a pleasant decoupling to put the constraints in the
> controller. After all, adding the constraints to the Java classes is
> too much work :-) And it would be a better encouragement for users to
> get started.

True if you're writing them in java it probably will be a bit painful,
but no more so than RIFE's constraint mechanism for example.

The constraints are related to thhe domain class because thats the way
its done in other frameworks, but not necessarily how it should be
done, I'm open to ideas how would you imagine it working in a
controller? per action? or as validator instance?

Graeme

>
>
> >
> > Anythings possible :-)
> > The constraints are just built up by instances of
> > org.codehaus.groovy.grails.orm.hibernate.validation.ConstrainedPersistentProperty
> > using a builder.. so these could be placed anywere really..
> > The builder used is
> > org.codehaus.groovy.grails.validation.ConstrainedPropertyBuilder.
> >
> > What do you have in mind anyway?
> >
> > BTW the docs on Hibernate Integration have been updated with more info
> > on java integration: http://grails.codehaus.org/Hibernate+Integration
> >
> > and I've added more to the original scaffolding docs about java integration
> >
> > Graeme
> > >
> > > >
> > > > The example in CVS uses Hibernate annotations and the entry in
> > > > hibernate.cfg.xml looks like:
> > > >
> > > > <hibernate-configuration>
> > > >     <session-factory>
> > > >         <mapping package="com.recipes" />
> > > >         <mapping class="com.recipes.Recipe" />
> > > >     </session-factory>
> > > > </hibernate-configuration>
> > > >
> > > > Maybe I will add a section on scaffolding hibernate mapped classes
> > > >
> > > > Graeme
> > > >
> > > >
> > > > >
> > > > > Steven
> > > > >
> > > > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > > > With screenshots: http://grails.codehaus.org/Scaffolding
> > > > > >
> > > > > > Next thing to do is the movie...
> > > > > >
> > > > > > Graeme
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Steven Devijver
> > > > > Senior Consultant
> > > > > Interface21
> > > > > Spring Services from the Source
> > > > > http://www.interface21.com
> > > > >
> > > > > Co-author, "Expert Spring MVC and Web Flow"
> > > > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > > > http://www.amazon.com/gp/product/159059584X
> > > > >
> > > > > Interface21 NL B.V.
> > > > > Donker Curtiusstraat 7-400c
> > > > > 1051JL Amsterdam
> > > > > The Netherlands
> > > > > Phone: +31 (0)20 486 47 63
> > > > > Fax: +31 (0)20 475 08 28
> > > > > Mail: [hidden email]
> > > > > Skype: devijvers
> > > > >
> > > >
> > >
> > >
> > > --
> > > Steven Devijver
> > > Senior Consultant
> > > Interface21
> > > Spring Services from the Source
> > > http://www.interface21.com
> > >
> > > Co-author, "Expert Spring MVC and Web Flow"
> > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > http://www.amazon.com/gp/product/159059584X
> > >
> > > Interface21 NL B.V.
> > > Donker Curtiusstraat 7-400c
> > > 1051JL Amsterdam
> > > The Netherlands
> > > Phone: +31 (0)20 486 47 63
> > > Fax: +31 (0)20 475 08 28
> > > Mail: [hidden email]
> > > Skype: devijvers
> > >
> >
>
>
> --
> Steven Devijver
> Senior Consultant
> Interface21
> Spring Services from the Source
> http://www.interface21.com
>
> Co-author, "Expert Spring MVC and Web Flow"
> (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> http://www.amazon.com/gp/product/159059584X
>
> Interface21 NL B.V.
> Donker Curtiusstraat 7-400c
> 1051JL Amsterdam
> The Netherlands
> Phone: +31 (0)20 486 47 63
> Fax: +31 (0)20 475 08 28
> Mail: [hidden email]
> Skype: devijvers
>
Reply | Threaded
Open this post in threaded view
|

Re: New Scaffolding Docs

Steven Devijver
On 2/27/06, Graeme Rocher <[hidden email]> wrote:

> On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > > > > Hey Graeme,
> > > > > >
> > > > > > This is perfect, it really is. The movie is going to be awesome!
> > > > > >
> > > > > > One thing I would like to change is a small detail in the Validation
> > > > > > section. It's not entirely clear where the constraints have to be
> > > > > > added: in the controller or in the domain class.
> > > > >
> > > > > Good point. I will change this.
> > > > >
> > > > > >
> > > > > > Also, how to these constraints work if I use Java domain classes? I
> > > > > > would also point out how to register your Java classes with the
> > > > > > SessionFactory.
> > > > >
> > > > > There is an example in CVS in "samples/recipes" that demonstrates java
> > > > > integration.  Its something like:
> > > > >
> > > > >     @Transient
> > > > >     public Map getConstraints() {
> > > > >         ConstrainedProperty titleConstraint = new
> > > > > ConstrainedPersistentProperty(getClass(), "title", String.class );
> > > > >         titleConstraint.setOrder(1);
> > > > >         titleConstraint.setLength(new IntRange(5,15));
> > > > >         ConstrainedProperty descConstraint = new
> > > > > ConstrainedPersistentProperty(getClass(), "title", String.class );
> > > > >         descConstraint.setOrder(2);
> > > > >         descConstraint.setWidget("textarea");
> > > > >
> > > > >
> > > > >         List constraints = new ArrayList();
> > > > >         constraints.add(titleConstraint);
> > > > >         constraints.add(descConstraint);
> > > > >
> > > > >         return constraints;
> > > > >     }
> > > >
> > > > Do you think it's possible to put the constraints in the controller?
> >
> > It doesn't make sense to me to add constraints to domain classes that
> > are related to the view and that are specific to Grails. That's why it
> > sounds like a pleasant decoupling to put the constraints in the
> > controller. After all, adding the constraints to the Java classes is
> > too much work :-) And it would be a better encouragement for users to
> > get started.
>
> True if you're writing them in java it probably will be a bit painful,
> but no more so than RIFE's constraint mechanism for example.
>
> The constraints are related to thhe domain class because thats the way
> its done in other frameworks, but not necessarily how it should be
> done, I'm open to ideas how would you imagine it working in a
> controller? per action? or as validator instance?
>

I suggest we go our own way, I think putting the constraints in Java
classes is plain wrong.  I would be very nice to see that *any*
existing Hibernate-mapped class can be reused in Grails with the full
flexibility of the framework without affecting existing classes.

BTW, can I also add Hibernate mapping files to the Hibernate config
file? It would be nice to document how this works, since many people
are still using these files.

Steven

>
> >
> >
> > >
> > > Anythings possible :-)
> > > The constraints are just built up by instances of
> > > org.codehaus.groovy.grails.orm.hibernate.validation.ConstrainedPersistentProperty
> > > using a builder.. so these could be placed anywere really..
> > > The builder used is
> > > org.codehaus.groovy.grails.validation.ConstrainedPropertyBuilder.
> > >
> > > What do you have in mind anyway?
> > >
> > > BTW the docs on Hibernate Integration have been updated with more info
> > > on java integration: http://grails.codehaus.org/Hibernate+Integration
> > >
> > > and I've added more to the original scaffolding docs about java integration
> > >
> > > Graeme
> > > >
> > > > >
> > > > > The example in CVS uses Hibernate annotations and the entry in
> > > > > hibernate.cfg.xml looks like:
> > > > >
> > > > > <hibernate-configuration>
> > > > >     <session-factory>
> > > > >         <mapping package="com.recipes" />
> > > > >         <mapping class="com.recipes.Recipe" />
> > > > >     </session-factory>
> > > > > </hibernate-configuration>
> > > > >
> > > > > Maybe I will add a section on scaffolding hibernate mapped classes
> > > > >
> > > > > Graeme
> > > > >
> > > > >
> > > > > >
> > > > > > Steven
> > > > > >
> > > > > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > > > > With screenshots: http://grails.codehaus.org/Scaffolding
> > > > > > >
> > > > > > > Next thing to do is the movie...
> > > > > > >
> > > > > > > Graeme
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Steven Devijver
> > > > > > Senior Consultant
> > > > > > Interface21
> > > > > > Spring Services from the Source
> > > > > > http://www.interface21.com
> > > > > >
> > > > > > Co-author, "Expert Spring MVC and Web Flow"
> > > > > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > > > > http://www.amazon.com/gp/product/159059584X
> > > > > >
> > > > > > Interface21 NL B.V.
> > > > > > Donker Curtiusstraat 7-400c
> > > > > > 1051JL Amsterdam
> > > > > > The Netherlands
> > > > > > Phone: +31 (0)20 486 47 63
> > > > > > Fax: +31 (0)20 475 08 28
> > > > > > Mail: [hidden email]
> > > > > > Skype: devijvers
> > > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > Steven Devijver
> > > > Senior Consultant
> > > > Interface21
> > > > Spring Services from the Source
> > > > http://www.interface21.com
> > > >
> > > > Co-author, "Expert Spring MVC and Web Flow"
> > > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > > http://www.amazon.com/gp/product/159059584X
> > > >
> > > > Interface21 NL B.V.
> > > > Donker Curtiusstraat 7-400c
> > > > 1051JL Amsterdam
> > > > The Netherlands
> > > > Phone: +31 (0)20 486 47 63
> > > > Fax: +31 (0)20 475 08 28
> > > > Mail: [hidden email]
> > > > Skype: devijvers
> > > >
> > >
> >
> >
> > --
> > Steven Devijver
> > Senior Consultant
> > Interface21
> > Spring Services from the Source
> > http://www.interface21.com
> >
> > Co-author, "Expert Spring MVC and Web Flow"
> > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > http://www.amazon.com/gp/product/159059584X
> >
> > Interface21 NL B.V.
> > Donker Curtiusstraat 7-400c
> > 1051JL Amsterdam
> > The Netherlands
> > Phone: +31 (0)20 486 47 63
> > Fax: +31 (0)20 475 08 28
> > Mail: [hidden email]
> > Skype: devijvers
> >
>


--
Steven Devijver
Senior Consultant
Interface21
Spring Services from the Source
http://www.interface21.com

Co-author, "Expert Spring MVC and Web Flow"
(February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
http://www.amazon.com/gp/product/159059584X

Interface21 NL B.V.
Donker Curtiusstraat 7-400c
1051JL Amsterdam
The Netherlands
Phone: +31 (0)20 486 47 63
Fax: +31 (0)20 475 08 28
Mail: [hidden email]
Skype: devijvers
Reply | Threaded
Open this post in threaded view
|

Re: New Scaffolding Docs

graemer
On 27/02/06, Steven Devijver <[hidden email]> wrote:

> On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > > > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > > > > > Hey Graeme,
> > > > > > >
> > > > > > > This is perfect, it really is. The movie is going to be awesome!
> > > > > > >
> > > > > > > One thing I would like to change is a small detail in the Validation
> > > > > > > section. It's not entirely clear where the constraints have to be
> > > > > > > added: in the controller or in the domain class.
> > > > > >
> > > > > > Good point. I will change this.
> > > > > >
> > > > > > >
> > > > > > > Also, how to these constraints work if I use Java domain classes? I
> > > > > > > would also point out how to register your Java classes with the
> > > > > > > SessionFactory.
> > > > > >
> > > > > > There is an example in CVS in "samples/recipes" that demonstrates java
> > > > > > integration.  Its something like:
> > > > > >
> > > > > >     @Transient
> > > > > >     public Map getConstraints() {
> > > > > >         ConstrainedProperty titleConstraint = new
> > > > > > ConstrainedPersistentProperty(getClass(), "title", String.class );
> > > > > >         titleConstraint.setOrder(1);
> > > > > >         titleConstraint.setLength(new IntRange(5,15));
> > > > > >         ConstrainedProperty descConstraint = new
> > > > > > ConstrainedPersistentProperty(getClass(), "title", String.class );
> > > > > >         descConstraint.setOrder(2);
> > > > > >         descConstraint.setWidget("textarea");
> > > > > >
> > > > > >
> > > > > >         List constraints = new ArrayList();
> > > > > >         constraints.add(titleConstraint);
> > > > > >         constraints.add(descConstraint);
> > > > > >
> > > > > >         return constraints;
> > > > > >     }
> > > > >
> > > > > Do you think it's possible to put the constraints in the controller?
> > >
> > > It doesn't make sense to me to add constraints to domain classes that
> > > are related to the view and that are specific to Grails. That's why it
> > > sounds like a pleasant decoupling to put the constraints in the
> > > controller. After all, adding the constraints to the Java classes is
> > > too much work :-) And it would be a better encouragement for users to
> > > get started.
> >
> > True if you're writing them in java it probably will be a bit painful,
> > but no more so than RIFE's constraint mechanism for example.
> >
> > The constraints are related to thhe domain class because thats the way
> > its done in other frameworks, but not necessarily how it should be
> > done, I'm open to ideas how would you imagine it working in a
> > controller? per action? or as validator instance?
> >
>
> I suggest we go our own way, I think putting the constraints in Java
> classes is plain wrong.  I would be very nice to see that *any*
> existing Hibernate-mapped class can be reused in Grails with the full
> flexibility of the framework without affecting existing classes.

Yes I agree with you. I will give it some thought as to how we can do this

>
> BTW, can I also add Hibernate mapping files to the Hibernate config
> file? It would be nice to document how this works, since many people
> are still using these files.

Yes you can. I don't have any of these to hand, but essentially you
just add your mapping files to the classpath either in the src/java
directory along side your classes or in the hibernate directory

>
> Steven
>
> >
> > >
> > >
> > > >
> > > > Anythings possible :-)
> > > > The constraints are just built up by instances of
> > > > org.codehaus.groovy.grails.orm.hibernate.validation.ConstrainedPersistentProperty
> > > > using a builder.. so these could be placed anywere really..
> > > > The builder used is
> > > > org.codehaus.groovy.grails.validation.ConstrainedPropertyBuilder.
> > > >
> > > > What do you have in mind anyway?
> > > >
> > > > BTW the docs on Hibernate Integration have been updated with more info
> > > > on java integration: http://grails.codehaus.org/Hibernate+Integration
> > > >
> > > > and I've added more to the original scaffolding docs about java integration
> > > >
> > > > Graeme
> > > > >
> > > > > >
> > > > > > The example in CVS uses Hibernate annotations and the entry in
> > > > > > hibernate.cfg.xml looks like:
> > > > > >
> > > > > > <hibernate-configuration>
> > > > > >     <session-factory>
> > > > > >         <mapping package="com.recipes" />
> > > > > >         <mapping class="com.recipes.Recipe" />
> > > > > >     </session-factory>
> > > > > > </hibernate-configuration>
> > > > > >
> > > > > > Maybe I will add a section on scaffolding hibernate mapped classes
> > > > > >
> > > > > > Graeme
> > > > > >
> > > > > >
> > > > > > >
> > > > > > > Steven
> > > > > > >
> > > > > > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > > > > > With screenshots: http://grails.codehaus.org/Scaffolding
> > > > > > > >
> > > > > > > > Next thing to do is the movie...
> > > > > > > >
> > > > > > > > Graeme
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Steven Devijver
> > > > > > > Senior Consultant
> > > > > > > Interface21
> > > > > > > Spring Services from the Source
> > > > > > > http://www.interface21.com
> > > > > > >
> > > > > > > Co-author, "Expert Spring MVC and Web Flow"
> > > > > > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > > > > > http://www.amazon.com/gp/product/159059584X
> > > > > > >
> > > > > > > Interface21 NL B.V.
> > > > > > > Donker Curtiusstraat 7-400c
> > > > > > > 1051JL Amsterdam
> > > > > > > The Netherlands
> > > > > > > Phone: +31 (0)20 486 47 63
> > > > > > > Fax: +31 (0)20 475 08 28
> > > > > > > Mail: [hidden email]
> > > > > > > Skype: devijvers
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Steven Devijver
> > > > > Senior Consultant
> > > > > Interface21
> > > > > Spring Services from the Source
> > > > > http://www.interface21.com
> > > > >
> > > > > Co-author, "Expert Spring MVC and Web Flow"
> > > > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > > > http://www.amazon.com/gp/product/159059584X
> > > > >
> > > > > Interface21 NL B.V.
> > > > > Donker Curtiusstraat 7-400c
> > > > > 1051JL Amsterdam
> > > > > The Netherlands
> > > > > Phone: +31 (0)20 486 47 63
> > > > > Fax: +31 (0)20 475 08 28
> > > > > Mail: [hidden email]
> > > > > Skype: devijvers
> > > > >
> > > >
> > >
> > >
> > > --
> > > Steven Devijver
> > > Senior Consultant
> > > Interface21
> > > Spring Services from the Source
> > > http://www.interface21.com
> > >
> > > Co-author, "Expert Spring MVC and Web Flow"
> > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > http://www.amazon.com/gp/product/159059584X
> > >
> > > Interface21 NL B.V.
> > > Donker Curtiusstraat 7-400c
> > > 1051JL Amsterdam
> > > The Netherlands
> > > Phone: +31 (0)20 486 47 63
> > > Fax: +31 (0)20 475 08 28
> > > Mail: [hidden email]
> > > Skype: devijvers
> > >
> >
>
>
> --
> Steven Devijver
> Senior Consultant
> Interface21
> Spring Services from the Source
> http://www.interface21.com
>
> Co-author, "Expert Spring MVC and Web Flow"
> (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> http://www.amazon.com/gp/product/159059584X
>
> Interface21 NL B.V.
> Donker Curtiusstraat 7-400c
> 1051JL Amsterdam
> The Netherlands
> Phone: +31 (0)20 486 47 63
> Fax: +31 (0)20 475 08 28
> Mail: [hidden email]
> Skype: devijvers
>
Reply | Threaded
Open this post in threaded view
|

Re: New Scaffolding Docs

graemer
Right I've given it some thought ;-)

The issue I have is that at the moment its really great having the
constraints in the domain class for grails domain classes, as they're
concise to define easy to access and it means you can unit test your
constraints.

But I see your point about the ability to define them elsewhere, but
I'm not convinced the controller is the right place for them either,
what you need is the ability to associate constraints with a class but
without that necessarily being part of the class.. those constraints
should still be picked up by the "validate()" method etc.

So the code would be something like:

@Property myConstraints = {
       name(length:5..15)
       email(email:true)
}

And then we need something to map them like this:

@Property constraintMappings = [  User.class : myConstraints ]

But where do these live? In the controller? I think not as these are
prototypes... maybe in some other artifact like
"ApplicationConstraints" or maybe we need a more general one like
"ApplicationConfiguration"

What do you think?

Graeme


On 27/02/06, Graeme Rocher <[hidden email]> wrote:

> On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > > > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > > > > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > > > > > > Hey Graeme,
> > > > > > > >
> > > > > > > > This is perfect, it really is. The movie is going to be awesome!
> > > > > > > >
> > > > > > > > One thing I would like to change is a small detail in the Validation
> > > > > > > > section. It's not entirely clear where the constraints have to be
> > > > > > > > added: in the controller or in the domain class.
> > > > > > >
> > > > > > > Good point. I will change this.
> > > > > > >
> > > > > > > >
> > > > > > > > Also, how to these constraints work if I use Java domain classes? I
> > > > > > > > would also point out how to register your Java classes with the
> > > > > > > > SessionFactory.
> > > > > > >
> > > > > > > There is an example in CVS in "samples/recipes" that demonstrates java
> > > > > > > integration.  Its something like:
> > > > > > >
> > > > > > >     @Transient
> > > > > > >     public Map getConstraints() {
> > > > > > >         ConstrainedProperty titleConstraint = new
> > > > > > > ConstrainedPersistentProperty(getClass(), "title", String.class );
> > > > > > >         titleConstraint.setOrder(1);
> > > > > > >         titleConstraint.setLength(new IntRange(5,15));
> > > > > > >         ConstrainedProperty descConstraint = new
> > > > > > > ConstrainedPersistentProperty(getClass(), "title", String.class );
> > > > > > >         descConstraint.setOrder(2);
> > > > > > >         descConstraint.setWidget("textarea");
> > > > > > >
> > > > > > >
> > > > > > >         List constraints = new ArrayList();
> > > > > > >         constraints.add(titleConstraint);
> > > > > > >         constraints.add(descConstraint);
> > > > > > >
> > > > > > >         return constraints;
> > > > > > >     }
> > > > > >
> > > > > > Do you think it's possible to put the constraints in the controller?
> > > >
> > > > It doesn't make sense to me to add constraints to domain classes that
> > > > are related to the view and that are specific to Grails. That's why it
> > > > sounds like a pleasant decoupling to put the constraints in the
> > > > controller. After all, adding the constraints to the Java classes is
> > > > too much work :-) And it would be a better encouragement for users to
> > > > get started.
> > >
> > > True if you're writing them in java it probably will be a bit painful,
> > > but no more so than RIFE's constraint mechanism for example.
> > >
> > > The constraints are related to thhe domain class because thats the way
> > > its done in other frameworks, but not necessarily how it should be
> > > done, I'm open to ideas how would you imagine it working in a
> > > controller? per action? or as validator instance?
> > >
> >
> > I suggest we go our own way, I think putting the constraints in Java
> > classes is plain wrong.  I would be very nice to see that *any*
> > existing Hibernate-mapped class can be reused in Grails with the full
> > flexibility of the framework without affecting existing classes.
>
> Yes I agree with you. I will give it some thought as to how we can do this
>
> >
> > BTW, can I also add Hibernate mapping files to the Hibernate config
> > file? It would be nice to document how this works, since many people
> > are still using these files.
>
> Yes you can. I don't have any of these to hand, but essentially you
> just add your mapping files to the classpath either in the src/java
> directory along side your classes or in the hibernate directory
>
> >
> > Steven
> >
> > >
> > > >
> > > >
> > > > >
> > > > > Anythings possible :-)
> > > > > The constraints are just built up by instances of
> > > > > org.codehaus.groovy.grails.orm.hibernate.validation.ConstrainedPersistentProperty
> > > > > using a builder.. so these could be placed anywere really..
> > > > > The builder used is
> > > > > org.codehaus.groovy.grails.validation.ConstrainedPropertyBuilder.
> > > > >
> > > > > What do you have in mind anyway?
> > > > >
> > > > > BTW the docs on Hibernate Integration have been updated with more info
> > > > > on java integration: http://grails.codehaus.org/Hibernate+Integration
> > > > >
> > > > > and I've added more to the original scaffolding docs about java integration
> > > > >
> > > > > Graeme
> > > > > >
> > > > > > >
> > > > > > > The example in CVS uses Hibernate annotations and the entry in
> > > > > > > hibernate.cfg.xml looks like:
> > > > > > >
> > > > > > > <hibernate-configuration>
> > > > > > >     <session-factory>
> > > > > > >         <mapping package="com.recipes" />
> > > > > > >         <mapping class="com.recipes.Recipe" />
> > > > > > >     </session-factory>
> > > > > > > </hibernate-configuration>
> > > > > > >
> > > > > > > Maybe I will add a section on scaffolding hibernate mapped classes
> > > > > > >
> > > > > > > Graeme
> > > > > > >
> > > > > > >
> > > > > > > >
> > > > > > > > Steven
> > > > > > > >
> > > > > > > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > > > > > > With screenshots: http://grails.codehaus.org/Scaffolding
> > > > > > > > >
> > > > > > > > > Next thing to do is the movie...
> > > > > > > > >
> > > > > > > > > Graeme
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Steven Devijver
> > > > > > > > Senior Consultant
> > > > > > > > Interface21
> > > > > > > > Spring Services from the Source
> > > > > > > > http://www.interface21.com
> > > > > > > >
> > > > > > > > Co-author, "Expert Spring MVC and Web Flow"
> > > > > > > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > > > > > > http://www.amazon.com/gp/product/159059584X
> > > > > > > >
> > > > > > > > Interface21 NL B.V.
> > > > > > > > Donker Curtiusstraat 7-400c
> > > > > > > > 1051JL Amsterdam
> > > > > > > > The Netherlands
> > > > > > > > Phone: +31 (0)20 486 47 63
> > > > > > > > Fax: +31 (0)20 475 08 28
> > > > > > > > Mail: [hidden email]
> > > > > > > > Skype: devijvers
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Steven Devijver
> > > > > > Senior Consultant
> > > > > > Interface21
> > > > > > Spring Services from the Source
> > > > > > http://www.interface21.com
> > > > > >
> > > > > > Co-author, "Expert Spring MVC and Web Flow"
> > > > > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > > > > http://www.amazon.com/gp/product/159059584X
> > > > > >
> > > > > > Interface21 NL B.V.
> > > > > > Donker Curtiusstraat 7-400c
> > > > > > 1051JL Amsterdam
> > > > > > The Netherlands
> > > > > > Phone: +31 (0)20 486 47 63
> > > > > > Fax: +31 (0)20 475 08 28
> > > > > > Mail: [hidden email]
> > > > > > Skype: devijvers
> > > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > Steven Devijver
> > > > Senior Consultant
> > > > Interface21
> > > > Spring Services from the Source
> > > > http://www.interface21.com
> > > >
> > > > Co-author, "Expert Spring MVC and Web Flow"
> > > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > > http://www.amazon.com/gp/product/159059584X
> > > >
> > > > Interface21 NL B.V.
> > > > Donker Curtiusstraat 7-400c
> > > > 1051JL Amsterdam
> > > > The Netherlands
> > > > Phone: +31 (0)20 486 47 63
> > > > Fax: +31 (0)20 475 08 28
> > > > Mail: [hidden email]
> > > > Skype: devijvers
> > > >
> > >
> >
> >
> > --
> > Steven Devijver
> > Senior Consultant
> > Interface21
> > Spring Services from the Source
> > http://www.interface21.com
> >
> > Co-author, "Expert Spring MVC and Web Flow"
> > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > http://www.amazon.com/gp/product/159059584X
> >
> > Interface21 NL B.V.
> > Donker Curtiusstraat 7-400c
> > 1051JL Amsterdam
> > The Netherlands
> > Phone: +31 (0)20 486 47 63
> > Fax: +31 (0)20 475 08 28
> > Mail: [hidden email]
> > Skype: devijvers
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: New Scaffolding Docs

Steven Devijver
On 2/27/06, Graeme Rocher <[hidden email]> wrote:

> Right I've given it some thought ;-)
>
> The issue I have is that at the moment its really great having the
> constraints in the domain class for grails domain classes, as they're
> concise to define easy to access and it means you can unit test your
> constraints.
>
> But I see your point about the ability to define them elsewhere, but
> I'm not convinced the controller is the right place for them either,
> what you need is the ability to associate constraints with a class but
> without that necessarily being part of the class.. those constraints
> should still be picked up by the "validate()" method etc.
>
> So the code would be something like:
>
> @Property myConstraints = {
>        name(length:5..15)
>        email(email:true)
> }
>
> And then we need something to map them like this:
>
> @Property constraintMappings = [  User.class : myConstraints ]
>
> But where do these live? In the controller? I think not as these are
> prototypes... maybe in some other artifact like
> "ApplicationConstraints" or maybe we need a more general one like
> "ApplicationConfiguration"
>
> What do you think?

Interesting point, I would go for a DomainConstraint artifact as these
constraints are specifically related to the Domain classes.

Steven

>
> Graeme
>
>
> On 27/02/06, Graeme Rocher <[hidden email]> wrote:
> > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > > > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > > > > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > > > > > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > > > > > > > Hey Graeme,
> > > > > > > > >
> > > > > > > > > This is perfect, it really is. The movie is going to be awesome!
> > > > > > > > >
> > > > > > > > > One thing I would like to change is a small detail in the Validation
> > > > > > > > > section. It's not entirely clear where the constraints have to be
> > > > > > > > > added: in the controller or in the domain class.
> > > > > > > >
> > > > > > > > Good point. I will change this.
> > > > > > > >
> > > > > > > > >
> > > > > > > > > Also, how to these constraints work if I use Java domain classes? I
> > > > > > > > > would also point out how to register your Java classes with the
> > > > > > > > > SessionFactory.
> > > > > > > >
> > > > > > > > There is an example in CVS in "samples/recipes" that demonstrates java
> > > > > > > > integration.  Its something like:
> > > > > > > >
> > > > > > > >     @Transient
> > > > > > > >     public Map getConstraints() {
> > > > > > > >         ConstrainedProperty titleConstraint = new
> > > > > > > > ConstrainedPersistentProperty(getClass(), "title", String.class );
> > > > > > > >         titleConstraint.setOrder(1);
> > > > > > > >         titleConstraint.setLength(new IntRange(5,15));
> > > > > > > >         ConstrainedProperty descConstraint = new
> > > > > > > > ConstrainedPersistentProperty(getClass(), "title", String.class );
> > > > > > > >         descConstraint.setOrder(2);
> > > > > > > >         descConstraint.setWidget("textarea");
> > > > > > > >
> > > > > > > >
> > > > > > > >         List constraints = new ArrayList();
> > > > > > > >         constraints.add(titleConstraint);
> > > > > > > >         constraints.add(descConstraint);
> > > > > > > >
> > > > > > > >         return constraints;
> > > > > > > >     }
> > > > > > >
> > > > > > > Do you think it's possible to put the constraints in the controller?
> > > > >
> > > > > It doesn't make sense to me to add constraints to domain classes that
> > > > > are related to the view and that are specific to Grails. That's why it
> > > > > sounds like a pleasant decoupling to put the constraints in the
> > > > > controller. After all, adding the constraints to the Java classes is
> > > > > too much work :-) And it would be a better encouragement for users to
> > > > > get started.
> > > >
> > > > True if you're writing them in java it probably will be a bit painful,
> > > > but no more so than RIFE's constraint mechanism for example.
> > > >
> > > > The constraints are related to thhe domain class because thats the way
> > > > its done in other frameworks, but not necessarily how it should be
> > > > done, I'm open to ideas how would you imagine it working in a
> > > > controller? per action? or as validator instance?
> > > >
> > >
> > > I suggest we go our own way, I think putting the constraints in Java
> > > classes is plain wrong.  I would be very nice to see that *any*
> > > existing Hibernate-mapped class can be reused in Grails with the full
> > > flexibility of the framework without affecting existing classes.
> >
> > Yes I agree with you. I will give it some thought as to how we can do this
> >
> > >
> > > BTW, can I also add Hibernate mapping files to the Hibernate config
> > > file? It would be nice to document how this works, since many people
> > > are still using these files.
> >
> > Yes you can. I don't have any of these to hand, but essentially you
> > just add your mapping files to the classpath either in the src/java
> > directory along side your classes or in the hibernate directory
> >
> > >
> > > Steven
> > >
> > > >
> > > > >
> > > > >
> > > > > >
> > > > > > Anythings possible :-)
> > > > > > The constraints are just built up by instances of
> > > > > > org.codehaus.groovy.grails.orm.hibernate.validation.ConstrainedPersistentProperty
> > > > > > using a builder.. so these could be placed anywere really..
> > > > > > The builder used is
> > > > > > org.codehaus.groovy.grails.validation.ConstrainedPropertyBuilder.
> > > > > >
> > > > > > What do you have in mind anyway?
> > > > > >
> > > > > > BTW the docs on Hibernate Integration have been updated with more info
> > > > > > on java integration: http://grails.codehaus.org/Hibernate+Integration
> > > > > >
> > > > > > and I've added more to the original scaffolding docs about java integration
> > > > > >
> > > > > > Graeme
> > > > > > >
> > > > > > > >
> > > > > > > > The example in CVS uses Hibernate annotations and the entry in
> > > > > > > > hibernate.cfg.xml looks like:
> > > > > > > >
> > > > > > > > <hibernate-configuration>
> > > > > > > >     <session-factory>
> > > > > > > >         <mapping package="com.recipes" />
> > > > > > > >         <mapping class="com.recipes.Recipe" />
> > > > > > > >     </session-factory>
> > > > > > > > </hibernate-configuration>
> > > > > > > >
> > > > > > > > Maybe I will add a section on scaffolding hibernate mapped classes
> > > > > > > >
> > > > > > > > Graeme
> > > > > > > >
> > > > > > > >
> > > > > > > > >
> > > > > > > > > Steven
> > > > > > > > >
> > > > > > > > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > > > > > > > With screenshots: http://grails.codehaus.org/Scaffolding
> > > > > > > > > >
> > > > > > > > > > Next thing to do is the movie...
> > > > > > > > > >
> > > > > > > > > > Graeme
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > Steven Devijver
> > > > > > > > > Senior Consultant
> > > > > > > > > Interface21
> > > > > > > > > Spring Services from the Source
> > > > > > > > > http://www.interface21.com
> > > > > > > > >
> > > > > > > > > Co-author, "Expert Spring MVC and Web Flow"
> > > > > > > > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > > > > > > > http://www.amazon.com/gp/product/159059584X
> > > > > > > > >
> > > > > > > > > Interface21 NL B.V.
> > > > > > > > > Donker Curtiusstraat 7-400c
> > > > > > > > > 1051JL Amsterdam
> > > > > > > > > The Netherlands
> > > > > > > > > Phone: +31 (0)20 486 47 63
> > > > > > > > > Fax: +31 (0)20 475 08 28
> > > > > > > > > Mail: [hidden email]
> > > > > > > > > Skype: devijvers
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Steven Devijver
> > > > > > > Senior Consultant
> > > > > > > Interface21
> > > > > > > Spring Services from the Source
> > > > > > > http://www.interface21.com
> > > > > > >
> > > > > > > Co-author, "Expert Spring MVC and Web Flow"
> > > > > > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > > > > > http://www.amazon.com/gp/product/159059584X
> > > > > > >
> > > > > > > Interface21 NL B.V.
> > > > > > > Donker Curtiusstraat 7-400c
> > > > > > > 1051JL Amsterdam
> > > > > > > The Netherlands
> > > > > > > Phone: +31 (0)20 486 47 63
> > > > > > > Fax: +31 (0)20 475 08 28
> > > > > > > Mail: [hidden email]
> > > > > > > Skype: devijvers
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Steven Devijver
> > > > > Senior Consultant
> > > > > Interface21
> > > > > Spring Services from the Source
> > > > > http://www.interface21.com
> > > > >
> > > > > Co-author, "Expert Spring MVC and Web Flow"
> > > > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > > > http://www.amazon.com/gp/product/159059584X
> > > > >
> > > > > Interface21 NL B.V.
> > > > > Donker Curtiusstraat 7-400c
> > > > > 1051JL Amsterdam
> > > > > The Netherlands
> > > > > Phone: +31 (0)20 486 47 63
> > > > > Fax: +31 (0)20 475 08 28
> > > > > Mail: [hidden email]
> > > > > Skype: devijvers
> > > > >
> > > >
> > >
> > >
> > > --
> > > Steven Devijver
> > > Senior Consultant
> > > Interface21
> > > Spring Services from the Source
> > > http://www.interface21.com
> > >
> > > Co-author, "Expert Spring MVC and Web Flow"
> > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > http://www.amazon.com/gp/product/159059584X
> > >
> > > Interface21 NL B.V.
> > > Donker Curtiusstraat 7-400c
> > > 1051JL Amsterdam
> > > The Netherlands
> > > Phone: +31 (0)20 486 47 63
> > > Fax: +31 (0)20 475 08 28
> > > Mail: [hidden email]
> > > Skype: devijvers
> > >
> >
>


--
Steven Devijver
Senior Consultant
Interface21
Spring Services from the Source
http://www.interface21.com

Co-author, "Expert Spring MVC and Web Flow"
(February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
http://www.amazon.com/gp/product/159059584X

Interface21 NL B.V.
Donker Curtiusstraat 7-400c
1051JL Amsterdam
The Netherlands
Phone: +31 (0)20 486 47 63
Fax: +31 (0)20 475 08 28
Mail: [hidden email]
Skype: devijvers
Reply | Threaded
Open this post in threaded view
|

Re: New Scaffolding Docs

graemer
Initial docs on Ajax support are now also there:

http://grails.codehaus.org/Ajax?nocache

Cheers
Graeme

On 27/02/06, Steven Devijver <[hidden email]> wrote:

> On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > Right I've given it some thought ;-)
> >
> > The issue I have is that at the moment its really great having the
> > constraints in the domain class for grails domain classes, as they're
> > concise to define easy to access and it means you can unit test your
> > constraints.
> >
> > But I see your point about the ability to define them elsewhere, but
> > I'm not convinced the controller is the right place for them either,
> > what you need is the ability to associate constraints with a class but
> > without that necessarily being part of the class.. those constraints
> > should still be picked up by the "validate()" method etc.
> >
> > So the code would be something like:
> >
> > @Property myConstraints = {
> >        name(length:5..15)
> >        email(email:true)
> > }
> >
> > And then we need something to map them like this:
> >
> > @Property constraintMappings = [  User.class : myConstraints ]
> >
> > But where do these live? In the controller? I think not as these are
> > prototypes... maybe in some other artifact like
> > "ApplicationConstraints" or maybe we need a more general one like
> > "ApplicationConfiguration"
> >
> > What do you think?
>
> Interesting point, I would go for a DomainConstraint artifact as these
> constraints are specifically related to the Domain classes.
>
> Steven
>
> >
> > Graeme
> >
> >
> > On 27/02/06, Graeme Rocher <[hidden email]> wrote:
> > > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > > > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > > > > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > > > > > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > > > > > > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > > > > > > > > Hey Graeme,
> > > > > > > > > >
> > > > > > > > > > This is perfect, it really is. The movie is going to be awesome!
> > > > > > > > > >
> > > > > > > > > > One thing I would like to change is a small detail in the Validation
> > > > > > > > > > section. It's not entirely clear where the constraints have to be
> > > > > > > > > > added: in the controller or in the domain class.
> > > > > > > > >
> > > > > > > > > Good point. I will change this.
> > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Also, how to these constraints work if I use Java domain classes? I
> > > > > > > > > > would also point out how to register your Java classes with the
> > > > > > > > > > SessionFactory.
> > > > > > > > >
> > > > > > > > > There is an example in CVS in "samples/recipes" that demonstrates java
> > > > > > > > > integration.  Its something like:
> > > > > > > > >
> > > > > > > > >     @Transient
> > > > > > > > >     public Map getConstraints() {
> > > > > > > > >         ConstrainedProperty titleConstraint = new
> > > > > > > > > ConstrainedPersistentProperty(getClass(), "title", String.class );
> > > > > > > > >         titleConstraint.setOrder(1);
> > > > > > > > >         titleConstraint.setLength(new IntRange(5,15));
> > > > > > > > >         ConstrainedProperty descConstraint = new
> > > > > > > > > ConstrainedPersistentProperty(getClass(), "title", String.class );
> > > > > > > > >         descConstraint.setOrder(2);
> > > > > > > > >         descConstraint.setWidget("textarea");
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >         List constraints = new ArrayList();
> > > > > > > > >         constraints.add(titleConstraint);
> > > > > > > > >         constraints.add(descConstraint);
> > > > > > > > >
> > > > > > > > >         return constraints;
> > > > > > > > >     }
> > > > > > > >
> > > > > > > > Do you think it's possible to put the constraints in the controller?
> > > > > >
> > > > > > It doesn't make sense to me to add constraints to domain classes that
> > > > > > are related to the view and that are specific to Grails. That's why it
> > > > > > sounds like a pleasant decoupling to put the constraints in the
> > > > > > controller. After all, adding the constraints to the Java classes is
> > > > > > too much work :-) And it would be a better encouragement for users to
> > > > > > get started.
> > > > >
> > > > > True if you're writing them in java it probably will be a bit painful,
> > > > > but no more so than RIFE's constraint mechanism for example.
> > > > >
> > > > > The constraints are related to thhe domain class because thats the way
> > > > > its done in other frameworks, but not necessarily how it should be
> > > > > done, I'm open to ideas how would you imagine it working in a
> > > > > controller? per action? or as validator instance?
> > > > >
> > > >
> > > > I suggest we go our own way, I think putting the constraints in Java
> > > > classes is plain wrong.  I would be very nice to see that *any*
> > > > existing Hibernate-mapped class can be reused in Grails with the full
> > > > flexibility of the framework without affecting existing classes.
> > >
> > > Yes I agree with you. I will give it some thought as to how we can do this
> > >
> > > >
> > > > BTW, can I also add Hibernate mapping files to the Hibernate config
> > > > file? It would be nice to document how this works, since many people
> > > > are still using these files.
> > >
> > > Yes you can. I don't have any of these to hand, but essentially you
> > > just add your mapping files to the classpath either in the src/java
> > > directory along side your classes or in the hibernate directory
> > >
> > > >
> > > > Steven
> > > >
> > > > >
> > > > > >
> > > > > >
> > > > > > >
> > > > > > > Anythings possible :-)
> > > > > > > The constraints are just built up by instances of
> > > > > > > org.codehaus.groovy.grails.orm.hibernate.validation.ConstrainedPersistentProperty
> > > > > > > using a builder.. so these could be placed anywere really..
> > > > > > > The builder used is
> > > > > > > org.codehaus.groovy.grails.validation.ConstrainedPropertyBuilder.
> > > > > > >
> > > > > > > What do you have in mind anyway?
> > > > > > >
> > > > > > > BTW the docs on Hibernate Integration have been updated with more info
> > > > > > > on java integration: http://grails.codehaus.org/Hibernate+Integration
> > > > > > >
> > > > > > > and I've added more to the original scaffolding docs about java integration
> > > > > > >
> > > > > > > Graeme
> > > > > > > >
> > > > > > > > >
> > > > > > > > > The example in CVS uses Hibernate annotations and the entry in
> > > > > > > > > hibernate.cfg.xml looks like:
> > > > > > > > >
> > > > > > > > > <hibernate-configuration>
> > > > > > > > >     <session-factory>
> > > > > > > > >         <mapping package="com.recipes" />
> > > > > > > > >         <mapping class="com.recipes.Recipe" />
> > > > > > > > >     </session-factory>
> > > > > > > > > </hibernate-configuration>
> > > > > > > > >
> > > > > > > > > Maybe I will add a section on scaffolding hibernate mapped classes
> > > > > > > > >
> > > > > > > > > Graeme
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Steven
> > > > > > > > > >
> > > > > > > > > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > > > > > > > > With screenshots: http://grails.codehaus.org/Scaffolding
> > > > > > > > > > >
> > > > > > > > > > > Next thing to do is the movie...
> > > > > > > > > > >
> > > > > > > > > > > Graeme
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > > Steven Devijver
> > > > > > > > > > Senior Consultant
> > > > > > > > > > Interface21
> > > > > > > > > > Spring Services from the Source
> > > > > > > > > > http://www.interface21.com
> > > > > > > > > >
> > > > > > > > > > Co-author, "Expert Spring MVC and Web Flow"
> > > > > > > > > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > > > > > > > > http://www.amazon.com/gp/product/159059584X
> > > > > > > > > >
> > > > > > > > > > Interface21 NL B.V.
> > > > > > > > > > Donker Curtiusstraat 7-400c
> > > > > > > > > > 1051JL Amsterdam
> > > > > > > > > > The Netherlands
> > > > > > > > > > Phone: +31 (0)20 486 47 63
> > > > > > > > > > Fax: +31 (0)20 475 08 28
> > > > > > > > > > Mail: [hidden email]
> > > > > > > > > > Skype: devijvers
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Steven Devijver
> > > > > > > > Senior Consultant
> > > > > > > > Interface21
> > > > > > > > Spring Services from the Source
> > > > > > > > http://www.interface21.com
> > > > > > > >
> > > > > > > > Co-author, "Expert Spring MVC and Web Flow"
> > > > > > > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > > > > > > http://www.amazon.com/gp/product/159059584X
> > > > > > > >
> > > > > > > > Interface21 NL B.V.
> > > > > > > > Donker Curtiusstraat 7-400c
> > > > > > > > 1051JL Amsterdam
> > > > > > > > The Netherlands
> > > > > > > > Phone: +31 (0)20 486 47 63
> > > > > > > > Fax: +31 (0)20 475 08 28
> > > > > > > > Mail: [hidden email]
> > > > > > > > Skype: devijvers
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Steven Devijver
> > > > > > Senior Consultant
> > > > > > Interface21
> > > > > > Spring Services from the Source
> > > > > > http://www.interface21.com
> > > > > >
> > > > > > Co-author, "Expert Spring MVC and Web Flow"
> > > > > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > > > > http://www.amazon.com/gp/product/159059584X
> > > > > >
> > > > > > Interface21 NL B.V.
> > > > > > Donker Curtiusstraat 7-400c
> > > > > > 1051JL Amsterdam
> > > > > > The Netherlands
> > > > > > Phone: +31 (0)20 486 47 63
> > > > > > Fax: +31 (0)20 475 08 28
> > > > > > Mail: [hidden email]
> > > > > > Skype: devijvers
> > > > > >
> > > > >
> > > >
> > > >
> > > > --
> > > > Steven Devijver
> > > > Senior Consultant
> > > > Interface21
> > > > Spring Services from the Source
> > > > http://www.interface21.com
> > > >
> > > > Co-author, "Expert Spring MVC and Web Flow"
> > > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > > http://www.amazon.com/gp/product/159059584X
> > > >
> > > > Interface21 NL B.V.
> > > > Donker Curtiusstraat 7-400c
> > > > 1051JL Amsterdam
> > > > The Netherlands
> > > > Phone: +31 (0)20 486 47 63
> > > > Fax: +31 (0)20 475 08 28
> > > > Mail: [hidden email]
> > > > Skype: devijvers
> > > >
> > >
> >
>
>
> --
> Steven Devijver
> Senior Consultant
> Interface21
> Spring Services from the Source
> http://www.interface21.com
>
> Co-author, "Expert Spring MVC and Web Flow"
> (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> http://www.amazon.com/gp/product/159059584X
>
> Interface21 NL B.V.
> Donker Curtiusstraat 7-400c
> 1051JL Amsterdam
> The Netherlands
> Phone: +31 (0)20 486 47 63
> Fax: +31 (0)20 475 08 28
> Mail: [hidden email]
> Skype: devijvers
>
Reply | Threaded
Open this post in threaded view
|

Re: New Scaffolding Docs

Steven Devijver
Graeme, these docs are great!

One remarks, at the end of the document you mention a formRemote tag
but in the subsequent code sample you use the g:form tag. Is this ok?

Steven

On 2/27/06, Graeme Rocher <[hidden email]> wrote:

> Initial docs on Ajax support are now also there:
>
> http://grails.codehaus.org/Ajax?nocache
>
> Cheers
> Graeme
>
> On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > Right I've given it some thought ;-)
> > >
> > > The issue I have is that at the moment its really great having the
> > > constraints in the domain class for grails domain classes, as they're
> > > concise to define easy to access and it means you can unit test your
> > > constraints.
> > >
> > > But I see your point about the ability to define them elsewhere, but
> > > I'm not convinced the controller is the right place for them either,
> > > what you need is the ability to associate constraints with a class but
> > > without that necessarily being part of the class.. those constraints
> > > should still be picked up by the "validate()" method etc.
> > >
> > > So the code would be something like:
> > >
> > > @Property myConstraints = {
> > >        name(length:5..15)
> > >        email(email:true)
> > > }
> > >
> > > And then we need something to map them like this:
> > >
> > > @Property constraintMappings = [  User.class : myConstraints ]
> > >
> > > But where do these live? In the controller? I think not as these are
> > > prototypes... maybe in some other artifact like
> > > "ApplicationConstraints" or maybe we need a more general one like
> > > "ApplicationConfiguration"
> > >
> > > What do you think?
> >
> > Interesting point, I would go for a DomainConstraint artifact as these
> > constraints are specifically related to the Domain classes.
> >
> > Steven
> >
> > >
> > > Graeme
> > >
> > >
> > > On 27/02/06, Graeme Rocher <[hidden email]> wrote:
> > > > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > > > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > > > > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > > > > > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > > > > > > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > > > > > > > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > > > > > > > > > Hey Graeme,
> > > > > > > > > > >
> > > > > > > > > > > This is perfect, it really is. The movie is going to be awesome!
> > > > > > > > > > >
> > > > > > > > > > > One thing I would like to change is a small detail in the Validation
> > > > > > > > > > > section. It's not entirely clear where the constraints have to be
> > > > > > > > > > > added: in the controller or in the domain class.
> > > > > > > > > >
> > > > > > > > > > Good point. I will change this.
> > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Also, how to these constraints work if I use Java domain classes? I
> > > > > > > > > > > would also point out how to register your Java classes with the
> > > > > > > > > > > SessionFactory.
> > > > > > > > > >
> > > > > > > > > > There is an example in CVS in "samples/recipes" that demonstrates java
> > > > > > > > > > integration.  Its something like:
> > > > > > > > > >
> > > > > > > > > >     @Transient
> > > > > > > > > >     public Map getConstraints() {
> > > > > > > > > >         ConstrainedProperty titleConstraint = new
> > > > > > > > > > ConstrainedPersistentProperty(getClass(), "title", String.class );
> > > > > > > > > >         titleConstraint.setOrder(1);
> > > > > > > > > >         titleConstraint.setLength(new IntRange(5,15));
> > > > > > > > > >         ConstrainedProperty descConstraint = new
> > > > > > > > > > ConstrainedPersistentProperty(getClass(), "title", String.class );
> > > > > > > > > >         descConstraint.setOrder(2);
> > > > > > > > > >         descConstraint.setWidget("textarea");
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >         List constraints = new ArrayList();
> > > > > > > > > >         constraints.add(titleConstraint);
> > > > > > > > > >         constraints.add(descConstraint);
> > > > > > > > > >
> > > > > > > > > >         return constraints;
> > > > > > > > > >     }
> > > > > > > > >
> > > > > > > > > Do you think it's possible to put the constraints in the controller?
> > > > > > >
> > > > > > > It doesn't make sense to me to add constraints to domain classes that
> > > > > > > are related to the view and that are specific to Grails. That's why it
> > > > > > > sounds like a pleasant decoupling to put the constraints in the
> > > > > > > controller. After all, adding the constraints to the Java classes is
> > > > > > > too much work :-) And it would be a better encouragement for users to
> > > > > > > get started.
> > > > > >
> > > > > > True if you're writing them in java it probably will be a bit painful,
> > > > > > but no more so than RIFE's constraint mechanism for example.
> > > > > >
> > > > > > The constraints are related to thhe domain class because thats the way
> > > > > > its done in other frameworks, but not necessarily how it should be
> > > > > > done, I'm open to ideas how would you imagine it working in a
> > > > > > controller? per action? or as validator instance?
> > > > > >
> > > > >
> > > > > I suggest we go our own way, I think putting the constraints in Java
> > > > > classes is plain wrong.  I would be very nice to see that *any*
> > > > > existing Hibernate-mapped class can be reused in Grails with the full
> > > > > flexibility of the framework without affecting existing classes.
> > > >
> > > > Yes I agree with you. I will give it some thought as to how we can do this
> > > >
> > > > >
> > > > > BTW, can I also add Hibernate mapping files to the Hibernate config
> > > > > file? It would be nice to document how this works, since many people
> > > > > are still using these files.
> > > >
> > > > Yes you can. I don't have any of these to hand, but essentially you
> > > > just add your mapping files to the classpath either in the src/java
> > > > directory along side your classes or in the hibernate directory
> > > >
> > > > >
> > > > > Steven
> > > > >
> > > > > >
> > > > > > >
> > > > > > >
> > > > > > > >
> > > > > > > > Anythings possible :-)
> > > > > > > > The constraints are just built up by instances of
> > > > > > > > org.codehaus.groovy.grails.orm.hibernate.validation.ConstrainedPersistentProperty
> > > > > > > > using a builder.. so these could be placed anywere really..
> > > > > > > > The builder used is
> > > > > > > > org.codehaus.groovy.grails.validation.ConstrainedPropertyBuilder.
> > > > > > > >
> > > > > > > > What do you have in mind anyway?
> > > > > > > >
> > > > > > > > BTW the docs on Hibernate Integration have been updated with more info
> > > > > > > > on java integration: http://grails.codehaus.org/Hibernate+Integration
> > > > > > > >
> > > > > > > > and I've added more to the original scaffolding docs about java integration
> > > > > > > >
> > > > > > > > Graeme
> > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > The example in CVS uses Hibernate annotations and the entry in
> > > > > > > > > > hibernate.cfg.xml looks like:
> > > > > > > > > >
> > > > > > > > > > <hibernate-configuration>
> > > > > > > > > >     <session-factory>
> > > > > > > > > >         <mapping package="com.recipes" />
> > > > > > > > > >         <mapping class="com.recipes.Recipe" />
> > > > > > > > > >     </session-factory>
> > > > > > > > > > </hibernate-configuration>
> > > > > > > > > >
> > > > > > > > > > Maybe I will add a section on scaffolding hibernate mapped classes
> > > > > > > > > >
> > > > > > > > > > Graeme
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Steven
> > > > > > > > > > >
> > > > > > > > > > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > > > > > > > > > With screenshots: http://grails.codehaus.org/Scaffolding
> > > > > > > > > > > >
> > > > > > > > > > > > Next thing to do is the movie...
> > > > > > > > > > > >
> > > > > > > > > > > > Graeme
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > --
> > > > > > > > > > > Steven Devijver
> > > > > > > > > > > Senior Consultant
> > > > > > > > > > > Interface21
> > > > > > > > > > > Spring Services from the Source
> > > > > > > > > > > http://www.interface21.com
> > > > > > > > > > >
> > > > > > > > > > > Co-author, "Expert Spring MVC and Web Flow"
> > > > > > > > > > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > > > > > > > > > http://www.amazon.com/gp/product/159059584X
> > > > > > > > > > >
> > > > > > > > > > > Interface21 NL B.V.
> > > > > > > > > > > Donker Curtiusstraat 7-400c
> > > > > > > > > > > 1051JL Amsterdam
> > > > > > > > > > > The Netherlands
> > > > > > > > > > > Phone: +31 (0)20 486 47 63
> > > > > > > > > > > Fax: +31 (0)20 475 08 28
> > > > > > > > > > > Mail: [hidden email]
> > > > > > > > > > > Skype: devijvers
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > Steven Devijver
> > > > > > > > > Senior Consultant
> > > > > > > > > Interface21
> > > > > > > > > Spring Services from the Source
> > > > > > > > > http://www.interface21.com
> > > > > > > > >
> > > > > > > > > Co-author, "Expert Spring MVC and Web Flow"
> > > > > > > > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > > > > > > > http://www.amazon.com/gp/product/159059584X
> > > > > > > > >
> > > > > > > > > Interface21 NL B.V.
> > > > > > > > > Donker Curtiusstraat 7-400c
> > > > > > > > > 1051JL Amsterdam
> > > > > > > > > The Netherlands
> > > > > > > > > Phone: +31 (0)20 486 47 63
> > > > > > > > > Fax: +31 (0)20 475 08 28
> > > > > > > > > Mail: [hidden email]
> > > > > > > > > Skype: devijvers
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Steven Devijver
> > > > > > > Senior Consultant
> > > > > > > Interface21
> > > > > > > Spring Services from the Source
> > > > > > > http://www.interface21.com
> > > > > > >
> > > > > > > Co-author, "Expert Spring MVC and Web Flow"
> > > > > > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > > > > > http://www.amazon.com/gp/product/159059584X
> > > > > > >
> > > > > > > Interface21 NL B.V.
> > > > > > > Donker Curtiusstraat 7-400c
> > > > > > > 1051JL Amsterdam
> > > > > > > The Netherlands
> > > > > > > Phone: +31 (0)20 486 47 63
> > > > > > > Fax: +31 (0)20 475 08 28
> > > > > > > Mail: [hidden email]
> > > > > > > Skype: devijvers
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Steven Devijver
> > > > > Senior Consultant
> > > > > Interface21
> > > > > Spring Services from the Source
> > > > > http://www.interface21.com
> > > > >
> > > > > Co-author, "Expert Spring MVC and Web Flow"
> > > > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > > > http://www.amazon.com/gp/product/159059584X
> > > > >
> > > > > Interface21 NL B.V.
> > > > > Donker Curtiusstraat 7-400c
> > > > > 1051JL Amsterdam
> > > > > The Netherlands
> > > > > Phone: +31 (0)20 486 47 63
> > > > > Fax: +31 (0)20 475 08 28
> > > > > Mail: [hidden email]
> > > > > Skype: devijvers
> > > > >
> > > >
> > >
> >
> >
> > --
> > Steven Devijver
> > Senior Consultant
> > Interface21
> > Spring Services from the Source
> > http://www.interface21.com
> >
> > Co-author, "Expert Spring MVC and Web Flow"
> > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > http://www.amazon.com/gp/product/159059584X
> >
> > Interface21 NL B.V.
> > Donker Curtiusstraat 7-400c
> > 1051JL Amsterdam
> > The Netherlands
> > Phone: +31 (0)20 486 47 63
> > Fax: +31 (0)20 475 08 28
> > Mail: [hidden email]
> > Skype: devijvers
> >
>


--
Steven Devijver
Senior Consultant
Interface21
Spring Services from the Source
http://www.interface21.com

Co-author, "Expert Spring MVC and Web Flow"
(February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
http://www.amazon.com/gp/product/159059584X

Interface21 NL B.V.
Donker Curtiusstraat 7-400c
1051JL Amsterdam
The Netherlands
Phone: +31 (0)20 486 47 63
Fax: +31 (0)20 475 08 28
Mail: [hidden email]
Skype: devijvers
Reply | Threaded
Open this post in threaded view
|

Re: New Scaffolding Docs

graemer
On 27/02/06, Steven Devijver <[hidden email]> wrote:
> Graeme, these docs are great!
>
> One remarks, at the end of the document you mention a formRemote tag
> but in the subsequent code sample you use the g:form tag. Is this ok?

Woops thanks for spotting that :-)

Graeme

>
> Steven
>
> On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > Initial docs on Ajax support are now also there:
> >
> > http://grails.codehaus.org/Ajax?nocache
> >
> > Cheers
> > Graeme
> >
> > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > Right I've given it some thought ;-)
> > > >
> > > > The issue I have is that at the moment its really great having the
> > > > constraints in the domain class for grails domain classes, as they're
> > > > concise to define easy to access and it means you can unit test your
> > > > constraints.
> > > >
> > > > But I see your point about the ability to define them elsewhere, but
> > > > I'm not convinced the controller is the right place for them either,
> > > > what you need is the ability to associate constraints with a class but
> > > > without that necessarily being part of the class.. those constraints
> > > > should still be picked up by the "validate()" method etc.
> > > >
> > > > So the code would be something like:
> > > >
> > > > @Property myConstraints = {
> > > >        name(length:5..15)
> > > >        email(email:true)
> > > > }
> > > >
> > > > And then we need something to map them like this:
> > > >
> > > > @Property constraintMappings = [  User.class : myConstraints ]
> > > >
> > > > But where do these live? In the controller? I think not as these are
> > > > prototypes... maybe in some other artifact like
> > > > "ApplicationConstraints" or maybe we need a more general one like
> > > > "ApplicationConfiguration"
> > > >
> > > > What do you think?
> > >
> > > Interesting point, I would go for a DomainConstraint artifact as these
> > > constraints are specifically related to the Domain classes.
> > >
> > > Steven
> > >
> > > >
> > > > Graeme
> > > >
> > > >
> > > > On 27/02/06, Graeme Rocher <[hidden email]> wrote:
> > > > > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > > > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > > > > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > > > > > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > > > > > > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > > > > > > > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > > > > > > > > On 27/02/06, Steven Devijver <[hidden email]> wrote:
> > > > > > > > > > > > Hey Graeme,
> > > > > > > > > > > >
> > > > > > > > > > > > This is perfect, it really is. The movie is going to be awesome!
> > > > > > > > > > > >
> > > > > > > > > > > > One thing I would like to change is a small detail in the Validation
> > > > > > > > > > > > section. It's not entirely clear where the constraints have to be
> > > > > > > > > > > > added: in the controller or in the domain class.
> > > > > > > > > > >
> > > > > > > > > > > Good point. I will change this.
> > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Also, how to these constraints work if I use Java domain classes? I
> > > > > > > > > > > > would also point out how to register your Java classes with the
> > > > > > > > > > > > SessionFactory.
> > > > > > > > > > >
> > > > > > > > > > > There is an example in CVS in "samples/recipes" that demonstrates java
> > > > > > > > > > > integration.  Its something like:
> > > > > > > > > > >
> > > > > > > > > > >     @Transient
> > > > > > > > > > >     public Map getConstraints() {
> > > > > > > > > > >         ConstrainedProperty titleConstraint = new
> > > > > > > > > > > ConstrainedPersistentProperty(getClass(), "title", String.class );
> > > > > > > > > > >         titleConstraint.setOrder(1);
> > > > > > > > > > >         titleConstraint.setLength(new IntRange(5,15));
> > > > > > > > > > >         ConstrainedProperty descConstraint = new
> > > > > > > > > > > ConstrainedPersistentProperty(getClass(), "title", String.class );
> > > > > > > > > > >         descConstraint.setOrder(2);
> > > > > > > > > > >         descConstraint.setWidget("textarea");
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >         List constraints = new ArrayList();
> > > > > > > > > > >         constraints.add(titleConstraint);
> > > > > > > > > > >         constraints.add(descConstraint);
> > > > > > > > > > >
> > > > > > > > > > >         return constraints;
> > > > > > > > > > >     }
> > > > > > > > > >
> > > > > > > > > > Do you think it's possible to put the constraints in the controller?
> > > > > > > >
> > > > > > > > It doesn't make sense to me to add constraints to domain classes that
> > > > > > > > are related to the view and that are specific to Grails. That's why it
> > > > > > > > sounds like a pleasant decoupling to put the constraints in the
> > > > > > > > controller. After all, adding the constraints to the Java classes is
> > > > > > > > too much work :-) And it would be a better encouragement for users to
> > > > > > > > get started.
> > > > > > >
> > > > > > > True if you're writing them in java it probably will be a bit painful,
> > > > > > > but no more so than RIFE's constraint mechanism for example.
> > > > > > >
> > > > > > > The constraints are related to thhe domain class because thats the way
> > > > > > > its done in other frameworks, but not necessarily how it should be
> > > > > > > done, I'm open to ideas how would you imagine it working in a
> > > > > > > controller? per action? or as validator instance?
> > > > > > >
> > > > > >
> > > > > > I suggest we go our own way, I think putting the constraints in Java
> > > > > > classes is plain wrong.  I would be very nice to see that *any*
> > > > > > existing Hibernate-mapped class can be reused in Grails with the full
> > > > > > flexibility of the framework without affecting existing classes.
> > > > >
> > > > > Yes I agree with you. I will give it some thought as to how we can do this
> > > > >
> > > > > >
> > > > > > BTW, can I also add Hibernate mapping files to the Hibernate config
> > > > > > file? It would be nice to document how this works, since many people
> > > > > > are still using these files.
> > > > >
> > > > > Yes you can. I don't have any of these to hand, but essentially you
> > > > > just add your mapping files to the classpath either in the src/java
> > > > > directory along side your classes or in the hibernate directory
> > > > >
> > > > > >
> > > > > > Steven
> > > > > >
> > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > >
> > > > > > > > > Anythings possible :-)
> > > > > > > > > The constraints are just built up by instances of
> > > > > > > > > org.codehaus.groovy.grails.orm.hibernate.validation.ConstrainedPersistentProperty
> > > > > > > > > using a builder.. so these could be placed anywere really..
> > > > > > > > > The builder used is
> > > > > > > > > org.codehaus.groovy.grails.validation.ConstrainedPropertyBuilder.
> > > > > > > > >
> > > > > > > > > What do you have in mind anyway?
> > > > > > > > >
> > > > > > > > > BTW the docs on Hibernate Integration have been updated with more info
> > > > > > > > > on java integration: http://grails.codehaus.org/Hibernate+Integration
> > > > > > > > >
> > > > > > > > > and I've added more to the original scaffolding docs about java integration
> > > > > > > > >
> > > > > > > > > Graeme
> > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > The example in CVS uses Hibernate annotations and the entry in
> > > > > > > > > > > hibernate.cfg.xml looks like:
> > > > > > > > > > >
> > > > > > > > > > > <hibernate-configuration>
> > > > > > > > > > >     <session-factory>
> > > > > > > > > > >         <mapping package="com.recipes" />
> > > > > > > > > > >         <mapping class="com.recipes.Recipe" />
> > > > > > > > > > >     </session-factory>
> > > > > > > > > > > </hibernate-configuration>
> > > > > > > > > > >
> > > > > > > > > > > Maybe I will add a section on scaffolding hibernate mapped classes
> > > > > > > > > > >
> > > > > > > > > > > Graeme
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > Steven
> > > > > > > > > > > >
> > > > > > > > > > > > On 2/27/06, Graeme Rocher <[hidden email]> wrote:
> > > > > > > > > > > > > With screenshots: http://grails.codehaus.org/Scaffolding
> > > > > > > > > > > > >
> > > > > > > > > > > > > Next thing to do is the movie...
> > > > > > > > > > > > >
> > > > > > > > > > > > > Graeme
> > > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > --
> > > > > > > > > > > > Steven Devijver
> > > > > > > > > > > > Senior Consultant
> > > > > > > > > > > > Interface21
> > > > > > > > > > > > Spring Services from the Source
> > > > > > > > > > > > http://www.interface21.com
> > > > > > > > > > > >
> > > > > > > > > > > > Co-author, "Expert Spring MVC and Web Flow"
> > > > > > > > > > > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > > > > > > > > > > http://www.amazon.com/gp/product/159059584X
> > > > > > > > > > > >
> > > > > > > > > > > > Interface21 NL B.V.
> > > > > > > > > > > > Donker Curtiusstraat 7-400c
> > > > > > > > > > > > 1051JL Amsterdam
> > > > > > > > > > > > The Netherlands
> > > > > > > > > > > > Phone: +31 (0)20 486 47 63
> > > > > > > > > > > > Fax: +31 (0)20 475 08 28
> > > > > > > > > > > > Mail: [hidden email]
> > > > > > > > > > > > Skype: devijvers
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > > Steven Devijver
> > > > > > > > > > Senior Consultant
> > > > > > > > > > Interface21
> > > > > > > > > > Spring Services from the Source
> > > > > > > > > > http://www.interface21.com
> > > > > > > > > >
> > > > > > > > > > Co-author, "Expert Spring MVC and Web Flow"
> > > > > > > > > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > > > > > > > > http://www.amazon.com/gp/product/159059584X
> > > > > > > > > >
> > > > > > > > > > Interface21 NL B.V.
> > > > > > > > > > Donker Curtiusstraat 7-400c
> > > > > > > > > > 1051JL Amsterdam
> > > > > > > > > > The Netherlands
> > > > > > > > > > Phone: +31 (0)20 486 47 63
> > > > > > > > > > Fax: +31 (0)20 475 08 28
> > > > > > > > > > Mail: [hidden email]
> > > > > > > > > > Skype: devijvers
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Steven Devijver
> > > > > > > > Senior Consultant
> > > > > > > > Interface21
> > > > > > > > Spring Services from the Source
> > > > > > > > http://www.interface21.com
> > > > > > > >
> > > > > > > > Co-author, "Expert Spring MVC and Web Flow"
> > > > > > > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > > > > > > http://www.amazon.com/gp/product/159059584X
> > > > > > > >
> > > > > > > > Interface21 NL B.V.
> > > > > > > > Donker Curtiusstraat 7-400c
> > > > > > > > 1051JL Amsterdam
> > > > > > > > The Netherlands
> > > > > > > > Phone: +31 (0)20 486 47 63
> > > > > > > > Fax: +31 (0)20 475 08 28
> > > > > > > > Mail: [hidden email]
> > > > > > > > Skype: devijvers
> > > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > Steven Devijver
> > > > > > Senior Consultant
> > > > > > Interface21
> > > > > > Spring Services from the Source
> > > > > > http://www.interface21.com
> > > > > >
> > > > > > Co-author, "Expert Spring MVC and Web Flow"
> > > > > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > > > > http://www.amazon.com/gp/product/159059584X
> > > > > >
> > > > > > Interface21 NL B.V.
> > > > > > Donker Curtiusstraat 7-400c
> > > > > > 1051JL Amsterdam
> > > > > > The Netherlands
> > > > > > Phone: +31 (0)20 486 47 63
> > > > > > Fax: +31 (0)20 475 08 28
> > > > > > Mail: [hidden email]
> > > > > > Skype: devijvers
> > > > > >
> > > > >
> > > >
> > >
> > >
> > > --
> > > Steven Devijver
> > > Senior Consultant
> > > Interface21
> > > Spring Services from the Source
> > > http://www.interface21.com
> > >
> > > Co-author, "Expert Spring MVC and Web Flow"
> > > (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> > > http://www.amazon.com/gp/product/159059584X
> > >
> > > Interface21 NL B.V.
> > > Donker Curtiusstraat 7-400c
> > > 1051JL Amsterdam
> > > The Netherlands
> > > Phone: +31 (0)20 486 47 63
> > > Fax: +31 (0)20 475 08 28
> > > Mail: [hidden email]
> > > Skype: devijvers
> > >
> >
>
>
> --
> Steven Devijver
> Senior Consultant
> Interface21
> Spring Services from the Source
> http://www.interface21.com
>
> Co-author, "Expert Spring MVC and Web Flow"
> (February 2006, with Seth Ladd, Darren Davison, and Colin Yates)
> http://www.amazon.com/gp/product/159059584X
>
> Interface21 NL B.V.
> Donker Curtiusstraat 7-400c
> 1051JL Amsterdam
> The Netherlands
> Phone: +31 (0)20 486 47 63
> Fax: +31 (0)20 475 08 28
> Mail: [hidden email]
> Skype: devijvers
>