Class JavaScriptBuilder

java.lang.Object
com.jbstrap.core.JavaScriptBuilder

public final class JavaScriptBuilder extends Object
Since:
4.0
Author:
JBStrap
  • Method Details

    • showNotification

      public static String showNotification(NotificationType notificationType, String title, String message)
      Parameters:
      notificationType - The notification type. See the NotificationType enum for applicable values.
      title - The notification title (header text)
      message - The notification message
      Returns:
      The JavaScript necessary to display the notification
      Throws:
      NullPointerException - If the notification type is null
    • changeContent

      public static String changeContent(String containerId, String newHtmlContent)
      Parameters:
      containerId - The component ID, of the component that will have it's content changed.
      newHtmlContent - The new HTML content
      Returns:
      The JavaScript that changes the content
    • registerEvent

      public static String registerEvent(Component<?> component, EventType eventType)
      Parameters:
      component - The component that will have the event registered to.
      eventType - The event type
      Returns:
      The JavaScript responsible event registration
      Throws:
      NullPointerException - If the specified component or event type is null
    • say

      public static String say(String title, String message, String language)
      Parameters:
      title - The message title (header text)
      message - The message text
      language - The language code, determining the button text
      Returns:
      The JavaScript responsible for displaying the message
    • error

      public static String error(String title, String message, String language)
      Parameters:
      title - The message title (header text)
      message - The message text
      language - The language code, determining the button text
      Returns:
      The JavaScript responsible for displaying the message
    • ask

      public static String ask(String title, String text, String language, String messageId)
      Parameters:
      title - The message title (header text)
      text - The message text
      language - The language code, determining the button text
      messageId - The id of the message, that will have the answer from the client.
      Returns:
      The generated JavaScript, that displays the question and sends the answer.
    • input

      public static String input(String title, String text, String language, String messageId)
      Parameters:
      title - The message title (header text)
      text - The message text
      language - The language code, determining the button text
      messageId - The id of the message, that will have the answer from the client.
      Returns:
      The generated JavaScript, that displays the window, the input field, and sends the inputted text
    • setCookie

      public static String setCookie(String name, String value, int expSec)
      Parameters:
      name - The cookie name
      value - The cookie value
      expSec - The cookie expiration, in seconds
      Returns:
      The JavaScript, that sets the cookie
      Throws:
      NullPointerException - If the specified cookie name is null
    • deleteCookie

      public static String deleteCookie(String name)
      Parameters:
      name - The cookie name
      Returns:
      The JavaScript that deletes the cookie.
    • getCookie

      public static String getCookie(String name)
      Parameters:
      name - The cookie name
      Returns:
      The cookie value or empty string, if the cookie doesn't exist in the user's browser
      Throws:
      NullPointerException - If the cookie name was specified as null
    • setTitle

      public static String setTitle(String title)
      Parameters:
      title - The address bar text
      Returns:
      The JavaScript that sets the address bar text
    • setURL

      public static String setURL(String baseURL, String url)
      Parameters:
      baseURL - The application's base URL
      url - The page URL, that will be added to the base URL
      Returns:
      The JavaScript that sets the URL
      Throws:
      NullPointerException - If the base url is specified as null
    • includeStylesheet

      public static String includeStylesheet(String stylesheetUrl)
      Parameters:
      stylesheetUrl - The style sheet's relative URL
      Returns:
      The JavaScript that adds the stlye sheet
      Throws:
      NullPointerException - If the stylesheet URL is null
    • changeApplicationIcon

      public static String changeApplicationIcon(String iconFile)
      Parameters:
      iconFile - The icon's relative URL
      Returns:
      The JavaScript that changes the application icon
      Throws:
      NullPointerException - IF the Icon URL is null