Package org.bedework.util.struts
Class UtilActionForm
- java.lang.Object
-
- org.apache.struts.action.ActionForm
-
- org.bedework.util.struts.UtilActionForm
-
- All Implemented Interfaces:
Serializable
public class UtilActionForm extends org.apache.struts.action.ActionFormThis class provides some convenience methods for use by ActionForm objects.- Author:
- Mike Douglass
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classUtilActionForm.IntValError????static classUtilActionForm.ValErrorValue error
-
Field Summary
Fields Modifier and Type Field Description protected HashMapappVarsApplication variables.protected StringbrowserTypeBrowser typeprotected StringconfirmationIdConfirmation id - require this on formsprotected StringcontentNameOne shot content name.protected StringcontextThe part of the URL that identifies the application - Of the form "/" + name-of-app, e.g.protected StringcurrentUserThe current authenticated user.protected booleandebugAre we debugging?protected MessageEmiterrAn error object reinitialised at each entry to the abstract actionprotected booleaninitialisedHave we initialised?protected org.apache.struts.util.MessageResourcesmresSo we can get hold of propertiesprotected MessageEmitmsgA message object reinitialised at each entry to the abstract actionprotected booleannocacheIs nocache on?protected StringschemeHostPortFirst part of URL.protected StringsessionIdSession id -protected StringurlIncoming URL.protected StringurlPrefixscheme + host + port part of the url together with the context.protected StringyesnoGeneral yes/no answer
-
Constructor Summary
Constructors Constructor Description UtilActionForm()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassignConfirmationId(String val)This should not be setConfirmationId as that exposes it to the incoming request.voidassignCurrentUser(String val)This should not be setCurrentUser as that exposes it to the incoming request.voidassignInuse(boolean val)Set inuse flagvoidassignSessionId(String val)This should not be setSessionId as that exposes it to the incoming request.voiddecWaiters()Dec waiting for resourceSetgetAppVars()StringgetBrowserType()StringgetConfirmationId()StringgetContentName()StringgetContext()StringgetCurDate()StringgetCurDateTime()LocalegetCurrentLocale()StringgetCurrentUser()StringgetCurShortDate()StringgetCurShortDateTime()StringgetCurTime()booleangetDebug()MessageEmitgetErr()booleangetErrorsEmitted()booleangetInitialised()booleangetInuse()booleangetMessagesEmitted()org.apache.struts.util.MessageResourcesgetMres()MessageEmitgetMsg()booleangetNocache()StringgetSchemeHostPort()StringgetSessionId()StringgetUrl()StringgetUrlPrefix()Returns the scheme + host + port part of the url together with the path up to the servlet path.String[]getVals(String prop)Get a list of property values and return as a string array.String[]getVals(String pre, String prop, String post)Get a list of property values and return as a string array.intgetWaiters()Get waiting for resourceStringgetYesno()voidincWaiters()Inc waiting for resourceintintVal(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).booleanisYes()voidprocessError(MessageEmit err, UtilActionForm.ValError ve)Override this to emit messagesbooleanprocessErrors(MessageEmit err)processErrors is called to determine if there were any errors.voidsetAppVarsTbl(HashMap val)voidsetBrowserType(String val)voidsetContentName(String val)voidsetContext(String val)Set the part of the URL that identifies the application.voidsetCurrentLocale(Locale val)voidsetDebug(boolean val)voidsetErr(MessageEmit val)voidsetException(Throwable t)Can be called by a page to signal an exceptiuonvoidsetInitialised(boolean val)Set initialised statevoidsetMres(org.apache.struts.util.MessageResources val)voidsetMsg(MessageEmit val)voidsetNocache(boolean val)voidsetSchemeHostPort(String val)voidsetUrl(String val)voidsetUrlPrefix(String val)Sets the scheme + host + port part of the url together with the path up to the servlet path.voidsetYesno(String val)
-
-
-
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
-
-
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 inprop1=aval prop2=bvalThere 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 inprop1=aval prop2=bvalThere 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 prefixprop- Property namepost- 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
-
processError
public void processError(MessageEmit err, UtilActionForm.ValError ve)
Override this to emit messages- Parameters:
err-ve-
-
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
-
-