Package de.hybris.platform.cockpit.util
Class ViewUpdateUtils
- java.lang.Object
-
- de.hybris.platform.cockpit.util.ViewUpdateUtils
-
public class ViewUpdateUtils extends java.lang.Object
Utility class for adding a "self update" feature to zk components
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ViewUpdateUtils.UpdateCallbackObject
An object that can be attached to a zk component
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
MODIFIED_ITEM_KEY
static java.lang.String
MODIFIED_PROPERTIES_KEY
-
Constructor Summary
Constructors Constructor Description ViewUpdateUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Map<java.lang.String,java.lang.Object>
createItemPropertyContext(TypedObject item, java.util.Collection<PropertyDescriptor> modifiedProperties)
Convenience method to create a context map that can be checked later byisMatchingItemPropertyContext(Map, TypedObject, PropertyDescriptor)
andisUpdateNeeded(Map, TypedObject, PropertyDescriptor, TypeService, ValueService)
.static boolean
isMatchingItemPropertyContext(java.util.Map<java.lang.String,java.lang.Object> ctx, TypedObject item, PropertyDescriptor propertyDescriptor)
Checks, if a TypedObject and PropertyDescriptor is contained in the given contextstatic boolean
isUpdateNeeded(java.util.Map<java.lang.String,java.lang.Object> ctx, TypedObject item, PropertyDescriptor propertyDescriptor, TypeService typeService, ValueService valueService)
Utility method to check, if an update is needed regarding to changes of an item.static void
performViewUpdate(org.zkoss.zk.ui.Component component, java.util.Map<java.lang.String,java.lang.Object> ctx, boolean recursive)
Try to update the current zk component, according to the attachedViewUpdateUtils.UpdateCallbackObject
object.static void
setUpdateCallback(org.zkoss.zk.ui.Component component, ViewUpdateUtils.UpdateCallbackObject updateCallbackObject)
Attaches anViewUpdateUtils.UpdateCallbackObject
object to a zk componentstatic void
suppressNextUpdateOn(org.zkoss.zk.ui.Component component)
Marks the given zk component to prevent an update at the next run ofperformViewUpdate(Component, Map, boolean)
.
-
-
-
Field Detail
-
MODIFIED_PROPERTIES_KEY
public static final java.lang.String MODIFIED_PROPERTIES_KEY
- See Also:
- Constant Field Values
-
MODIFIED_ITEM_KEY
public static final java.lang.String MODIFIED_ITEM_KEY
- See Also:
- Constant Field Values
-
-
Method Detail
-
performViewUpdate
public static void performViewUpdate(org.zkoss.zk.ui.Component component, java.util.Map<java.lang.String,java.lang.Object> ctx, boolean recursive)
Try to update the current zk component, according to the attachedViewUpdateUtils.UpdateCallbackObject
object. If recursive is set to true, also recursively updates the child components.- Parameters:
component
- the zk component to updatectx
- additional context parameters, which are passed to theViewUpdateUtils.UpdateCallbackObject.update(Component, Map)
method.recursive
- true, if the update should include all child components
-
setUpdateCallback
public static void setUpdateCallback(org.zkoss.zk.ui.Component component, ViewUpdateUtils.UpdateCallbackObject updateCallbackObject)
Attaches anViewUpdateUtils.UpdateCallbackObject
object to a zk component- Parameters:
component
- the zk componentupdateCallbackObject
- an instance ofViewUpdateUtils.UpdateCallbackObject
-
suppressNextUpdateOn
public static void suppressNextUpdateOn(org.zkoss.zk.ui.Component component)
Marks the given zk component to prevent an update at the next run ofperformViewUpdate(Component, Map, boolean)
. This is pretty useful e.g. when changing a value in a cockpit editor which usually causes an item changed event that again may the reason for re-rendering the editor. In most cases this is not necessary, since the change is immediately reflected to the editor and a re-rendering will lose the focus on it.- Parameters:
component
- the component
-
isUpdateNeeded
public static boolean isUpdateNeeded(java.util.Map<java.lang.String,java.lang.Object> ctx, TypedObject item, PropertyDescriptor propertyDescriptor, TypeService typeService, ValueService valueService)
Utility method to check, if an update is needed regarding to changes of an item. CallsisMatchingItemPropertyContext(Map, TypedObject, PropertyDescriptor)
and does some additionally tests, if the changed item may be referenced by the property- Parameters:
ctx
- a map that contains informations about modified item and properties, mapped to the keysMODIFIED_ITEM_KEY
andMODIFIED_PROPERTIES_KEY
item
- the item that should be checked against the contextpropertyDescriptor
- the property the should be checked against the contexttypeService
- the typeService- Returns:
- true, if update is needed
-
isMatchingItemPropertyContext
public static boolean isMatchingItemPropertyContext(java.util.Map<java.lang.String,java.lang.Object> ctx, TypedObject item, PropertyDescriptor propertyDescriptor)
Checks, if a TypedObject and PropertyDescriptor is contained in the given context- Parameters:
ctx
- a map that contains informations about modified item and properties, mapped to the keysMODIFIED_ITEM_KEY
andMODIFIED_PROPERTIES_KEY
item
- the item that should be checked against the contextpropertyDescriptor
- the property the should be checked against the context- Returns:
- true, if the context contains item and property
-
createItemPropertyContext
public static java.util.Map<java.lang.String,java.lang.Object> createItemPropertyContext(TypedObject item, java.util.Collection<PropertyDescriptor> modifiedProperties)
Convenience method to create a context map that can be checked later byisMatchingItemPropertyContext(Map, TypedObject, PropertyDescriptor)
andisUpdateNeeded(Map, TypedObject, PropertyDescriptor, TypeService, ValueService)
.- Parameters:
item
- the item that should be added to the contextmodifiedProperties
- the properties that should be added to the context- Returns:
- the context map
-
-