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_NONE
      Synchronous call (means that the job will be launched directly after instantiation)
      static int ASYNC_SESSION
      New thread in the current Grant session with the current instance of Object
      static int ASYNC_STANDALONE
      New Grant session with the 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)
      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)
      Constructor
    • Method Summary

      Modifier and Type Method Description
      void addConfirmField​(java.lang.String name)
      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
      static char getButtonVisibility​(java.lang.String val, char dflt)
      Convert list BTN_VIS to Action visibility
      java.lang.String getConfirmExpr()
      Action confirmation expression
      java.util.List<java.lang.String> getConfirmFields()
      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.
      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()  
      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()  
      char getType()
      Get action current type
      java.lang.String getURL()
      Get URL
      boolean isConfirm()
      Action needs a user confirmation?
      boolean isCustom()
      Is custom or standard action?
      boolean isDefaultPlus()
      By default in Plus button?
      boolean isEnabled()
      Is the action available
      boolean isFormVisible()
      Is form visible?
      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?
      boolean isPlus()
      Action can be displayed in the plus button ?
      boolean isServerSide()
      Is server-side (backed) action (has a method or a scripted expression) ?
      boolean isTransition()
      Is transition action ?
      boolean isUnlimited()
      Unlimited jobs history?
      void setAsync​(int async)
      Set asynchronous mode
      void setAsyncDepth​(int depth)
      Set asynchronous depth
      void setConfirm​(boolean b)
      Set whether action needs confirmation
      void setConfirmExpr​(java.lang.String e)
      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 the action or not
      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 setTransition​(boolean b)
      Set whether action is 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 in the current Grant session with the current instance of Object
        See Also:
        Constant Field Values
      • ASYNC_STANDALONE

        public static final int ASYNC_STANDALONE
        New Grant session with the 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

        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)
        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 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)
        Copy constructor
        Parameters:
        action - Action
        position - Position
    • Method Detail

      • getId

        public java.lang.String getId()
      • getName

        public java.lang.String getName()
      • 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
        public java.util.Map<java.lang.String,​java.lang.String> getDisplay()
        Deprecated.
      • 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
        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?
      • isConfirm

        public boolean isConfirm()
        Action needs a user confirmation?
      • setConfirm

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

        public java.lang.String getConfirmExpr()
        Action confirmation expression
      • setConfirmExpr

        public void setConfirmExpr​(java.lang.String e)
        Set confirmation expression
        Parameters:
        e - 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 name)
        Add a field to confirm action
        Parameters:
        name - Field name
      • getConfirmFields

        public java.util.List<java.lang.String> getConfirmFields()
        Fields to confirm action
      • isPlus

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

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

        public boolean isDefaultPlus()
        By default in Plus button?
        Returns:
        default plus ?
      • 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:
        show label ?
      • showLabel

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

        public boolean isCustom()
        Is custom or standard action?
      • isTransition

        public boolean isTransition()
        Is transition action ?
      • setTransition

        public void setTransition​(boolean b)
        Set whether action is 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 available
        Returns:
        enabled?
      • setEnabled

        public void setEnabled​(boolean b)
        Enable the action or not
        Parameters:
        b - enabled?
      • isFormVisible

        public boolean isFormVisible()
        Is form visible?
      • isListVisible

        public boolean isListVisible()
        Is list visible?
      • isListItemVisible

        public boolean isListItemVisible()
        Is visible on list items?
      • isHidden

        public boolean isHidden()
        Is hidden?
      • isServerSide

        public boolean isServerSide()
        Is server-side (backed) action (has a method or a scripted expression) ?
      • 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