Class ServerAction

java.lang.Object
javax.swing.AbstractAction
org.jdesktop.swingx.action.ServerAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action

public class ServerAction extends AbstractAction
An action which will invoke an http POST operation.
See Also:
  • Field Details

  • Constructor Details

    • ServerAction

      public ServerAction()
    • ServerAction

      public ServerAction(String name)
    • ServerAction

      public ServerAction(String name, String command)
      Parameters:
      name - display name of the action
      command - the value of the action command key
    • ServerAction

      public ServerAction(String name, Icon icon)
    • ServerAction

      public ServerAction(String name, String command, Icon icon)
      Parameters:
      name - display name of the action
      command - the value of the action command key
      icon - icon to display
  • Method Details

    • setURL

      public void setURL(String url)
      Set the url for the action.

      Parameters:
      url - a string representation of the url
    • getURL

      public String getURL()
    • getParams

      private Map<String,String> getParams()
    • setParams

      private void setParams(Map<String,String> params)
    • addParam

      public void addParam(String name, String value)
      Adds a name value pair which represents a url parameter in an http POST request.
    • getParamValue

      public String getParamValue(String name)
      Return a parameter value corresponding to name or null if it doesn't exist.
    • getParamNames

      public Set<String> getParamNames()
      Return a set of parameter names or null if there are no params
    • getHeaders

      private Map<String,String> getHeaders()
    • setHeaders

      private void setHeaders(Map<String,String> headers)
    • addHeader

      public void addHeader(String name, String value)
      Adds a name value pair which represents a url connection request property. For example, name could be "Content-Type" and the value could be "application/x-www-form-urlencoded"
    • getHeaderValue

      public String getHeaderValue(String name)
      Return a header value corresponding to name or null if it doesn't exist.
    • getHeaderNames

      public Set<String> getHeaderNames()
      Return a set of parameter names or null if there are no params
    • actionPerformed

      public void actionPerformed(ActionEvent evt)
      Invokes the server operation when the action has been invoked.
    • getPostData

      private String getPostData()
      Retrieves a string which represents the parameter data for a server action.
      Returns:
      a string of name value pairs prefixed by a '?' and delimited by an 'invalid input: '&''
    • createMessage

      private String createMessage(int code, String msg)
      Creates a human readable message from the server code and message result.
      Parameters:
      code - an http error code.
      msg - server message