Class ViewUpdateUtils


  • public class ViewUpdateUtils
    extends java.lang.Object
    Utility class for adding a "self update" feature to zk components
    • 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
    • Constructor Detail

      • ViewUpdateUtils

        public ViewUpdateUtils()
    • 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 attached ViewUpdateUtils.UpdateCallbackObject object. If recursive is set to true, also recursively updates the child components.
        Parameters:
        component - the zk component to update
        ctx - additional context parameters, which are passed to the ViewUpdateUtils.UpdateCallbackObject.update(Component, Map) method.
        recursive - true, if the update should include all child components
      • suppressNextUpdateOn

        public static void suppressNextUpdateOn​(org.zkoss.zk.ui.Component component)
        Marks the given zk component to prevent an update at the next run of performViewUpdate(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. Calls isMatchingItemPropertyContext(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 keys MODIFIED_ITEM_KEY and MODIFIED_PROPERTIES_KEY
        item - the item that should be checked against the context
        propertyDescriptor - the property the should be checked against the context
        typeService - 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 keys MODIFIED_ITEM_KEY and MODIFIED_PROPERTIES_KEY
        item - the item that should be checked against the context
        propertyDescriptor - the property the should be checked against the context
        Returns:
        true, if the context contains item and property