T
- Type of model objectpublic class Palette<T> extends FormComponentPanel<Collection<T>>
When creating a Palette object make sure your IChoiceRenderer returns a specific ID, not the index.
Ajaxifying the palette: If you want to update a Palette with an
AjaxFormComponentUpdatingBehavior
, you have to attach it to the contained
Recorder
by overriding newRecorderComponent()
and calling
FormComponent.processInput()
:
Palette palette=new Palette(...) {
protected Recorder newRecorderComponent()
{
Recorder recorder=super.newRecorderComponent();
recorder.add(new AjaxFormComponentUpdatingBehavior("change") {
protected void onUpdate(AjaxRequestTarget target) {
processInput(); // let Palette process input too
...
}
});
return recorder;
}
}
You can add a DefaultTheme
to style this component in a left to right fashion.FLAG_CONVERT_EMPTY_INPUT_STRING_TO_NULL, VALUE_SEPARATOR
ENABLE, FLAG_INITIALIZED, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED8, PARENT_PATH, PATH_SEPARATOR, RENDER, RFLAG_CONTAINER_DEQUEING, RFLAG_CONTAINER_HAS_REMOVALS
Constructor and Description |
---|
Palette(String id,
IModel<? extends Collection<T>> choicesModel,
IChoiceRenderer<? super T> choiceRenderer,
int rows,
boolean allowOrder) |
Palette(String id,
IModel<? extends Collection<T>> model,
IModel<? extends Collection<? extends T>> choicesModel,
IChoiceRenderer<? super T> choiceRenderer,
int rows,
boolean allowOrder) |
Palette(String id,
IModel<? extends Collection<T>> model,
IModel<? extends Collection<? extends T>> choicesModel,
IChoiceRenderer<? super T> choiceRenderer,
int rows,
boolean allowOrder,
boolean allowMoveAll)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected String |
buildJSCall(String funcName)
builds javascript handler call
|
void |
convertInput()
Converts and validates the conversion of the raw input string into the object specified by
FormComponent.getType() and records any thrown ConversionException s. |
String |
getAddAllOnClickJS() |
protected Map<String,String> |
getAdditionalAttributesForChoices(Object choice) |
protected Map<String,String> |
getAdditionalAttributesForSelection(Object choice) |
String |
getAddOnClickJS() |
IChoiceRenderer<? super T> |
getChoiceRenderer() |
Collection<? extends T> |
getChoices() |
protected Component |
getChoicesComponent() |
String |
getChoicesOnFocusJS() |
String |
getDownOnClickJS() |
Collection<T> |
getModelCollection() |
Recorder<T> |
getRecorderComponent()
Returns recorder component.
|
String |
getRemoveAllOnClickJS() |
String |
getRemoveOnClickJS() |
int |
getRows() |
Iterator<T> |
getSelectedChoices() |
protected Component |
getSelectionComponent() |
String |
getSelectionOnFocusJS() |
Iterator<T> |
getUnselectedChoices() |
String |
getUpOnClickJS() |
boolean |
isPaletteEnabled()
Return true if the palette is enabled, false otherwise
|
protected boolean |
localizeDisplayValues()
Override this method if you do not want to localize the display values of
the generated options.
|
protected Component |
newAddAllComponent()
factory method for the addAll component
|
protected Component |
newAddComponent()
factory method for the addcomponent
|
protected Component |
newAvailableHeader(String componentId)
factory method for the available items header
|
protected Component |
newChoicesComponent()
factory method for the available items component
|
protected Component |
newDownComponent()
factory method for the move down component
|
protected Recorder<T> |
newRecorderComponent()
factory method to create the tracker component
|
protected Component |
newRemoveAllComponent()
factory method for the removeAll component
|
protected Component |
newRemoveComponent()
factory method for the remove component
|
protected Component |
newSelectedHeader(String componentId)
factory method for the selected items header
|
protected Component |
newSelectionComponent()
factory method for the selected items component
|
protected Component |
newUpComponent()
factory method for the move up component
|
protected void |
onBeforeRender()
Called on all visible components before any component is rendered.
|
protected void |
onDetach()
Sets the temporary converted input value to null.
|
void |
renderHead(IHeaderResponse response)
Renders header contributions
|
void |
updateModel()
The model object is assumed to be a Collection, and it is modified in-place.
|
checkRequired, clearInput, newMarkupSourcingStrategy, onComponentTag
add, add, convertValue, error, getConvertedInput, getDefaultLabel, getDefaultLabel, getForm, getInput, getInputAsArray, getInputName, getModelValue, getParameterValues, getRawInput, getType, getValidatorKeyPrefix, getValidators, getValue, hasRawInput, inputAsInt, inputAsInt, inputAsIntArray, inputChanged, internalOnModelChanged, invalid, isInputNullable, isMultiPart, isRequired, isValid, newValidatable, newValidationError, onDisabled, onInvalid, onRequired, onValid, processChildren, processInput, remove, reportRequiredError, setConvertedInput, setLabel, setModelValue, setRequired, setType, shouldTrimInput, trim, updateAutoLabels, updateCollectionModel, valid, validate, validateRequired, validateValidators, visitComponentsPostOrder, visitFormComponentsPostOrder
getLabel
getWebApplication, getWebPage, getWebRequest, getWebResponse, getWebSession
add, addDequeuedComponent, addOrReplace, autoAdd, canDequeueTag, contains, dequeue, dequeue, dequeuePreamble, findChildComponent, findComponentToDequeue, get, getAssociatedMarkup, getAssociatedMarkupStream, getMarkup, getMarkupType, getRegionMarkup, internalAdd, internalInitialize, iterator, iterator, newDequeueContext, onComponentTagBody, onInitialize, onRender, queue, remove, remove, removeAll, renderAll, renderAssociatedMarkup, renderNext, replace, setDefaultModel, size, stream, streamChildren, toString, toString, visitChildren, visitChildren
add, addStateChange, beforeRender, canCallListener, canCallListenerAfterExpiry, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, clearOriginalDestination, configure, continueToOriginalDestination, createConverter, debug, detach, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, getAjaxRegionMarkupId, getApplication, getBehaviorById, getBehaviorId, getBehaviors, getBehaviors, getClassRelativePath, getConverter, getDefaultModel, getDefaultModelObject, getDefaultModelObjectAsString, getDefaultModelObjectAsString, getEscapeModelStrings, getFeedbackMessages, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkup, getMarkupAttributes, getMarkupId, getMarkupId, getMarkupIdFromMarkup, getMarkupIdImpl, getMarkupSourcingStrategy, getMetaData, getModelComparator, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getRequestFlag, getResponse, getSession, getSizeInBytes, getStatelessHint, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, initModel, internalRenderComponent, internalRenderHead, isActionAuthorized, isAuto, isBehaviorAccepted, isEnableAllowed, isEnabled, isEnabledInHierarchy, isIgnoreAttributeModifier, isInitialized, isRenderAllowed, isRendering, isStateless, isVersioned, isVisibilityAllowed, isVisible, isVisibleInHierarchy, markRendering, modelChanged, modelChanging, onAfterRender, onConfigure, onEvent, onModelChanged, onModelChanging, onReAdd, onRemove, redirectToInterceptPage, remove, remove, render, renderComponentTag, rendered, renderPart, renderPlaceholderTag, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, send, setAuto, setDefaultModelObject, setEnabled, setEscapeModelStrings, setFlag, setIgnoreAttributeModifier, setMarkup, setMarkupId, setMarkupIdImpl, setMetaData, setOutputMarkupId, setOutputMarkupPlaceholderTag, setParent, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, success, urlFor, urlFor, urlFor, urlForListener, urlForListener, visitParents, visitParents, warn, wrap
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
dequeue, getRegionMarkup, newDequeueContext
getDefaultModel, getDefaultModelObject, getModel, getModelObject, setDefaultModel, setDefaultModelObject, setModel, setModelObject
forEach, spliterator
public Palette(String id, IModel<? extends Collection<T>> choicesModel, IChoiceRenderer<? super T> choiceRenderer, int rows, boolean allowOrder)
id
- Component idchoicesModel
- Model representing collection of all available choiceschoiceRenderer
- Render used to render choices. This must use unique IDs for the objects, not the
index.rows
- Number of choices to be visible on the screen with out scrollingallowOrder
- Allow user to move selections up and downpublic Palette(String id, IModel<? extends Collection<T>> model, IModel<? extends Collection<? extends T>> choicesModel, IChoiceRenderer<? super T> choiceRenderer, int rows, boolean allowOrder)
id
- Component idmodel
- Model representing collection of user's selectionschoicesModel
- Model representing collection of all available choiceschoiceRenderer
- Render used to render choices. This must use unique IDs for the objects, not the
index.rows
- Number of choices to be visible on the screen with out scrollingallowOrder
- Allow user to move selections up and downpublic Palette(String id, IModel<? extends Collection<T>> model, IModel<? extends Collection<? extends T>> choicesModel, IChoiceRenderer<? super T> choiceRenderer, int rows, boolean allowOrder, boolean allowMoveAll)
id
- Component idchoicesModel
- Model representing collection of all available choiceschoiceRenderer
- Render used to render choices. This must use unique IDs for the objects, not the
index.rows
- Number of choices to be visible on the screen with out scrollingallowOrder
- Allow user to move selections up and downallowMoveAll
- Allow user to add or remove all items at onceprotected void onBeforeRender()
Component
NOTE: If you override this, you *must* call super.onBeforeRender() within
your implementation.
Because this method is responsible for cascading Component.onBeforeRender()
call to its
children it is strongly recommended that super call is made at the end of the override.
onBeforeRender
in class Component
MarkupContainer.addOrReplace(Component...)
public final boolean isPaletteEnabled()
public Iterator<T> getUnselectedChoices()
protected Recorder<T> newRecorderComponent()
protected Component newAvailableHeader(String componentId)
componentId
- component id of the returned header componentprotected Component newSelectedHeader(String componentId)
componentId
- component id of the returned header componentprotected Component newDownComponent()
protected Component newUpComponent()
protected Component newRemoveComponent()
protected Component newAddComponent()
protected Component newSelectionComponent()
protected Component newAddAllComponent()
protected Component newRemoveAllComponent()
protected Map<String,String> getAdditionalAttributesForSelection(Object choice)
choice
- AbstractOptions.getAdditionalAttributes(Object)
protected Component newChoicesComponent()
protected boolean localizeDisplayValues()
protected Map<String,String> getAdditionalAttributesForChoices(Object choice)
choice
- AbstractOptions.getAdditionalAttributes(Object)
protected Component getChoicesComponent()
protected Component getSelectionComponent()
public final Recorder<T> getRecorderComponent()
onchange
javascript event whenever a
change in selection occurs.public Collection<? extends T> getChoices()
public Collection<T> getModelCollection()
public IChoiceRenderer<? super T> getChoiceRenderer()
public int getRows()
public void convertInput()
FormComponent
FormComponent.getType()
and records any thrown ConversionException
s.
Converted value is available through FormComponent.getConvertedInput()
.
Usually the user should do custom conversions by specifying an IConverter
by
registering it with the application by overriding Application.getConverterLocator()
,
or at the component level by overriding Component.getConverter(Class)
.
public final void updateModel()
IModel.setObject(Object)
is called with the same instance: it allows the Model to be
notified of changes even when Model.getObject()
returns a different
Collection
at every invocation.updateModel
in interface IFormModelUpdateListener
updateModel
in class FormComponent<Collection<T>>
FormComponent.updateModel()
protected String buildJSCall(String funcName)
funcName
- name of javascript function to callpublic String getChoicesOnFocusJS()
public String getSelectionOnFocusJS()
public String getAddOnClickJS()
public String getRemoveOnClickJS()
public String getUpOnClickJS()
public String getDownOnClickJS()
public String getAddAllOnClickJS()
public String getRemoveAllOnClickJS()
protected void onDetach()
FormComponent
onDetach
in class FormComponent<Collection<T>>
Component.onDetach()
public void renderHead(IHeaderResponse response)
renderHead
in interface IHeaderContributor
renderHead
in class Component
response
- Copyright © 2006–2022 Apache Software Foundation. All rights reserved.