-
Notifications
You must be signed in to change notification settings - Fork 255
Displaying fields backed by dynamic expression
ikostenko edited this page Apr 22, 2013
·
4 revisions
It is possible to enrich List View, Quick View and Show View with results of the entity accessor methods calls, entity transient fields, or data from an associated entity.
Due to the nature of transient fields, it is most reasonable to show transient fields whose values are based on persistent field values
This is done using FieldSetConfigurationUnitBuilder.dynamic()
method:
-
dynamic( "[entity accessor method name without 'get' prefix]" )
; -
dynamic( "[entity transient field name]" )
; -
dynamic( "[associated entity name].[entity field name]" )
.
See the usage example below.
@Administration( Booking.class )
public class BookingAdministration {
public static FieldSetConfigurationUnit listView( final FieldSetConfigurationUnitBuilder fragmentBuilder ) {
return fragmentBuilder
.field( "user" ).caption( "Customer" )
.dynamic( "hotel.name" ).caption( "Hotel Name" )
.field( "smoking" ).caption( "Smoking" )
.field( "beds" ).caption( "Beds" )
.dynamic( "total" ).caption( "Total" ).build();
}
public static FieldSetConfigurationUnit quickView( final FieldSetConfigurationUnitBuilder fragmentBuilder ) {
return fragmentBuilder
.dynamic( "hotel.price" ).caption( "Hotel Price" )
.field( "checkinDate" ).caption( "Check-In Date" )
.field( "checkoutDate" ).caption( "Check-Out Date" )
.dynamic( "nights" ).caption( "Nights" )
.dynamic( "description" ).caption( "Booking Description" ).build();
}
}