Data binding with Multiple domain classes for a command object

View: New views
5 Messages — Rating Filter:   Alert me  

Data binding with Multiple domain classes for a command object

by Jean-Noël Rivasseau-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I find the multiple data binding fieature with dots (eg, author.title,
book.title) quite useful. Would the same thing work for a command
object, and if yes, how?

Eg how can I isolate parameters to bind to a command object, while
others will be bound to a domain class?

I tried to use the same name as the command object class and it did
not work. (eg SampleCommand as the command object name, I used
"sample.title").

If this is not currently possible, can I JIRA? :)

Jean-Noel

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



AW: Data binding with Multiple domain classes for a command object

by Daniel J. Lauk-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi.

I am not sure, if I understood correctly.
But I think what you are speaking of are simply "Groovy Beans":
http://groovy.codehaus.org/Groovy+Beans

A quote from there:
[...]
When Groovy is compiled to bytecode, the following rules are used.

    * If the name is declared with an access modifier (public, private
or protected) then a field is generated.
    * A name declared with no access modifier generates a private field
with public getter and setter (i.e. a property).
    * If a property is declared final the private field is created final
and no setter is generated.
    * You can declare a property and also declare your own getter or
setter.
    * If you want a private or protected property you have to provide
your own getter and setter which must be declared private or protected.
[...]

Was that what you meant?

So if your SampleCommand class looks like that:

// groovy code
class SampleCommand {
  String title
}

You will be able to use code like that:

// groovy code
// ...
def cmd = new SampleCommand(title:'Hello, world!')
println cmd.title

HTH,
DJ

--
Daniel J. Lauk


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Data binding with Multiple domain classes for a command object

by Jean-Noël Rivasseau-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

No, this is not what I meant. I was speaking of the Grails specific
feature to bind parameters to objects via

myObject.properties = params

The params object allows for multiple domain class binding if you
prefix the property name by the name of the target domain class
follofwed by a dot, eg myClass.myProperty as a param name.

I was wondering if the same thing was possible for command objects.

On Thu, Jul 17, 2008 at 2:12 PM, Lauk Daniel <Daniel.Lauk@...> wrote:

> Hi.
>
> I am not sure, if I understood correctly.
> But I think what you are speaking of are simply "Groovy Beans":
> http://groovy.codehaus.org/Groovy+Beans
>
> A quote from there:
> [...]
> When Groovy is compiled to bytecode, the following rules are used.
>
>    * If the name is declared with an access modifier (public, private
> or protected) then a field is generated.
>    * A name declared with no access modifier generates a private field
> with public getter and setter (i.e. a property).
>    * If a property is declared final the private field is created final
> and no setter is generated.
>    * You can declare a property and also declare your own getter or
> setter.
>    * If you want a private or protected property you have to provide
> your own getter and setter which must be declared private or protected.
> [...]
>
> Was that what you meant?
>
> So if your SampleCommand class looks like that:
>
> // groovy code
> class SampleCommand {
>  String title
> }
>
> You will be able to use code like that:
>
> // groovy code
> // ...
> def cmd = new SampleCommand(title:'Hello, world!')
> println cmd.title
>
> HTH,
> DJ
>
> --
> Daniel J. Lauk
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



AW: Data binding with Multiple domain classes for a command object

by Daniel J. Lauk-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Oh, OK. Now I understand. Sorry to bother you.

Cheers,
DJ
--
Daniel J. Lauk

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Re: Data binding with Multiple domain classes for a command object

by Jean-Noël Rivasseau-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I opened a JIRA for this at

http://jira.codehaus.org/browse/GRAILS-3266

sheduled for 1.1

Cheers

On Thu, Jul 17, 2008 at 2:28 PM, Jean-Noël Rivasseau <elvanor@...> wrote:

> No, this is not what I meant. I was speaking of the Grails specific
> feature to bind parameters to objects via
>
> myObject.properties = params
>
> The params object allows for multiple domain class binding if you
> prefix the property name by the name of the target domain class
> follofwed by a dot, eg myClass.myProperty as a param name.
>
> I was wondering if the same thing was possible for command objects.
>
> On Thu, Jul 17, 2008 at 2:12 PM, Lauk Daniel <Daniel.Lauk@...> wrote:
>> Hi.
>>
>> I am not sure, if I understood correctly.
>> But I think what you are speaking of are simply "Groovy Beans":
>> http://groovy.codehaus.org/Groovy+Beans
>>
>> A quote from there:
>> [...]
>> When Groovy is compiled to bytecode, the following rules are used.
>>
>>    * If the name is declared with an access modifier (public, private
>> or protected) then a field is generated.
>>    * A name declared with no access modifier generates a private field
>> with public getter and setter (i.e. a property).
>>    * If a property is declared final the private field is created final
>> and no setter is generated.
>>    * You can declare a property and also declare your own getter or
>> setter.
>>    * If you want a private or protected property you have to provide
>> your own getter and setter which must be declared private or protected.
>> [...]
>>
>> Was that what you meant?
>>
>> So if your SampleCommand class looks like that:
>>
>> // groovy code
>> class SampleCommand {
>>  String title
>> }
>>
>> You will be able to use code like that:
>>
>> // groovy code
>> // ...
>> def cmd = new SampleCommand(title:'Hello, world!')
>> println cmd.title
>>
>> HTH,
>> DJ
>>
>> --
>> Daniel J. Lauk
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>    http://xircles.codehaus.org/manage_email
>>
>>
>>
>