Class JKWebController

java.lang.Object
com.jk.web.faces.controllers.JKWebController
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
JKAccountWebController, JKSecurityWebController, JKUtilWebController, JKWebAppBaseController, JKWebMessagesController, WorkflowController

public class JKWebController extends Object implements Serializable
This class is a controller, provides common utility methods and functionalities that can be used by web controllers throughout the application.
Version:
1.0
Author:
Dr. Jalal H. Kiswani
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected JKLogger
    Represents this class logger.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected jakarta.faces.context.ExternalContext
    This method retrieves the external context associated with the current FacesContext.
    void
    error(String message)
    This method display an error message to the user.
    void
    error(String message, boolean useLabel)
    This method display an error message to the user.
    protected void
    This method executes a Runnable task asynchronously using a thread pool.
    getContextParam(String param, String defaultcValue)
    This method retrieves the value of a context parameter from the web application's configuration.
    protected String
    This method retrieves the context path of the current web application.
    This method retrieves an object from the application scope.
    This method retrieves an object from the current request scope.
    This method retrieves an object from the current session scope.
    protected String
    getParam(String paramName)
    This method retrieves the value of a request parameter by its name.
    This method retrieves a request parameter value by name.
    This method retrieves a list of roles associated with the current user session.
    This method gets the tenant identifier (ID).
    This method retrieves the user name associated with the current user session.
    <T> T
    This method retrieves a view-scoped managed bean by its controller name.
    protected void
    This method handles exceptions that may occur during the execution of controller methods.
    void
    This method initializes the web controller.
    boolean
    This method checks if the web application is running in debug mode.
    boolean
    This method checks if the web application is running in development mode.
    void
    This method logs an action or event with the specified message.
    protected void
    This method is yet to be implemented (TBI).
    void
    redirect(String outcome)
    This method redirects the current request to a specified outcome or URL.
    jakarta.servlet.http.HttpServletRequest
    This method retrieves the HttpServletRequest associated with the current FacesContext.
    jakarta.servlet.http.HttpSession
    Thie method retrieves the HttpSession associated with the current FacesContext.
    void
    This method shows message error message in primefaces dialog
    void
    This method shows message info message in primefaces dialog
    void
    This method shows message warning message in primefaces dialog
    void
    success(String message)
    This method adds a success message to the current FacesContext.
    void
    success(String message, boolean localize)
    This method adds a success message to the current FacesContext.
    protected String
    suggestName(String prefix, List<?> list)
    This method generates a suggested name by appending a unique number to the given prefix.
    void
    updateUi(String compId)
    This method updates the user interface component identified by its component ID (compId).
    void
    warning(String message)
    This method adds a warning message to the current FacesContext.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • logger

      protected JKLogger logger
      Represents this class logger.
  • Constructor Details

    • JKWebController

      public JKWebController()
  • Method Details

    • init

      @PostConstruct public void init()
      This method initializes the web controller.
    • error

      public void error(String message)
      This method display an error message to the user.
      Parameters:
      message - Specifies the error message to be displayed.
    • error

      public void error(String message, boolean useLabel)
      This method display an error message to the user.
      Parameters:
      message - Specifies the error message to be displayed.
      useLabel - Indicates whether to use a label for the message.
    • getFromAppliaction

      public Object getFromAppliaction(String name)
      This method retrieves an object from the application scope.
      Parameters:
      name - Specifies the name or key associated with the object in the application scope.
      Returns:
      the object stored in the application scope under the specified name.
    • getFromRequest

      public Object getFromRequest(String name)
      This method retrieves an object from the current request scope.
      Parameters:
      name - Specifies the name or key associated with the object in the request scope.
      Returns:
      the object stored in the request scope under the specified name.
    • getFromSession

      public Object getFromSession(String name)
      This method retrieves an object from the current session scope.
      Parameters:
      name - Specifies the name or key associated with the object in the session scope.
      Returns:
      the object stored in the session scope under the specified name.
    • getParamterFromRequest

      public String getParamterFromRequest(String name)
      This method retrieves a request parameter value by name.
      Parameters:
      name - Specifies the name of the request parameter.
      Returns:
      the value of the request parameter.
    • context

      protected jakarta.faces.context.ExternalContext context()
      This method retrieves the external context associated with the current FacesContext.
      Returns:
      the ExternalContext object for the current request.
    • request

      public jakarta.servlet.http.HttpServletRequest request()
      This method retrieves the HttpServletRequest associated with the current FacesContext.
      Returns:
      the HttpServletRequest associated with the current FacesContext.
    • session

      public jakarta.servlet.http.HttpSession session()
      Thie method retrieves the HttpSession associated with the current FacesContext.
      Returns:
      the HttpSession associated with the current FacesContext.
    • redirect

      public void redirect(String outcome)
      This method redirects the current request to a specified outcome or URL.
      Parameters:
      outcome - Specifies the URL or outcome to which the request should be redirected.
    • success

      public void success(String message)
      This method adds a success message to the current FacesContext.
      Parameters:
      message - Specifies the success message to be displayed.
    • success

      public void success(String message, boolean localize)
      This method adds a success message to the current FacesContext.
      Parameters:
      message - Specifies the success message to be displayed.
      localize - Indicates whether the message should be localized.
    • warning

      public void warning(String message)
      This method adds a warning message to the current FacesContext.
      Parameters:
      message - Specifies the warning message to be displayed.
    • handleException

      protected void handleException(Exception e)
      This method handles exceptions that may occur during the execution of controller methods.
      Parameters:
      e - Specifies the exception to be handled.
    • getParam

      protected String getParam(String paramName)
      This method retrieves the value of a request parameter by its name.
      Parameters:
      paramName - Specifies the parameter name.
      Returns:
      the value of the parameter.
    • getContextPath

      protected String getContextPath()
      This method retrieves the context path of the current web application.
      Returns:
      the context path of the current web application.
    • getContextParam

      public String getContextParam(String param, String defaultcValue)
      This method retrieves the value of a context parameter from the web application's configuration.
      Parameters:
      param - Specifies the name of the context parameter to retrieve.
      defaultcValue - Specifies the default value to return if the parameter is not found.
      Returns:
      the value of the context parameter or the default value if not found.
    • isDevelopmentMode

      public boolean isDevelopmentMode()
      This method checks if the web application is running in development mode.
      Returns:
      true, if the web application is in development mode, false otherwise.
    • isDebug

      public boolean isDebug()
      This method checks if the web application is running in debug mode.
      Returns:
      true, if the web application is in debug mode, false otherwise.
    • executeAsyc

      protected void executeAsyc(Runnable command)
      This method executes a Runnable task asynchronously using a thread pool.
      Parameters:
      command - Specifies the Runnable task to execute asynchronously.
    • logAction

      public void logAction(String log)
      This method logs an action or event with the specified message.
      Parameters:
      log - Specifies the message describing the action or event to be logged.
    • getUserName

      public String getUserName()
      This method retrieves the user name associated with the current user session.
      Returns:
      the user name of the current user.
    • getRoles

      public List<String> getRoles()
      This method retrieves a list of roles associated with the current user session.
      Returns:
      the list of role names assigned to the current user.
    • suggestName

      protected String suggestName(String prefix, List<?> list)
      This method generates a suggested name by appending a unique number to the given prefix.
      Parameters:
      prefix - Specifies the prefix to be used in the generated name.
      list - Specifies the list of items to check for uniqueness when generating the name.
      Returns:
      the suggested name that combines the prefix and a unique number.
    • updateUi

      public void updateUi(String compId)
      This method updates the user interface component identified by its component ID (compId).
      Parameters:
      compId - Specifies the component ID.
    • getViewScopedManagedBean

      public <T> T getViewScopedManagedBean(String controllerName)
      This method retrieves a view-scoped managed bean by its controller name.
      Type Parameters:
      T - Specifies the type of the managed bean.
      Parameters:
      controllerName - Specifies the name of the managed bean controller to retrieve.
      Returns:
      the instance of the managed bean.
    • getTenantId

      public String getTenantId()
      This method gets the tenant identifier (ID).
      Returns:
      the tenant identifier (ID).
    • postConstruct

      protected void postConstruct()
      This method is yet to be implemented (TBI).
    • showInfoDialogMessage

      public void showInfoDialogMessage(String msgText, String title)
      This method shows message info message in primefaces dialog
      Parameters:
      msgText - Specifies the info dialog message.
      title - Specifies the message summary.
    • showErrorDialogMessage

      public void showErrorDialogMessage(String msgText, String title)
      This method shows message error message in primefaces dialog
      Parameters:
      msgText - Specifies the error dialog message.
      title - Specifies the message summary.
    • showWarningDialogMessage

      public void showWarningDialogMessage(String msgText, String title)
      This method shows message warning message in primefaces dialog
      Parameters:
      msgText - Specifies the warning dialog message.
      title - Specifies the message summary.