T
- public class DefaultWicketTemplateRenderAdapter<T> extends Object implements CustomTemplateRenderAdapter<T,org.apache.wicket.model.IModel,org.apache.wicket.Component,org.apache.wicket.MarkupContainer>
CustomTemplateRenderAdapter
that understands how to render various ContentType
from the core content entity.CustomTemplateRenderAdapter.Nothing
Modifier and Type | Field and Description |
---|---|
static String |
ATTRIB_CHOICE_REMOVE_NO_SELECTION |
static String |
ATTRIB_CHOICE_RENDER_SETTINGS
AutoCompleteSettings or IChoiceRenderer if ContentType.INPUT_AUTO_SUGGEST or ContentType.SELECT is used. |
static String |
ATTRIB_FRAGMENT_ID
Name the generated Fragment using the wicket Id corresponding to this attribute.
|
static String |
ATTRIB_INPUT_TYPE
Input type fields can override type from text to say email to support HTL5 validation in the field tag itself.
|
static String |
ATTRIB_LOOKUP
Deprecated.
|
protected AuthorizationModule<Void> |
authorizationModule |
protected org.apache.wicket.markup.html.WebMarkupContainer |
callingTemplate |
protected List<org.apache.wicket.Component> |
rawAddedComponents
Maintain a context of all components added for the Caller
|
protected FileUploadWrapper |
resourceUploader |
protected Template |
template |
nothing
Constructor and Description |
---|
DefaultWicketTemplateRenderAdapter(List<org.apache.wicket.Component> rawAddedComponents,
FileUploadWrapper resourceUploader,
Template template,
org.apache.wicket.markup.html.WebMarkupContainer callingTemplate) |
DefaultWicketTemplateRenderAdapter(Template template) |
DefaultWicketTemplateRenderAdapter(Template template,
org.apache.wicket.markup.html.WebMarkupContainer callingTemplate) |
Modifier and Type | Method and Description |
---|---|
protected org.apache.wicket.Component |
filter(org.apache.wicket.Component c,
MetaItem mi,
User user)
Apply
Authorization etc |
org.apache.wicket.Component |
getComponentForType(MetaItem metaItem,
String fieldComponentName,
org.apache.wicket.model.IModel model,
org.apache.wicket.MarkupContainer container,
T modelObject,
User user)
One can override to customize specific components or impose some manual override over what is dynamically
generated.
|
protected FieldAjaxEventBehavior |
getContentEditorAjaxSavingBehavior(org.apache.wicket.ajax.markup.html.AjaxLink link,
org.apache.wicket.ajax.IAjaxCallDecorator callDecorator,
MetaItem metaItem,
T modelObject,
ContentFacet facet)
If The Adapter uses a Content Editor which is capable of independent facet update hence
it requires a
FieldAjaxEventBehavior to define how that editor will behave on actions like onClick |
static DefaultWicketTemplateRenderAdapter |
getInstance() |
String |
getItemRefId(MetaItem metaItem)
A way to identify the panels/components for feedback on submit etc.
|
protected String |
identifyEntity(T entity)
Identify an entity; for log purposes etc
|
protected boolean |
isExemptFromProcessing(MetaItem meta,
Object value)
Some elements maybe processed exceptionally outside the automated process, determine which to leave out
|
protected void |
markComponentHidden(org.apache.wicket.Component c) |
protected void |
markComponentReadOnly(org.apache.wicket.Component c) |
Object |
processItem(T entity,
MetaItem metaItem,
org.apache.wicket.Component coreEntityDataField,
User user,
Object... contextParams)
For each meta item handle processing on submit and derive the value to be submitted/persisted back
|
void |
reset()
During Ajax calls a Render Adapter maybe called multiple times.
|
org.apache.wicket.Component |
unwrap(org.apache.wicket.Component entityDataField)
Remove the wrapper to pass back the component the custom render adapter created
|
protected Object |
validateAndTransform(MetaItem meta,
Object value,
org.apache.wicket.Component entityDataField,
User user)
Submit, Validate the returned object and return the validated/Transformed value, based on the following:
|
protected transient List<org.apache.wicket.Component> rawAddedComponents
protected transient FileUploadWrapper resourceUploader
protected transient Template template
protected transient org.apache.wicket.markup.html.WebMarkupContainer callingTemplate
protected AuthorizationModule<Void> authorizationModule
public static final String ATTRIB_FRAGMENT_ID
@Deprecated public static final String ATTRIB_LOOKUP
Transformer
then the input will be an Object array of the following in sequence [0]Field Model, [1] Entity Object, [2] MetaItem, [3] userFacetMeta.getLookup()
,
Constant Field Valuespublic static final String ATTRIB_CHOICE_RENDER_SETTINGS
AutoCompleteSettings
or IChoiceRenderer
if ContentType.INPUT_AUTO_SUGGEST
or ContentType.SELECT
is used.public static final String ATTRIB_CHOICE_REMOVE_NO_SELECTION
public static final String ATTRIB_INPUT_TYPE
public DefaultWicketTemplateRenderAdapter(Template template, org.apache.wicket.markup.html.WebMarkupContainer callingTemplate)
public DefaultWicketTemplateRenderAdapter(Template template)
public DefaultWicketTemplateRenderAdapter(List<org.apache.wicket.Component> rawAddedComponents, FileUploadWrapper resourceUploader, Template template, org.apache.wicket.markup.html.WebMarkupContainer callingTemplate)
public static DefaultWicketTemplateRenderAdapter getInstance()
protected void markComponentHidden(org.apache.wicket.Component c)
protected void markComponentReadOnly(org.apache.wicket.Component c)
protected org.apache.wicket.Component filter(org.apache.wicket.Component c, MetaItem mi, User user)
Authorization
etcpublic org.apache.wicket.Component getComponentForType(MetaItem metaItem, String fieldComponentName, org.apache.wicket.model.IModel model, org.apache.wicket.MarkupContainer container, T modelObject, User user)
Field
and ContentFacetMeta
exist then ContentFacetMeta
is given preference as it is defined by Config in a Template
StaticImageComponent
- Renders the image and the ability to upload a new oneHiddenField
- A reference to some values. the values can be derived from other input support defined on the UI.HiddenField
- Supports an array of comma separated values (Strings)HiddenField
- If an Object is being used then it will be marshaled/serialized into JSON format automatically and processed as such.HiddenField
- If an Array of Object(s) is being used then it will be marshaled/serialized into JSON format automatically and processed as such.
Usage Sample :
<wicket:panel>
<tr wicket:id="items">
<td><span wicket:id="fieldName" /><div wicket:id="feedback" style='background-color:#EEEEEE'></div></td>
<td><div wicket:id="productField"></div></td>
</tr>
<!-- Specific complex types -->
<wicket:fragment wicket:id="IMG">
<img wicket:id="currentImg" onerror='onImgError(this, "img/common/no-image.gif")' /><br>
<input wicket:id="file" type='file' />
</wicket:fragment>
<wicket:fragment wicket:id="REF_colors">
Color(s): -- Deprecated, colors now ARRAY type
<input wicket:id="input" type='hidden' />
</wicket:fragment>
<wicket:fragment wicket:id="ARRAY_colors">
Color(s):
<input wicket:id="input" type='hidden' />
</wicket:fragment>
<wicket:fragment wicket:id="JSON_size">
Size:
<input wicket:id="input" type='hidden' />
</wicket:fragment>
<wicket:fragment wicket:id="JSON_ARRAY_relatedGroups">
Related Groups:
<input wicket:id="input" type='hidden' />
</wicket:fragment>
<wicket:fragment wicket:id="FILE_BIN">
<a wicket:id='link'></a>
<input wicket:id="file" type='file' />
</wicket:fragment>
</wicket:panel>
MetaItem.getFacetMeta()
default value
IChoiceRenderer
instead of FacetMeta.getDisplayTransformer()
; his is because the drop-down has no way to reverse map the output display
to the input model. One can do it like this:
public class OrgnaizationChoiceRenderer implements IChoiceRenderer {
private static final long serialVersionUID = 1L;
public Object getDisplayValue(T object) {
if(object != null) {
return object.getDisplayName();
}
else {
return "None";
}
}
public String getIdValue(T object, int index) {
if(object instanceof Organization) {
return object.getName();
}
else {
// AbstractSingleSelectChoice.NO_SELECTION_VALUE == "-1"
return "-1";
}
}
}
{@literal
}
{@literal
}
getComponentForType
in interface CustomTemplateRenderAdapter<T,org.apache.wicket.model.IModel,org.apache.wicket.Component,org.apache.wicket.MarkupContainer>
metaItem
- as MetaItem
fieldComponentName
- as the rendering fieldComponentName or Id (of the component to be created)model
- as MODEL of the value extracted from the original modelObject for the MetaItem
.
This is a variable that would typically be extracted from the modeObject using the MetaItem,
however there is complex logic that can vary and hence is expected to be provided to this method.container
- as CONTAINER_COMPONENT containing the produced componentmodelObject
- as the core domain Object
/Entityuser
- as com.neurosys.security.auth.domain.User for any Authorization related needs @nullable trueSelectRenderAdapter
protected boolean isExemptFromProcessing(MetaItem meta, Object value)
public org.apache.wicket.Component unwrap(org.apache.wicket.Component entityDataField)
protected Object validateAndTransform(MetaItem meta, Object value, org.apache.wicket.Component entityDataField, User user) throws javax.validation.ValidationException
Map attribs = meta.getFacetMeta().getAttributes();
if (attribs!=null) {
if (attribs.containsKey("expectedFieldType")) expectedFieldType = (Class)attribs.get("expectedFieldType");
if (attribs.containsKey("expectedFieldRegex")) regEx = (String)attribs.get("expectedFieldRegex");
if (attribs.containsKey("expectedNull")) nullable = (Boolean)attribs.get("expectedNull");
if (attribs.containsKey("nullValidation")) nullValidation = (Boolean)attribs.get("nullValidation");
}
public Object processItem(T entity, MetaItem metaItem, org.apache.wicket.Component coreEntityDataField, User user, Object... contextParams) throws Exception
processItem
in interface CustomTemplateRenderAdapter<T,org.apache.wicket.model.IModel,org.apache.wicket.Component,org.apache.wicket.MarkupContainer>
CustomTemplateRenderAdapter.Nothing
(nothing). Nothing should not be persisted or used, it implies it should be ignored.Exception
protected FieldAjaxEventBehavior getContentEditorAjaxSavingBehavior(org.apache.wicket.ajax.markup.html.AjaxLink link, org.apache.wicket.ajax.IAjaxCallDecorator callDecorator, MetaItem metaItem, T modelObject, ContentFacet facet)
FieldAjaxEventBehavior
to define how that editor will behave on actions like onClickpublic String getItemRefId(MetaItem metaItem)
getItemRefId
in interface CustomTemplateRenderAdapter<T,org.apache.wicket.model.IModel,org.apache.wicket.Component,org.apache.wicket.MarkupContainer>
metaItem
- as MetaItem
public void reset()
CustomTemplateRenderAdapter
reset
in interface CustomTemplateRenderAdapter<T,org.apache.wicket.model.IModel,org.apache.wicket.Component,org.apache.wicket.MarkupContainer>
Copyright © 2018. All rights reserved.