Class JKUtilWebController

java.lang.Object
com.jk.web.faces.controllers.JKWebController
com.jk.web.faces.controllers.JKUtilWebController
All Implemented Interfaces:
Serializable

@Named("util") @Eager @ApplicationScoped public class JKUtilWebController extends JKWebController
This class is a controller, providing utility methods and properties for web applications.
Version:
1.0
Author:
Dr. Jalal H. Kiswani
See Also:
  • Constructor Details

    • JKUtilWebController

      public JKUtilWebController()
      This method constructs a new JKUtilWebController.
  • Method Details

    • random

      public String random()
      This method generates a random number as a string.
      Returns:
      a random number as a string.
    • reloadRandom

      public String reloadRandom()
      This method reloads the random value.

      If in debug mode, generates a new random number; otherwise, returns the live random value.

      Returns:
      the random value.
    • currentYear

      public int currentYear()
      This method retrieves the current year.
      Returns:
      the current year.
    • getPath

      public String getPath()
      This method gets the path from the request URI.
      Returns:
      the path.
    • exists

      public boolean exists(String fileName)
      This method checks if a file with the given filename exists.
      Parameters:
      fileName - Specifies the name of the file.
      Returns:
      true, if the file exists, false otherwise.
    • isMobile

      public boolean isMobile()
      This method checks if the user agent indicates a mobile device.
      Returns:
      true, if the user agent indicates a mobile device, false otherwise.
    • main

      public static void main(String[] args)
      This main method is used for testing purposes.
      Parameters:
      args - the command-line arguments.
    • list

      public List<Integer> list(int size)
      This method generates a list of integers from 0 to (size-1).
      Parameters:
      size - Specifies the size of the list.
      Returns:
      the list of integers.
    • toString

      public String toString(Object o)
      This method converts an object to its string representation. If the object is null, returns "-".
      Parameters:
      o - Specifies the object to convert.
      Returns:
      the string representation of the object.
    • getTheme

      public String getTheme()
      This method gets the current theme selected for the web application.
      Returns:
      the current theme.
    • getThemes

      public String[] getThemes()
      This method gets the list of available themes.
      Returns:
      an array of theme names.
    • setTheme

      public void setTheme(String theme)
      This method sets the current theme for the web application.
      Parameters:
      theme - Specifies the new theme for the web application.