public class JSONGridRenderAdapter extends CustomItemComponentRenderAdapter
CustomItemComponentRenderAdapter
that supports rows and columns to support JSON Maps
EntityDetailsTemplatePanel
type should be like:
<table class="grid" wicket:id="input">
<thead><tr><th class="tuple_head" wicket:id="tupleColName"></th><wicket:container wicket:id="colNames"><th wicket:id="colDisplayName"></th></wicket:container></tr></thead>
<tbody>
<tr wicket:id="rows">
<td class="tuple_head" wicket:id="tupleDisplayName"></td>
<td wicket:id="cols"><div wicket:id="core"></div></td>
</tr>
</tbody>
</table>
tupleFields
: Defines the secondary axis (Y), which are the rows backing the grid. Each row (tuple) is a collection of columns (coreFields
value).FacetMeta#getAttribute(String))
, for key , then it assumes the core JSON is itself the tuple. This is useful for JSON's that are single tuples and do not need a key to represent the tuple itself.FacetMeta.isCollectionType()
, then it assumes the tuple is a JSON Array. In this case the coreFields
, FacetMeta.getName()
is the index within the array and hence is expect3ed to be an integer.
coreFields
: Defines the primary axis (X). These constitute the core fields that will capture the values for any given tuple.CustomItemComponentRenderAdapter.ContextualTwoWayTransformer
Modifier and Type | Field and Description |
---|---|
static String |
ATTRIB_SINGLE_TYPE_JSON
FacetMeta.getAttribute(String) , if for this key is true
then it will treat the JSON as a single tuple. |
authorizationModule, modelTransformer
Constructor and Description |
---|
JSONGridRenderAdapter() |
JSONGridRenderAdapter(JSONGridRenderAdapter 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..
|
List<FacetMeta> |
getCoreFields()
These are the fields that define the core data to be captured.
For example in a class, for every student. |
Map<String,org.apache.commons.collections.Transformer> |
getCoreFieldTransformers()
An optional
Map of Transformer for each field in coreFields by FacetMeta.getName() Any mapping with null key implies applying that Transformer to all cells in the grid, if no override exists for it. |
CustomTemplateRenderAdapter<Object,org.apache.wicket.model.IModel,org.apache.wicket.Component,org.apache.wicket.MarkupContainer> |
getFieldRenderAdapter()
Optional
CustomTemplateRenderAdapter to render fields in the grip. |
String |
getTupleColName()
An HTML friendly name for the tuple column
|
List<ISection> |
getTupleFields()
These are the fields that define the group of the primary fields, that belong to the secondary field.
The ISection.getName() define the keys in a JSON / Map and the ISection.getDisplayName() the display tuple nameFor example in a class, for every student. |
Object |
processSubmit(MetaItem metaItem,
org.apache.wicket.Component fieldEntityComponent,
Object value,
User user)
Call on submit of component.
|
void |
setCoreFields(List<FacetMeta> coreFields)
These are the fields that define the core data to be captured.
For example in a class, for every student. |
void |
setCoreFieldTransformers(Map<String,org.apache.commons.collections.Transformer> coreFieldTransformers)
An optional
Map of Transformer for each field in coreFields by FacetMeta.getName() Any mapping with null key implies applying that Transformer to all cells in the grid, if no override exists for it. |
void |
setFieldRenderAdapter(CustomTemplateRenderAdapter<Object,org.apache.wicket.model.IModel,org.apache.wicket.Component,org.apache.wicket.MarkupContainer> fieldRenderAdapter)
Optional
CustomTemplateRenderAdapter to render fields in the grip. |
void |
setTupleColName(String tupleColName)
An HTML friendly name for the tuple column
|
void |
setTupleFields(List<ISection> tupleFields)
These are the fields that define the group of the primary fields, that belong to the secondary field.
The ISection.getName() define the keys in a JSON / Map and the ISection.getDisplayName() the display tuple nameFor example in a class, for every student. |
filter, getDataList, getLookup, getModelTransformer, markComponentReadOnly, setModelTransformer, translateCurrentSelectionModel
public static final String ATTRIB_SINGLE_TYPE_JSON
FacetMeta.getAttribute(String)
, if for this key is true
then it will treat the JSON as a single tuple.
Example: {"a":"123", "b":".."}public JSONGridRenderAdapter()
public JSONGridRenderAdapter(JSONGridRenderAdapter t)
public org.apache.wicket.Component getComponent(String componentId, MetaItem metaItem, org.apache.wicket.model.IModel defaultInputModel, Object modelObject, User user)
CustomItemComponentRenderAdapter
HiddenField
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 truepublic Object processSubmit(MetaItem metaItem, org.apache.wicket.Component fieldEntityComponent, Object value, User user)
CustomItemComponentRenderAdapter.modelTransformer
is a TwoWayTransformer
then this method can be skipped.processSubmit
in class CustomItemComponentRenderAdapter
metaItem
- as MetaItem
fieldEntityComponent
- as Component
, the same component that the RenderAdapter created in CustomItemComponentRenderAdapter.getComponent(String, MetaItem, IModel, Object, User)
value
- as Objectuser
- as Userpublic List<FacetMeta> getCoreFields()
public void setCoreFields(List<FacetMeta> coreFields)
public List<ISection> getTupleFields()
ISection.getName()
define the keys in a JSON / Map and the ISection.getDisplayName()
the display tuple namepublic void setTupleFields(List<ISection> tupleFields)
ISection.getName()
define the keys in a JSON / Map and the ISection.getDisplayName()
the display tuple namepublic CustomTemplateRenderAdapter<Object,org.apache.wicket.model.IModel,org.apache.wicket.Component,org.apache.wicket.MarkupContainer> getFieldRenderAdapter()
CustomTemplateRenderAdapter
to render fields in the grip.DefaultWicketTemplateRenderAdapter.getInstance()
public void setFieldRenderAdapter(CustomTemplateRenderAdapter<Object,org.apache.wicket.model.IModel,org.apache.wicket.Component,org.apache.wicket.MarkupContainer> fieldRenderAdapter)
CustomTemplateRenderAdapter
to render fields in the grip.DefaultWicketTemplateRenderAdapter.getInstance()
public String getTupleColName()
public void setTupleColName(String tupleColName)
public Map<String,org.apache.commons.collections.Transformer> getCoreFieldTransformers()
Map
of Transformer
for each field in coreFields
by FacetMeta.getName()
public void setCoreFieldTransformers(Map<String,org.apache.commons.collections.Transformer> coreFieldTransformers)
Map
of Transformer
for each field in coreFields
by FacetMeta.getName()
Copyright © 2018. All rights reserved.