Class UtilActionForm

  • All Implemented Interfaces:
    Serializable

    public class UtilActionForm
    extends org.apache.struts.action.ActionForm
    This class provides some convenience methods for use by ActionForm objects.
    Author:
    Mike Douglass
    See Also:
    Serialized Form
    • Field Detail

      • debug

        protected boolean debug
        Are we debugging?
      • initialised

        protected boolean initialised
        Have we initialised?
      • nocache

        protected boolean nocache
        Is nocache on?
      • err

        protected transient MessageEmit err
        An error object reinitialised at each entry to the abstract action
      • msg

        protected transient MessageEmit msg
        A message object reinitialised at each entry to the abstract action
      • mres

        protected org.apache.struts.util.MessageResources mres
        So we can get hold of properties
      • appVars

        protected HashMap appVars
        Application variables. These can be set with request parameters and dumped into the page for use by jsp and xslt.
      • contentName

        protected String contentName
        One shot content name.
      • url

        protected String url
        Incoming URL.
      • schemeHostPort

        protected String schemeHostPort
        First part of URL. Allows us to target services on same host.
      • context

        protected String context
        The part of the URL that identifies the application - Of the form "/" + name-of-app, e.g. /kiosk
      • urlPrefix

        protected String urlPrefix
        scheme + host + port part of the url together with the context.
      • currentUser

        protected String currentUser
        The current authenticated user. May be null
      • sessionId

        protected String sessionId
        Session id -
      • confirmationId

        protected String confirmationId
        Confirmation id - require this on forms
      • yesno

        protected String yesno
        General yes/no answer
      • browserType

        protected String browserType
        Browser type
    • Constructor Detail

      • UtilActionForm

        public UtilActionForm()
    • Method Detail

      • incWaiters

        public void incWaiters()
        Inc waiting for resource
      • decWaiters

        public void decWaiters()
        Dec waiting for resource
      • getWaiters

        public int getWaiters()
        Get waiting for resource
        Returns:
        num waiting for resource
      • assignInuse

        public void assignInuse​(boolean val)
        Set inuse flag
        Parameters:
        val -
      • getInuse

        public boolean getInuse()
        Returns:
        boolean value of inuse flag
      • setDebug

        public void setDebug​(boolean val)
        Parameters:
        val -
      • getDebug

        public boolean getDebug()
        Returns:
        true for debugging on
      • setInitialised

        public void setInitialised​(boolean val)
        Set initialised state
        Parameters:
        val -
      • getInitialised

        public boolean getInitialised()
        Returns:
        initialised state
      • setCurrentLocale

        public void setCurrentLocale​(Locale val)
        Parameters:
        val -
      • getCurrentLocale

        public Locale getCurrentLocale()
        Returns:
        current locale
      • setNocache

        public void setNocache​(boolean val)
        Parameters:
        val -
      • getNocache

        public boolean getNocache()
        Returns:
        boolean true for nocache
      • getMres

        public org.apache.struts.util.MessageResources getMres()
        Returns:
        MessageResources
      • setMres

        public void setMres​(org.apache.struts.util.MessageResources val)
        Parameters:
        val -
      • setErr

        public void setErr​(MessageEmit val)
        Parameters:
        val -
      • getErr

        public MessageEmit getErr()
        Returns:
        MessageEmit
      • getErrorsEmitted

        public boolean getErrorsEmitted()
        Returns:
        boolean
      • setMsg

        public void setMsg​(MessageEmit val)
        Parameters:
        val -
      • getMsg

        public MessageEmit getMsg()
        Returns:
        boolean
      • getMessagesEmitted

        public boolean getMessagesEmitted()
        Returns:
        boolean
      • setException

        public void setException​(Throwable t)
        Can be called by a page to signal an exceptiuon
        Parameters:
        t -
      • setAppVarsTbl

        public void setAppVarsTbl​(HashMap val)
        Parameters:
        val -
      • getAppVars

        public Set getAppVars()
        Returns:
        Set
      • getVals

        public String[] getVals​(String prop)
        Get a list of property values and return as a string array. The properties are stored with consectutively numbered names as in
             prop1=aval
             prop2=bval
          
        There can be no gaps in the sequence. setMres must have been called previously.
        Parameters:
        prop - Property name
        Returns:
        String[] values as a String array
      • getVals

        public String[] getVals​(String pre,
                                String prop,
                                String post)
        Get a list of property values and return as a string array. The properties are stored with consectutively numbered names as in
             prop1=aval
             prop2=bval
          
        There can be no gaps in the sequence. If pre or post are non-null they are the property names of values to be added to the beginning or end. setMres must have been called previously.
        Parameters:
        pre - Property name of prefix
        prop - Property name
        post - Property name of postfix
        Returns:
        String[] values as a String array
      • setContentName

        public void setContentName​(String val)
        Parameters:
        val -
      • getContentName

        public String getContentName()
        Returns:
        String
      • setUrl

        public void setUrl​(String val)
        Parameters:
        val -
      • getUrl

        public String getUrl()
        Returns:
        String
      • setSchemeHostPort

        public void setSchemeHostPort​(String val)
        Parameters:
        val -
      • getSchemeHostPort

        public String getSchemeHostPort()
        Returns:
        String
      • setContext

        public void setContext​(String val)
        Set the part of the URL that identifies the application.
        Parameters:
        val - context path in form "/" + name-of-app, e.g. /kiosk
      • getContext

        public String getContext()
        Returns:
        String
      • setUrlPrefix

        public void setUrlPrefix​(String val)
        Sets the scheme + host + port part of the url together with the path up to the servlet path. This allows us to append a new action to the end.

        For example, we want val="http://myhost.com:8080/myapp"

        Parameters:
        val - the URL prefix
      • getUrlPrefix

        public String getUrlPrefix()
        Returns the scheme + host + port part of the url together with the path up to the servlet path. This allows us to append a new action to the end.
        Returns:
        String the URL prefix
      • assignCurrentUser

        public void assignCurrentUser​(String val)
        This should not be setCurrentUser as that exposes it to the incoming request.
        Parameters:
        val - String user id
      • getCurrentUser

        public String getCurrentUser()
        Returns:
        String
      • assignSessionId

        public void assignSessionId​(String val)
        This should not be setSessionId as that exposes it to the incoming request.
        Parameters:
        val - String session id
      • getSessionId

        public String getSessionId()
        Returns:
        String
      • assignConfirmationId

        public void assignConfirmationId​(String val)
        This should not be setConfirmationId as that exposes it to the incoming request.
        Parameters:
        val - String confirmation id
      • getConfirmationId

        public String getConfirmationId()
        Returns:
        String
      • setYesno

        public void setYesno​(String val)
        Parameters:
        val -
      • getYesno

        public String getYesno()
        Returns:
        String
      • isYes

        public boolean isYes()
        Returns:
        String
      • setBrowserType

        public void setBrowserType​(String val)
        Parameters:
        val -
      • getBrowserType

        public String getBrowserType()
        Returns:
        String
      • intVal

        public int intVal​(String newVal,
                          int curVal,
                          String name)
        Convert a string parameter so we can add an error message for incorrect formats (instead of relying on Struts).

        Struts tends to return 0 or null for illegal values, e.g., alpha characters for a number.

        Parameters:
        newVal -
        curVal -
        name -
        Returns:
        String
      • processErrors

        public boolean processErrors​(MessageEmit err)
        processErrors is called to determine if there were any errors. If so processError is called for each error adn the errors vector is cleared. Override the processError method to emit custom messages.
        Parameters:
        err - MessageEmit object
        Returns:
        boolean True if there were errors
      • getCurTime

        public String getCurTime()
        Returns:
        String
      • getCurDate

        public String getCurDate()
        Returns:
        String
      • getCurDateTime

        public String getCurDateTime()
        Returns:
        String
      • getCurShortDate

        public String getCurShortDate()
        Returns:
        String
      • getCurShortDateTime

        public String getCurShortDateTime()
        Returns:
        String