public class MapRenderAdapter<M extends Map> extends CustomItemComponentRenderAdapter
Map
as a series of Key-Value inputsSelect
(single or multi-select depends on the ContentType
in MetaItem
)Map
then one should ensure that the core input type is converted to Map and back by setting CustomItemComponentRenderAdapter.setModelTransformer(org.apache.commons.collections.Transformer)
with a TwoWayTransformer
#getLookup()
if not entityTemplate
is provided.
TODO: This adapter cannot be used with ProductDetailsTemplatePanel
as the entityTemplate
is of EntityTemplate
type.
We need to adapt it to also work with ProductDetailsTemplatePanel
.CustomItemComponentRenderAdapter.ContextualTwoWayTransformer
Modifier and Type | Field and Description |
---|---|
protected EntityTemplate |
entityTemplate |
authorizationModule, modelTransformer
Constructor and Description |
---|
MapRenderAdapter() |
MapRenderAdapter(MapRenderAdapter<M> t) |
Modifier and Type | Method and Description |
---|---|
org.apache.wicket.Component |
getComponent(String componentId,
MetaItem metaItem,
org.apache.wicket.model.IModel defaultInputModel,
Object modelObject,
User user)
Some fields/attribute may require display of options
for selection or Auto-Suggest etc..
|
EntityTemplate<Map> |
getEntityTemplate() |
protected M |
getMapInstance() |
protected void |
populateItem(org.apache.wicket.markup.html.WebMarkupContainer item,
org.apache.wicket.model.CompoundPropertyModel model)
Model of the input data to the Component
If entityTemplate is provided then it will render a Dynamic EntityDetailsTemplatePanel ; using Template.getReference() . |
void |
setEntityTemplate(EntityTemplate<Map> entityTemplate) |
filter, getDataList, getLookup, getModelTransformer, markComponentReadOnly, processSubmit, setModelTransformer, translateCurrentSelectionModel
protected EntityTemplate entityTemplate
public MapRenderAdapter()
public MapRenderAdapter(MapRenderAdapter<M> t)
protected M getMapInstance()
public org.apache.wicket.Component getComponent(String componentId, MetaItem metaItem, org.apache.wicket.model.IModel defaultInputModel, Object modelObject, User user)
HiddenField
Expect the modelObject as JSONObject
and make a ListView
of all the key, value pairs.getComponent
in class CustomItemComponentRenderAdapter
componentId
- as Sting id for the ComponentmetaItem
- as MetaItem meta data for rendering logicdefaultInputModel
- is the current data defined in a IModel
for the MetaItem.
The resultant model in the returned Component may NOT be same as the one passed to the inner component, hence always use the derived one.
This is because there maybe a mismatch in the form of core/raw data and one required for final presentation.
For example the input maybe a Comma Separated list of Strings, however for presentation in a List box we may convert the Model to a ListModel.modelObject
- as Object, that represents the main Entity (overall context)user
- as com.neurosys.security.auth.domain.User for any Authorization related needs @nullable trueprotected void populateItem(org.apache.wicket.markup.html.WebMarkupContainer item, org.apache.wicket.model.CompoundPropertyModel model)
entityTemplate
is provided then it will render a Dynamic EntityDetailsTemplatePanel
; using Template.getReference()
.
hence in this case Template.getReference()
must not be null.item
- as ListItem
model
- as CompoundPropertyModel
public EntityTemplate<Map> getEntityTemplate()
public void setEntityTemplate(EntityTemplate<Map> entityTemplate)
Copyright © 2018. All rights reserved.