CRUD table customization : all fields automatically

389 views
Skip to first unread message

Xavier NOPRE

unread,
May 26, 2011, 10:16:46 AM5/26/11
to play-framework
Hi,

In a CRUD list, when I can see all objects of a type, I want to display all fields of each object, in the CRUD.table.

I can do that :

        #{crud.table fields:['name', 'field1', 'field2'] }
            #{crud.custom 'field1'}
                ${object.field1 ? 'Yes' : '-' }
            #{/crud.custom}
            #{crud.custom 'field2'}
                ${object.field2 ? 'Yes' : '-' }
            #{/crud.custom}
        #{/crud.table}

Now, when I add a new "field3" to the bean class, I have to update this template.

Is it possible to not specify all fields names ? Something like :

        #{crud.table fields:['*'] }
            #{crud.custom 'field1'}
                ${object.field1 ? 'Yes' : '-' }
            #{/crud.custom}
            #{crud.custom 'field2'}
                ${object.field2 ? 'Yes' : '-' }
            #{/crud.custom}
        #{/crud.table}

Or simply, is it possible to have all fields (or some specified fields) in the CRUD table ?

Thanks,

Xavier


Peter Hilton, Lunatech

unread,
May 26, 2011, 2:44:26 PM5/26/11
to play-fr...@googlegroups.com
I think it works with #{crud.table fields:currentType.fields*.name } because it uses field names. I can’t remember if currentType is what’s in scope for the CRUD.ObjectType instance but this should give you a good idea.

Peter Hilton, Lunatech

unread,
May 26, 2011, 2:45:38 PM5/26/11
to play-fr...@googlegroups.com
Ah, make that #{crud.table fields:type.fields*.name }

Xavier NOPRE

unread,
May 27, 2011, 2:19:54 AM5/27/11
to play-fr...@googlegroups.com
Hi Peter !

Ah, make that #{crud.table fields:type.fields*.name }

Thank you for your answer : YES, it works !

But unfortunatel, some fields are unwanted, the solution "*" is not good ... Unless I can construct myself this list to add the field "name" and all fields starting with "right*" .... ? A new challenge .... ;-)

Thanks,

Xavier

Peter Hilton, Lunatech

unread,
May 27, 2011, 2:51:39 AM5/27/11
to play-fr...@googlegroups.com
Use the technique on http://www.lunatech-research.com/archives/2011/01/11/declarative-model-class-enhancement-play to create an annotation to mark the fields you want, and then modify CRUD.ObjectType to add a second getSomeFields method that only returns the fields with the annotation.

Xavier NOPRE

unread,
May 27, 2011, 4:12:13 AM5/27/11
to play-fr...@googlegroups.com
Hi,

Yes, good idea, et very good link !

Thanks,

Xavier


2011/5/27 Peter Hilton, Lunatech <peter....@gmail.com>
Use the technique on http://www.lunatech-research.com/archives/2011/01/11/declarative-model-class-enhancement-play to create an annotation to mark the fields you want, and then modify CRUD.ObjectType to add a second getSomeFields method that only returns the fields with the annotation.

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.

Reply all
Reply to author
Forward
0 new messages