Class Action

  • All Implemented Interfaces:
    java.io.Serializable

    public class Action
    extends java.lang.Object
    implements java.io.Serializable
    Custom action
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static char ACTION_ALL
      Display both on list header, form and lines of list
      static char ACTION_FORM
      Enable on form / display on form and lines of list
      static char ACTION_FORM_ONLY
      Enable on form / display on form only, not on list items
      static char ACTION_HIDDEN
      Hidden on UI (but may be enabled for a cron job)
      static char ACTION_LIST
      Enable on list / display in list header
      static char ACTION_LIST_FORM
      Both form and List header (but not on list items)
      static char ACTION_LIST_ITEMS_ONLY
      Enable on form / display on list items only, not on form
      static char ACTION_PLUS
      In Plus button
      static int ASYNC_ISOLATED
      New thread with isolated Grant (outside session) and a new job instance of object
      static int ASYNC_NONE
      Synchronous call (means that the job will be launched directly after instantiation)
      static int ASYNC_SESSION
      New thread with the current Grant and the current instance of object
      static int ASYNC_STANDALONE
      New thread with the current Grant and a new job instance of object
      static int LIST_COUNT_NONE
      No rows counter on list action
      static int LIST_COUNT_SEL_OR_ALL
      Count selected rows or all rows if none selected by user
      static int LIST_COUNT_SELECTED
      Count selected rows only
    • Constructor Summary

      Constructors 
      Constructor Description
      Action​(Action action, int position, java.lang.String lang)
      Copy constructor
      Action​(java.lang.String name, char type, java.util.Map<java.lang.String,​java.lang.String> display, java.lang.String image, int position, boolean plus, int count)
      Silent constructor (no method, no URL).
      Action​(java.lang.String id, java.lang.String name, char type, java.util.Map<java.lang.String,​java.lang.String> display, java.util.Map<java.lang.String,​java.lang.String> help, java.lang.String method, java.lang.String expr, java.lang.String url, java.lang.String image, boolean confirm, boolean plus, int async, int asyncDepth, java.lang.String confirmUI, java.lang.String confirmExpr, int countRows)
      Deprecated. 
      Action​(java.lang.String id, java.lang.String name, char type, java.util.Map<java.lang.String,​java.lang.String> display, java.util.Map<java.lang.String,​java.lang.String> help, java.lang.String method, java.lang.String expr, java.lang.String url, java.lang.String image, boolean confirm, boolean plus, int async, int asyncDepth, java.lang.String confirmUI, java.lang.String confirmExpr, int countRows, java.lang.String color, java.lang.String bgcolor)
      Constructor
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void addConfirmField​(java.lang.String lang, ObjectField field)
      Add a field to confirm action
      int countRows()
      Count selected rows on UI?
      void disable()
      Deactivate the action
      void enable()
      Activate the action
      java.lang.String extractTarget()
      Extract URL target
      java.lang.String extractURL​(ObjectCore obj, java.lang.String contextParams)
      Extract URL
      java.lang.String getAnchor​(ObjectCore obj, java.lang.String contextParams)
      Get URL anchor
      java.lang.String getAnchor​(ObjectCore obj, java.lang.String contextParams, java.lang.String extraParams)
      Get URL anchor
      int getAsync()
      Get asynchronous mode
      int getAsyncDepth()
      Get asynchronous depth
      java.lang.String getBackgroundColor()
      Get background color
      static char getButtonVisibility​(java.lang.String val, char dflt)
      Convert list BTN_VIS to Action visibility
      java.lang.String getConfirmExpr()
      Get action confirmation expression
      ObjectField getConfirmField​(java.lang.String name)
      Field to confirm action
      ObjectField getConfirmField​(java.lang.String lang, java.lang.String name)
      Field to confirm action
      java.util.List<ObjectField> getConfirmFields​(java.lang.String lang)
      Fields to confirm action
      java.lang.String getConfirmUI()
      Action confirmation template
      int getDefaultPosition()
      Get default position
      char getDefaultType()
      Get action default type
      java.util.Map<java.lang.String,​java.lang.String> getDisplay()
      Deprecated.
      Use getDisplays
      java.lang.String getDisplay​(java.lang.String lang)
      Get action translation
      java.util.Map<java.lang.String,​java.lang.String> getDisplays()
      Get action translations
      java.lang.String getExpression()
      Get expression
      java.util.Map<java.lang.String,​java.lang.String> getHelp()
      Deprecated.
      Use getHelps
      java.lang.String getHelp​(java.lang.String lang)
      Get help
      java.util.Map<java.lang.String,​java.lang.String> getHelps()
      Get helps
      java.lang.String getId()  
      static java.lang.String getId​(java.lang.String name)
      Get action Id from name
      java.lang.String getImage()
      Get the icon name
      java.lang.String getLabel​(java.lang.String lang)
      Get action transaction (alias to getDisplay)
      java.util.Map<java.lang.String,​java.lang.String> getLabels()
      Get action translations (alias to getDisplays)
      java.lang.String getMethod()
      Get method
      java.lang.String getName()  
      static java.lang.String getName​(java.lang.String rowId)
      Get action name from rowId
      java.lang.String getTextColor()
      Get text color
      char getType()
      Get action current type
      java.lang.String getURL()
      Get URL
      boolean isConfirm()
      Does action needs a user confirmation?
      boolean isCustom()
      Is a custom action?
      boolean isDefaultPlus()
      By default in the "Plus" button?
      boolean isEnabled()
      Is the action enabled?
      boolean isFormVisible()
      Is visible on form?
      boolean isHidden()
      Is hidden?
      boolean isLimitedbyCount()
      History of job is limited by count?
      boolean isLimitedByDays()
      History of job is limited by days?
      boolean isListItemVisible()
      Is visible on list items?
      boolean isListVisible()
      Is list visible on list?
      boolean isPlus()
      Action can be displayed in the "Plus" button ?
      boolean isServerSide()
      Is server-side (backend) action (has a method or a scripted expression)?
      boolean isTransition()
      Is a transition action?
      boolean isUnlimited()
      Unlimited jobs history?
      void setAsync​(int async)
      Set asynchronous mode
      void setAsyncDepth​(int depth)
      Set asynchronous depth
      void setBackgroundColor​(java.lang.String color)
      Set background color
      void setConfirm​(boolean b)
      Set whether action needs confirmation
      void setConfirmExpr​(java.lang.String expr)
      Set confirmation expression
      void setConfirmUI​(java.lang.String t)
      Set confirmation template
      void setDefaultPosition​(int pos)
      Set default position
      void setDisplay​(java.lang.String lang, java.lang.String disp)
      Set action translation
      void setEnabled​(boolean b)
      Enable/disable the action
      void setExpression​(java.lang.String expr)
      Set expression
      void setHelp​(java.lang.String lang, java.lang.String help)
      Set help
      void setImage​(java.lang.String name)
      Set the icon name
      void setLabel​(java.lang.String lang, java.lang.String disp)
      Set action translation (alias to setDisplay)
      void setMethod​(java.lang.String method)
      Set method
      void setName​(java.lang.String name)  
      void setPlus​(boolean plus)
      Set the display in the "Plus" button
      void setTextColor​(java.lang.String color)
      Set text color
      void setTransition​(boolean b)
      Set whether action is a transition
      void setType​(char type)
      Change action current type
      void setURL​(java.lang.String url)
      Set URL
      boolean showLabel()
      Show label on button?
      void showLabel​(boolean show)
      Show label on button?
      org.json.JSONObject toJSONObject()
      Generates a JSON object representation of the action
      java.lang.String toString()
      Generates a string representation of the action
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • ACTION_LIST

        public static final char ACTION_LIST
        Enable on list / display in list header
        See Also:
        Constant Field Values
      • ACTION_FORM

        public static final char ACTION_FORM
        Enable on form / display on form and lines of list
        See Also:
        Constant Field Values
      • ACTION_ALL

        public static final char ACTION_ALL
        Display both on list header, form and lines of list
        See Also:
        Constant Field Values
      • ACTION_LIST_FORM

        public static final char ACTION_LIST_FORM
        Both form and List header (but not on list items)
        See Also:
        Constant Field Values
      • ACTION_FORM_ONLY

        public static final char ACTION_FORM_ONLY
        Enable on form / display on form only, not on list items
        See Also:
        Constant Field Values
      • ACTION_LIST_ITEMS_ONLY

        public static final char ACTION_LIST_ITEMS_ONLY
        Enable on form / display on list items only, not on form
        See Also:
        Constant Field Values
      • ACTION_HIDDEN

        public static final char ACTION_HIDDEN
        Hidden on UI (but may be enabled for a cron job)
        See Also:
        Constant Field Values
      • ASYNC_NONE

        public static final int ASYNC_NONE
        Synchronous call (means that the job will be launched directly after instantiation)
        See Also:
        Constant Field Values
      • ASYNC_SESSION

        public static final int ASYNC_SESSION
        New thread with the current Grant and the current instance of object
        See Also:
        Constant Field Values
      • ASYNC_STANDALONE

        public static final int ASYNC_STANDALONE
        New thread with the current Grant and a new job instance of object
        See Also:
        Constant Field Values
      • ASYNC_ISOLATED

        public static final int ASYNC_ISOLATED
        New thread with isolated Grant (outside session) and a new job instance of object
        See Also:
        Constant Field Values
      • LIST_COUNT_NONE

        public static final int LIST_COUNT_NONE
        No rows counter on list action
        See Also:
        Constant Field Values
      • LIST_COUNT_SELECTED

        public static final int LIST_COUNT_SELECTED
        Count selected rows only
        See Also:
        Constant Field Values
      • LIST_COUNT_SEL_OR_ALL

        public static final int LIST_COUNT_SEL_OR_ALL
        Count selected rows or all rows if none selected by user
        See Also:
        Constant Field Values
    • Constructor Detail

      • Action

        @Deprecated
        public Action​(java.lang.String id,
                      java.lang.String name,
                      char type,
                      java.util.Map<java.lang.String,​java.lang.String> display,
                      java.util.Map<java.lang.String,​java.lang.String> help,
                      java.lang.String method,
                      java.lang.String expr,
                      java.lang.String url,
                      java.lang.String image,
                      boolean confirm,
                      boolean plus,
                      int async,
                      int asyncDepth,
                      java.lang.String confirmUI,
                      java.lang.String confirmExpr,
                      int countRows)
        Deprecated.
        Constructor
        Parameters:
        id - Id
        name - Action name
        type - Visibility
        display - Translation per language
        help - Help per language
        method - Action method
        expr - Action expression
        url - Action URL
        image - Icon
        confirm - Confirm action ?
        plus - Display in Plus button when possible ?
        async - Asynchronous mode CronJob.ASYNC_*
        asyncDepth - Execution jobs depth (null not limited)
        confirmUI - Optional template to confirm action
        countRows - Count selected rows on UI
      • Action

        public Action​(java.lang.String id,
                      java.lang.String name,
                      char type,
                      java.util.Map<java.lang.String,​java.lang.String> display,
                      java.util.Map<java.lang.String,​java.lang.String> help,
                      java.lang.String method,
                      java.lang.String expr,
                      java.lang.String url,
                      java.lang.String image,
                      boolean confirm,
                      boolean plus,
                      int async,
                      int asyncDepth,
                      java.lang.String confirmUI,
                      java.lang.String confirmExpr,
                      int countRows,
                      java.lang.String color,
                      java.lang.String bgcolor)
        Constructor
        Parameters:
        id - Id
        name - Action name
        type - Visibility
        display - Translation per language
        help - Help per language
        method - Action method
        expr - Action expression
        url - Action URL
        image - Icon
        confirm - Confirm action ?
        plus - Display in Plus button when possible ?
        async - Asynchronous mode CronJob.ASYNC_*
        asyncDepth - Execution jobs depth (null not limited)
        confirmUI - Optional template to confirm action
        countRows - Count selected rows on UI
        color - Text color
        bgcolor - Background color
      • Action

        public Action​(java.lang.String name,
                      char type,
                      java.util.Map<java.lang.String,​java.lang.String> display,
                      java.lang.String image,
                      int position,
                      boolean plus,
                      int count)
        Silent constructor (no method, no URL). Internal usage to generate common actions
        Parameters:
        name - Name
        type - type
        display - display
        image - Image
        position - Position
        plus - is plus ?
        count - count rows ?
      • Action

        public Action​(Action action,
                      int position,
                      java.lang.String lang)
        Copy constructor
        Parameters:
        action - Action
        position - Position
        lang - Optional user language to limit copy
    • Method Detail

      • getId

        public java.lang.String getId()
      • getId

        public static java.lang.String getId​(java.lang.String name)
        Get action Id from name
        Parameters:
        name - Action name
        Returns:
        action Id if exists
      • getName

        public java.lang.String getName()
      • getName

        public static java.lang.String getName​(java.lang.String rowId)
        Get action name from rowId
        Parameters:
        rowId - Row Id
        Returns:
        action name if exists
      • setName

        public void setName​(java.lang.String name)
      • setType

        public void setType​(char type)
        Change action current type
        Parameters:
        type - action type
      • getType

        public char getType()
        Get action current type
        Returns:
        action current type
      • getDefaultType

        public char getDefaultType()
        Get action default type
        Returns:
        action default type
      • getDisplay

        public java.lang.String getDisplay​(java.lang.String lang)
        Get action translation
        Parameters:
        lang - Language code
      • getLabel

        public java.lang.String getLabel​(java.lang.String lang)
        Get action transaction (alias to getDisplay)
        Parameters:
        lang - Language code
      • setDisplay

        public void setDisplay​(java.lang.String lang,
                               java.lang.String disp)
        Set action translation
        Parameters:
        lang - Language code
        disp - Translation
      • setLabel

        public void setLabel​(java.lang.String lang,
                             java.lang.String disp)
        Set action translation (alias to setDisplay)
        Parameters:
        lang - Language code
        disp - Translation
      • getDisplay

        @Deprecated(forRemoval=false,
                    since="4.0")
        public java.util.Map<java.lang.String,​java.lang.String> getDisplay()
        Deprecated.
        Use getDisplays
      • getDisplays

        public java.util.Map<java.lang.String,​java.lang.String> getDisplays()
        Get action translations
      • getLabels

        public java.util.Map<java.lang.String,​java.lang.String> getLabels()
        Get action translations (alias to getDisplays)
      • getHelp

        public java.lang.String getHelp​(java.lang.String lang)
        Get help
        Parameters:
        lang - Language code
      • setHelp

        public void setHelp​(java.lang.String lang,
                            java.lang.String help)
        Set help
        Parameters:
        lang - Language code
        help - Help
      • getHelps

        public java.util.Map<java.lang.String,​java.lang.String> getHelps()
        Get helps
      • getHelp

        @Deprecated(forRemoval=false,
                    since="4.0")
        public java.util.Map<java.lang.String,​java.lang.String> getHelp()
        Deprecated.
        Use getHelps
      • getMethod

        public java.lang.String getMethod()
        Get method
      • setMethod

        public void setMethod​(java.lang.String method)
        Set method
        Parameters:
        method - Method
      • getExpression

        public java.lang.String getExpression()
        Get expression
      • setExpression

        public void setExpression​(java.lang.String expr)
        Set expression
        Parameters:
        expr - Expression
      • getURL

        public java.lang.String getURL()
        Get URL
      • setURL

        public void setURL​(java.lang.String url)
        Set URL
        Parameters:
        url - URL
      • getAsync

        public int getAsync()
        Get asynchronous mode
      • setAsync

        public void setAsync​(int async)
        Set asynchronous mode
        Parameters:
        async - Asynchronous mode
      • getAsyncDepth

        public int getAsyncDepth()
        Get asynchronous depth
      • setAsyncDepth

        public void setAsyncDepth​(int depth)
        Set asynchronous depth
        Parameters:
        depth - Asynchronous depth
      • isLimitedByDays

        public boolean isLimitedByDays()
        History of job is limited by days?
        Returns:
        is limited by days ?
      • isLimitedbyCount

        public boolean isLimitedbyCount()
        History of job is limited by count?
        Returns:
        is limited by count ?
      • isUnlimited

        public boolean isUnlimited()
        Unlimited jobs history?
        Returns:
        is unlimited
      • extractURL

        public java.lang.String extractURL​(ObjectCore obj,
                                           java.lang.String contextParams)
        Extract URL
        Parameters:
        obj - Object
        contextParams - Context parameters
      • extractTarget

        public java.lang.String extractTarget()
        Extract URL target
      • getAnchor

        public java.lang.String getAnchor​(ObjectCore obj,
                                          java.lang.String contextParams)
        Get URL anchor
        Parameters:
        obj - Object
        contextParams - Context parameters
      • getAnchor

        public java.lang.String getAnchor​(ObjectCore obj,
                                          java.lang.String contextParams,
                                          java.lang.String extraParams)
        Get URL anchor
        Parameters:
        obj - object
        contextParams - Context parameters
        extraParams - Extra parameters
      • getImage

        public java.lang.String getImage()
        Get the icon name
      • setImage

        public void setImage​(java.lang.String name)
        Set the icon name
        Parameters:
        name - icon name
      • countRows

        public int countRows()
        Count selected rows on UI?
        Returns:
        Selected rows count
      • isConfirm

        public boolean isConfirm()
        Does action needs a user confirmation?
        Returns:
        True if user confirmation is needed
      • setConfirm

        public void setConfirm​(boolean b)
        Set whether action needs confirmation
        Parameters:
        b - Confirmation?
      • getConfirmExpr

        public java.lang.String getConfirmExpr()
        Get action confirmation expression
        Returns:
        Confirmation expression
      • setConfirmExpr

        public void setConfirmExpr​(java.lang.String expr)
        Set confirmation expression
        Parameters:
        expr - Confirmation expression
      • getConfirmUI

        public java.lang.String getConfirmUI()
        Action confirmation template
      • setConfirmUI

        public void setConfirmUI​(java.lang.String t)
        Set confirmation template
        Parameters:
        t - HTML template
      • addConfirmField

        public void addConfirmField​(java.lang.String lang,
                                    ObjectField field)
        Add a field to confirm action
        Parameters:
        lang - User language
        field - Field definition
      • getConfirmFields

        public java.util.List<ObjectField> getConfirmFields​(java.lang.String lang)
        Fields to confirm action
        Parameters:
        lang - User language
        Returns:
        List of fields to confirm action
      • getConfirmField

        public ObjectField getConfirmField​(java.lang.String lang,
                                           java.lang.String name)
        Field to confirm action
        Parameters:
        lang - User language
        name - Field name
        Returns:
        Field or null if unknown
      • getConfirmField

        public ObjectField getConfirmField​(java.lang.String name)
        Field to confirm action
        Parameters:
        name - Field name
        Returns:
        Field or null if unknown
      • isPlus

        public boolean isPlus()
        Action can be displayed in the "Plus" button ?
        Returns:
        True if in "Plus" button
      • setPlus

        public void setPlus​(boolean plus)
        Set the display in the "Plus" button
        Parameters:
        plus - Display in the "Plus" button?
      • isDefaultPlus

        public boolean isDefaultPlus()
        By default in the "Plus" button?
        Returns:
        By default in the "Plus" button?
      • getDefaultPosition

        public int getDefaultPosition()
        Get default position
        Returns:
        Default position
      • setDefaultPosition

        public void setDefaultPosition​(int pos)
        Set default position
        Parameters:
        pos - Position
      • showLabel

        public boolean showLabel()
        Show label on button?
        Returns:
        True if label is shown
      • showLabel

        public void showLabel​(boolean show)
        Show label on button?
        Parameters:
        show - Show label?
      • getBackgroundColor

        public java.lang.String getBackgroundColor()
        Get background color
      • setBackgroundColor

        public void setBackgroundColor​(java.lang.String color)
        Set background color
        Parameters:
        color - RGB color
      • getTextColor

        public java.lang.String getTextColor()
        Get text color
      • setTextColor

        public void setTextColor​(java.lang.String color)
        Set text color
        Parameters:
        color - RGB color
      • isCustom

        public boolean isCustom()
        Is a custom action?
        Returns:
        True if action is custom
      • isTransition

        public boolean isTransition()
        Is a transition action?
        Returns:
        True if action is transition
      • setTransition

        public void setTransition​(boolean b)
        Set whether action is a transition
        Parameters:
        b - Transition?
      • enable

        public void enable()
        Activate the action
      • disable

        public void disable()
        Deactivate the action
      • isEnabled

        public boolean isEnabled()
        Is the action enabled?
        Returns:
        True if enabled
      • setEnabled

        public void setEnabled​(boolean b)
        Enable/disable the action
        Parameters:
        b - Enabled?
      • isFormVisible

        public boolean isFormVisible()
        Is visible on form?
        Returns:
        True if visible on form
      • isListVisible

        public boolean isListVisible()
        Is list visible on list?
        Returns:
        True if visible on list
      • isListItemVisible

        public boolean isListItemVisible()
        Is visible on list items?
        Returns:
        True if visible on list items
      • isHidden

        public boolean isHidden()
        Is hidden?
        Returns:
        True if hidden
      • isServerSide

        public boolean isServerSide()
        Is server-side (backend) action (has a method or a scripted expression)?
        Returns:
        True if action is server-side
      • getButtonVisibility

        public static char getButtonVisibility​(java.lang.String val,
                                               char dflt)
        Convert list BTN_VIS to Action visibility
        Parameters:
        val - Value
        dflt - default
        Returns:
        Action visibility
      • toJSONObject

        public org.json.JSONObject toJSONObject()
        Generates a JSON object representation of the action
        Returns:
        Action as JSON object
      • toString

        public java.lang.String toString()
        Generates a string representation of the action
        Overrides:
        toString in class java.lang.Object
        Returns:
        Action as string