Class NmCommandBean

java.lang.Object
com.ptc.netmarkets.util.beans.NmCommandBean
All Implemented Interfaces:
FormDataHolder, Externalizable, Serializable, Cloneable

public class NmCommandBean extends Object implements FormDataHolder, Externalizable, Cloneable
A new NmCommandBean is created for each request and put into request scope for reuse across the lifetime of the request. The bean has helper APIs to access all the form data for the current request. Query parameters, form data values (from hidden input fields, text inputs, text areas, checkboxs, radio buttons etc.) If the form fields were rendered by a GuiComponent, the command bean will also have info on whether the value was changed and what the old value was. There are also helper APIs to get the current context object for the page/action.


Keeps track of whether there is a dynamic refresh of a table/tree for the current request. And holds the oid information of what is getting dynamically refreshed. This dynamic refresh information is set up automatically if your FormProcessor sets up DyanmicRefreshInfo(s) on a FormResult. If needed APIs such as setDynamic(ArrayList, NmOid, NmOid, String) could be called directly from a command class, but the best practice is to set up a FormResult with DynamicRefreshInfo objects.

Used to get query parameters or values from hidden input fields. Example set of APIs to get the values of combo boxes (each kind of input component has a set of APIs like this):
Helper APIs that can be used to get the current context object(s) for the page/action.

Supported API: true

Extendable: true
See Also:
  • Method Details

    • getSelected

      public ArrayList getSelected()
      Gets the value of the attribute: selected; gets the selected objects from the table in the Form Processor or NmCommand class for a NORMAL action. Gets the current selected items in the window.

      Supported API: true
      Returns:
      ArrayList
    • getComboBox

      public HashMap getComboBox()
      Gets the value of the attribute: comboBox; The comboboxes that are posted on this request object

      Supported API: true
      Specified by:
      getComboBox in interface FormDataHolder
      Returns:
      HashMap
    • getPrimaryOid

      public NmOid getPrimaryOid() throws WTException
      Gets the main context object. Usually the oid on the url from which the page was launched. last resort for knowing what the page should display info for. Use getActionOid(), getActionOidsWithWizard(), getActionOidsWithOutWizard() for determing the target of actions. Use getPageOid() for determing the object to use incase it jsp over-rode the context object on an include.

      Supported API: true
      Returns:
      NmOid
      Throws:
      WTException
    • getPageOid

      public NmOid getPageOid() throws WTException
      Gets the over-ridden context object. Same as primaryOid when no jsp include has occurred. Use getActionOid(), getActionOidsWithWizard(), getActionOidsWithOutWizard() for determining the target of actions. Use getPageOid() for determining the object to use in-case it jsp over-rode the context object on an include.

      Supported API: true
      Returns:
      NmOid
      Throws:
      WTException
    • getElementOid

      public NmOid getElementOid() throws WTException
      Gets the row context object. Use getActionOid(), getActionOidsWithWizard(), getActionOidsWithOutWizard() for determining the target of actions.

      Supported API: true
      Returns:
      NmOid
      Throws:
      WTException
    • getNewChecked

      public HashMap getNewChecked() throws WTException
      Returns a hashMap of Name of Checkbox -> Optional Column Name so that if one was to make a table of principals to Access control, the name would be the user, and the optional column name would be the access control.

      Supported API: true
      Specified by:
      getNewChecked in interface FormDataHolder
      Returns:
      HashMap
      Throws:
      WTException
    • getUnChecked

      public HashMap getUnChecked() throws WTException
      Returns a hashMap of all the un-checked checkboxes on the page. Only returns values that were originally rendered with checkbox gui-components. Name of Checkbox -> Optional Column Name so that if one was to make a table of principals to Access control, the name would be the user, and the optional column name would be the access control.

      Supported API: true
      Specified by:
      getUnChecked in interface FormDataHolder
      Returns:
      HashMap
      Throws:
      WTException
    • getChangedRadio

      public HashMap getChangedRadio() throws WTException
      Returns a hashMap of any radio buttons that have changed. Radio buttons needed to have been rendered by gui-comopnents. key,values of the hashmap are Name of radio -> Optional Column Name so that if one was to make a table of principals to Access control, the name would be the user, and the optional column name would be the access control.

      Supported API: true
      Specified by:
      getChangedRadio in interface FormDataHolder
      Returns:
      HashMap
      Throws:
      WTException
    • getChangedText

      public HashMap getChangedText() throws WTException
      Gets the textboxes that have changed. Name -> new value

      Supported API: true
      Specified by:
      getChangedText in interface FormDataHolder
      Returns:
      HashMap
      Throws:
      WTException
    • getChangedTextArea

      public HashMap getChangedTextArea() throws WTException
      Gets the textareas that have changed. Name -> new value

      Supported API: true
      Specified by:
      getChangedTextArea in interface FormDataHolder
      Returns:
      HashMap
      Throws:
      WTException
    • getChangedComboBox

      public HashMap getChangedComboBox() throws WTException
      Gets the comboboxes that have changed. Name -> new value

      Supported API: true
      Specified by:
      getChangedComboBox in interface FormDataHolder
      Returns:
      HashMap
      Throws:
      WTException
    • getSelectedOidForPopup

      public ArrayList getSelectedOidForPopup() throws WTException
      gets the selected objects from the table in the popup window jsp or table code if the UI needs to display something about the selected objects that were selected when the action was click to launch the window. To be used during rendering (not meant for form processors which should use getActionOid, getActionOidsWithWizard, getActionOidsWithoutWizard)

      Supported API: true
      Returns:
      ArrayList
      Throws:
      WTException
    • getAddedItemsByName

      public List<NmOid> getAddedItemsByName(String param_name)
      Will return the list of NmOids which were selected for addition from the component defined by the component name param_name.
      Specified by:
      getAddedItemsByName in interface FormDataHolder
      Parameters:
      param_name - The name of the component which the items were added to. (for example: table ID)
      Returns:
      a list of oids that are added from the component.

      Supported API: true
    • getRemovedItemsByName

      public List<NmOid> getRemovedItemsByName(String param_name)
      Will return the list of NmOids which were selected for removal from the component defined by the component name param_name.


      Supported API: true
      Specified by:
      getRemovedItemsByName in interface FormDataHolder
      Parameters:
      param_name - The name of the component which the items were removed from. (for example: table ID)
      Returns:
      a list of oids that are removed from the component.
    • getTextParameter

      public String getTextParameter(String key)
      Gets a HTTP request parameter value in UTF8 format. Works in both Servlet engine and Method Server code. Use this instead of getRequest().getParameter()

      Available in the servlet container and in the Method Server

      Supported API: true
      Specified by:
      getTextParameter in interface FormDataHolder
      Parameters:
      key -
      Returns:
      String
    • getTextParameterValues

      public String[] getTextParameterValues(String key)
      Gets all the HTTP request parameter values for the given key in UTF8 format.

      Available in the servlet container and in the Method Server

      Supported API: true
      Specified by:
      getTextParameterValues in interface FormDataHolder
      Parameters:
      key -
      Returns:
      String[]
    • setRequest

      public void setRequest(Object a_Request) throws WTException
      Initializes the commandbean with all the request params. Each request param is iterated over to set JCA state. Sets the value of the attribute: request;

      Supported API: true
      Parameters:
      a_Request -
      Throws:
      WTException
    • getResponse

      public jakarta.servlet.http.HttpServletResponse getResponse()
      Gets the value of the attribute: response; available in the jsp engine only

      Supported API: true
      Returns:
      HttpServletResponse
    • setResponse

      public void setResponse(Object a_Response) throws WTException
      Sets the value of the attribute: response; available in the jsp engine only

      Supported API: true
      Parameters:
      a_Response -
      Throws:
      WTException
    • getOut

      public jakarta.servlet.jsp.JspWriter getOut()
      Gets the value of the attribute: out; available in the jsp engine only This is the jsp out variable

      Supported API: true
      Returns:
      JspWriter
    • setOut

      public void setOut(Object a_Out) throws WTException
      Sets the value of the attribute: out; available in the jsp engine only

      Supported API: true
      Parameters:
      a_Out -
      Throws:
      WTException
    • getRequestAttribute

      public Object getRequestAttribute(String key)
      returns the attribute value
      Supported API: true
      Parameters:
      key - : name of the attribute
      Returns:
      value of the attribute
    • convertRequestParam

      public String convertRequestParam(String text)
      Converts a string from ISO-8859 to UTF-8 if needed. The isConvertParams global variable will be used to determine if conversion is necessary. Does not escpe any HTML in the given text and so is appropriate to use on rich text parameters.

      Supported API: true
    • convertRequestParamNoEscaping

      @Deprecated public String convertRequestParamNoEscaping(String text)
      Deprecated.
      Converts a string from ISO-8859 to UTF-8 if needed. The isConvertParams global variable will be used to determine if conversion is necessary. Does not escape any HTML in the given text and so is appropriate to use on rich text parameters.

      Supported API: true
    • convertMain

      public static String convertMain(String name)
      Converts a 8859 string into utf8

      Supported API: true
    • getSelectedContextsForPopup

      public ArrayList getSelectedContextsForPopup() throws WTException
      Same as getSelectedOidForPopup but it does not auto-convert the NmContext -> NmOid if developer needs that extra info. *

      Supported API: true
      Throws:
      WTException
    • getContextFromString

      public static Object getContextFromString(String nmoidstr, Object req) throws WTException
      Will return the target oid of the string if the string is a NmOid string, NmCOntext string, or Object Ref string.

      Supported API: true
      Throws:
      WTException
    • getOidFromObject

      public static NmOid getOidFromObject(Object nextObj) throws WTException
      Will return the target oid of the object if the object is a NmOid string, NmCOntext string, or a String.

      Supported API: true
      Throws:
      WTException
    • getViewingContainer

      public WTContainer getViewingContainer() throws WTException
      Returns the container that the user is launching the action from. When actions are launched from a object that is shared, this method will return the shared container instead of the object's true container
      If the user doesn't have access to the container, returns null. Also refer getViewingContainerObject()

      Supported API: true
      Throws:
      WTException
    • getViewingContainerObject

      public WTContainer getViewingContainerObject() throws WTException
      Returns the container that the user is launching the action from. When actions are launched from a object that is shared, this method will return the shared container instead of the object's true container
      If the user doesn't have access to the container, throws exception. Also refer getViewingContainer()

      Supported API: true
      Throws:
      WTException
    • getActionOid

      public NmOid getActionOid() throws WTException
      Gets the object that is the target of the action. This could be the elementOid for a row based action or the primarOid for actions invoked on the details page It will not look at selected objects for toolbar actions. Please use for toolbar actions: getActionOidsWithWizard, getActionOidsWithOutWizard **

      Supported API: true
      Throws:
      WTException
    • setParameter

      public void setParameter(String name, String value, String[] values) throws WTException
      Initialize the commandBean with a specific parameter.
      Supported API: true
      Parameters:
      name - - the name of the request parameter
      value - - the value to set
      values - - array of values, if null, will be defaulted to be new String {value} **
      Throws:
      WTException
    • initializeServerRequestData

      public void initializeServerRequestData()
      Initialize the commandbean so that request data is available in the Method Server The request object must have been set prior to this call Will not reset if called multiple times **

      Supported API: true
    • getActionOidsWithWizard

      public ArrayList<NmOid> getActionOidsWithWizard() throws WTException
      Gets the actions oids of a action that had a wizard. Use this method to find which objects the action should act upon. When its in a toolbar, this will return all the selected objects when the action was launched. When launched from other locations it will return the actionOid **

      Supported API: true
      Throws:
      WTException
    • getActionOidsWithoutWizard

      public ArrayList<NmOid> getActionOidsWithoutWizard() throws WTException
      Gets the actions oids of a action that does not have a wizard. Use this method to find which objects the action should act upon. When its in a toolbar, this will return all the selected objects when the action was launched. When launched from other locations it will return the actionOid **

      Supported API: true
      Throws:
      WTException
    • getNmOidSelected

      public ArrayList<NmOid> getNmOidSelected() throws WTException
      Get the selected objects as oids. getSelected() method will return NmContexts which provides more info but requires calling code to cast and and call getTargetOid() **

      Supported API: true
      Throws:
      WTException
    • getNmOidSelectedInOpener

      public ArrayList<NmOid> getNmOidSelectedInOpener() throws WTException
      Get the selected-in-opener objects as oids. getSelectedInOpener() method will return NmContexts which provides more info but requires calling code to cast and and call getTargetOid() **

      Supported API: true
      Throws:
      WTException
    • getInitialItemsByName

      public List<NmOid> getInitialItemsByName(String param_name)
      Returns the list of initial NmOids for objects which are associated to the component with the name param_name.


      Supported API: true
      Specified by:
      getInitialItemsByName in interface FormDataHolder
      Parameters:
      param_name - The name of the component with the initial items (for example: table ID)
      Returns:
      a list of initial oids that are from the component.
      See Also: