All Packages Class Hierarchy This Package Previous Next Index
Class com.startups.webui.Model
java.lang.Object
|
+----com.startups.validation.ValidatableObject
|
+----com.startups.webui.Model
- public abstract class Model
- extends com.startups.validation.ValidatableObject
The base class of all Model objects, which represent
the dynamic state of a web page. Each page is
represented by a Model object, a ControllerServlet,
and one or more views implemented as jsp pages.
Model contains some generic presentation
convenience methods to be called from jsp pages.
-
Model()
-
-
activateValidationDisplay()
-
-
checkAccess(HttpServletRequest, HttpServletResponse)
- In order to require login for a page, in the jsp there should
be a call to this method from the model using the
implicit request and response objects:
someStateModel.checkAccess(request, response);
Add this line of code to the jsp just after the bean
declaration of someStateModel.
-
displayFailedValidations()
- Return a list of failed form validations in red.
-
fontColorTagFor(String)
- Returns a red font color tag if the given fieldName in the given
model is invalid, otherwise returns a black font color tag.
-
getAccessSuccessfulURL()
- Return the url to send the user to after the user
successfully logs in.
-
getLoginPageMessage()
- Return the message to display on the login page when
it is presented to the user.
-
getLoginPageTitle()
- Return the title to display on the login page when
it is presented to the user.
-
getPermissionDeniedURL()
- Return the url to send the user to if the user
successfully logs in, but the user does not contain
the role specified by getRequiredRole().
-
getRequiredRole()
- Return the Class of the required UserRole needed
to access this state.
-
isAccessibleTo(StartupsUser)
- Return true if the page corresponding to this model
is accessible to the given user.
Model
public Model()
isAccessibleTo
public boolean isAccessibleTo(com.startups.business.StartupsUser user)
- Return true if the page corresponding to this model
is accessible to the given user. This method may
be overridden by subclasses if the default behavior
of checking to see if the user contains the role
required by getRequiredRole() is insufficient.
For example, if roles were to contain individual
permissions, an overridden version of isAccessibleTo()
could check for these.
getRequiredRole
public java.lang.Class getRequiredRole()
- Return the Class of the required UserRole needed
to access this state. Return null otherwise.
Subclasses should override this method to return
the needed class. If there is a series of states
that require access protection, the developer may
find it useful to create an abstract subclass of
Model to use as a base:
public abstract class ResourceLocatorAccessModel extends Model {
public Class getRequiredRole() {
return ResourceLocatorRole.class;
}
}
public class SomeStateModel extends ResourceLocatorAccessModel {
...
}
- See Also:
- getPermissionDeniedURL
getAccessSuccessfulURL
public java.lang.String getAccessSuccessfulURL()
- Return the url to send the user to after the user
successfully logs in. Typically this is a home or
start page for the role. By default it returns null,
which will be interpreted by the system to go to
the page that the user originally attempted to access.
Subclasses should override this method if they desire
a successful login to send the user somewhere else.
- See Also:
- getRequiredRole
getPermissionDeniedURL
public java.lang.String getPermissionDeniedURL()
- Return the url to send the user to if the user
successfully logs in, but the user does not contain
the role specified by getRequiredRole(). By default
it sends the user to a role missing error page.
Subclasses should override this method if they desire
to send the user somewhere else--like perhaps a signup page.
getLoginPageMessage
public java.lang.String getLoginPageMessage()
- Return the message to display on the login page when
it is presented to the user. Subclasses should
override this method if a generic login message is
not sufficient.
getLoginPageTitle
public java.lang.String getLoginPageTitle()
- Return the title to display on the login page when
it is presented to the user. Subclasses should
override this method if "Startups.com Login" is
not sufficient (for example, in the Job Connection
section it might be overridden to return
"Log in to Job Connection").
checkAccess
public void checkAccess(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) throws java.io.IOException
- In order to require login for a page, in the jsp there should
be a call to this method from the model using the
implicit request and response objects:
someStateModel.checkAccess(request, response);
Add this line of code to the jsp just after the bean
declaration of someStateModel.
fontColorTagFor
public java.lang.String fontColorTagFor(java.lang.String fieldName)
- Returns a red font color tag if the given fieldName in the given
model is invalid, otherwise returns a black font color tag.
In order for this method to work properly, there
should be a validation method with the signature
public void validate() throws
ValidationFailedException
.
displayFailedValidations
public java.lang.String displayFailedValidations()
- Return a list of failed form validations in red.
The display will look something like this:
Please review the indicated fields:
...
If all validations passed, return an empty string.
activateValidationDisplay
public void activateValidationDisplay()
All Packages Class Hierarchy This Package Previous Next Index