public class DialogPlace extends Object
dialog in combination with its
getParameters(). It allows to represent a specific state of the client that can be bookmarked and
reopened at a later point in time. Dialog you need to define a dialog-id. To decouple your
navigation from the actual dialogs and their implementation, it is recommended to define them in a central
interface (you can also have multiple such interfaces or classes for large modular systems). See
DialogConstants to get started. For Dialogs may have mandatory or optional
parameters it is further recommended to create sub-classes for
DialogPlace or to define a factory for your DialogPlaces that takes the parameter
values as properly typed arguments. This will make refactoring easier if parameters need to be changed. If
you are sub-classing DialogPlace please be aware that your
DialogControllers are NOT permitted to cast DialogPlace to
your sub-class as the navigation can also take place via URL
typing or from a bookmark and the framework will NOT know your subclasses. For generic access to your
parameters please also define PARAMETER_* constants in your DialogConstants.
public class MyScreenDialogPlace extendsIf you do not need toDialogPlace{ public MyScreenDialogPlace(Type mandatoryParameterFoo) { this(mandatoryParameterFoo, null); } public MyScreenDialogPlace(Type mandatoryParameterFoo, OtherType optionalParameterBar) { super(MyDialogConstants.DIALOG_ID_MY_SCREEN,addParameter(newParameter(MyDialogConstants.PARAMETER_MY_SCREEN_FOO, mandatoryParameterFoo), MyDialogConstants.PARAMETER_MY_SCREEN_BAR, optionalParameterBar, false)); } }
open places in
a new window, you can also combine your places with the DialogManager and instead of providing
create methods you define methods like:
public void navigateDocument(long documentId) {
DialogPlace place = new DialogPlace(PLACE_DOCUMENT, createParameters(PARAM_DOCUMENT_ID, Long.toString(documentId));
getDialogManager().navigateTo(place);
}
| Modifier and Type | Field and Description |
|---|---|
private String |
dialogId |
private Map<String,String> |
parameters |
static String |
PATTERN_DIALOG_ID |
static String |
PATTERN_KEY
The regex pattern used to assert
parameter keys. |
static String |
PATTERN_VALUE
The regex pattern used to assert
parameter values. |
static char |
SEPARATOR_PARAMETER
The separator used between
parameters. |
static char |
SEPARATOR_STATE
The separator for
dialog-id and its parameters. |
static char |
SEPARATOR_VALUE
The separator for key and value of a
parameter. |
private static SimpleGenericValueConverter |
valueConverter |
| Modifier | Constructor and Description |
|---|---|
|
DialogPlace(String dialogId)
The constructor.
|
protected |
DialogPlace(String dialogId,
Map<String,String> parameters)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected static Map<String,String> |
addParameter(Map<String,String> parameters,
String key,
Object value)
Adds the given parameter to the given
Map. |
protected static Map<String,String> |
addParameter(Map<String,String> parameters,
String key,
Object value,
boolean required)
Adds the given parameter to the given
Map. |
boolean |
equals(Object obj) |
static DialogPlace |
fromString(String place)
This is the inverse operation of
toString(). |
String |
getDialogId()
|
String |
getParameter(String key)
This method gets a parameter of this
DialogPlace. |
<T> T |
getParameter(String key,
Class<T> type)
This method gets a typed parameter of this
DialogPlace. |
protected Map<String,String> |
getParameters() |
protected SimpleGenericValueConverter |
getValueConverter() |
int |
hashCode() |
boolean |
hasParameter(String key)
This method determines if a
getParameter(String) is present (!= null). |
protected static Map<String,String> |
newParameter(String key,
Object value)
Creates a
Map with the given parameter. |
protected static Map<String,String> |
newParameter(String key,
Object value,
boolean required)
Creates a
Map with the given parameter. |
String |
toString() |
public static final char SEPARATOR_STATE
dialog-id and its parameters.public static final char SEPARATOR_PARAMETER
parameters.public static final char SEPARATOR_VALUE
parameter.public static final String PATTERN_KEY
parameter keys.public static final String PATTERN_VALUE
parameter values.public static final String PATTERN_DIALOG_ID
private final String dialogId
getDialogId()private Map<String,String> parameters
getParameters()private static SimpleGenericValueConverter valueConverter
getValueConverter()public DialogPlace(String dialogId)
dialogId - - see getDialogId().protected DialogPlace(String dialogId, Map<String,String> parameters)
dialogId - - see getDialogId().parameters - - see getParameters().protected static Map<String,String> newParameter(String key, Object value)
Map with the given parameter.key - is the name of the parameter.value - is the value of the parameter.Map with the given parameter.protected static Map<String,String> newParameter(String key, Object value, boolean required)
Map with the given parameter.key - is the name of the parameter.value - is the value of the parameter. May be null
if required is false. Then an empty Map is returned. Use the
empty String instead of null to prevent this.required - - if false the given value may be null,
true if the parameter is required and an exception shall be thrown if
value is null.Map with the given parameter.protected static Map<String,String> addParameter(Map<String,String> parameters, String key, Object value)
Map.parameters - is the map with the current parameters.key - is the name of the parameter.value - is the value of the parameter.parameters Map.protected static Map<String,String> addParameter(Map<String,String> parameters, String key, Object value, boolean required)
Map.parameters - is the map with the current parameters.key - is the name of the parameter.value - is the value of the parameter. May be null
for generic usage with optional parameter. Then the given Map is returned unchanged. Use
the empty String instead of null to prevent this.required - - if false the given value may be null,
true if the parameter is required and an exception shall be thrown if
value is null.parameters Map.public boolean hasParameter(String key)
getParameter(String) is present (!= null).key - is the name of the parameter to test.true if that parameter is present (NOT null), false
otherwise.public String getParameter(String key)
DialogPlace.key - is the name of the requested parameter.null if NOT set.public <T> T getParameter(String key, Class<T> type)
DialogPlace.T - is the generic type of the desired parameter value.key - is the name of the requested parameter.type - is the desired type of the parametertype. Will be
null if NOT set.protected SimpleGenericValueConverter getValueConverter()
SimpleGenericValueConverter used for conversion in
getParameter(String, Class).public static DialogPlace fromString(String place)
toString().place - is the string-representation of the DialogPlace to create.DialogPlace.Copyright © 2001–2016 mmm-Team. All rights reserved.