Class SetFocusCommand

java.lang.Object
com.oorian.messaging.commands.Command
com.oorian.messaging.commands.SetFocusCommand

public class SetFocusCommand extends Command
Command to set keyboard focus on a specific DOM element.

This command programmatically sets the keyboard focus to the specified element, similar to when a user clicks on an input field or tabs to it. This is useful for improving user experience by directing attention to specific form fields or interactive elements.

Features:

  • Sets keyboard focus on any focusable element
  • Targets elements by ID
  • Improves form navigation and accessibility
  • Enables guided user workflows

Usage:


 // Set focus on a login username field
 SetFocusCommand focus = new SetFocusCommand("usernameInput");
 JsonObject json = focus.toJson();
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • SetFocusCommand

      public SetFocusCommand(String elementId)
      Constructs a new SetFocusCommand to set focus on the specified element.
      Parameters:
      elementId - the ID of the element to focus
  • Method Details

    • toJson

      public JsonObject toJson()
      Generates the JSON representation of this set focus command.

      The JSON includes the command ID and target element ID.

      Specified by:
      toJson in class Command
      Returns:
      a JsonObject containing the set focus command attributes