Hitachi

JP1 Version 12 JP1/Navigation Platform Development Guide


5.5.1 decodeHtmlPartParam method

This method receives encoded character strings input from an HTML Part as arguments, and then converts them to the Map format.

Organization of this subsection

(1) Format

public static Map<String, String> decodeHtmlPartParam(String param)
              throws UCNPPluginException;

(2) Arguments

(a) param

This argument stores the encoded character strings input from the HTML Part.

(3) Return values

Map<String, String>

The value corresponding to an input item in the HTML Part is returned in a Map. The Map contains the name attribute as the key and the value attribute as the value. If the param argument is an empty character string, an empty Map is returned. You can acquire the value from the returned Map by using the name attribute of the element specified in the HTML Part as the key.

(4) Exception

UCNPPluginException - Conversion of an encoded character string fails.

If an error occurs with this method, conversion to the Map format is interrupted and the UCNPPluginException exception is thrown. The following shows a list of errors.

Table 5‒10: List of errors that occur in the decodeHtmlPartParam method

Error

Message ID

This method is executed for data other than an HTML Part.

KDCZ10205-E

(5) Example

The following describes an example of using the decodeHtmlPartParam method within the inputFromNode method of the IIoPluginController interface.

Conditions

This example is based on the following conditions:

I/O Plugin implementation example

The following shows an example of implementation to receive and process the input parameter from the HTML Part indicated in the conditions. The decodeHtmlPartParam method is used in the part in bold.

package jp.co.hitachi.soft.ucnp.plugin.sample.ioaction.controller;
 
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpSession;
import jp.co.hitachi.soft.ucnp.plugin.inputoutput.controller.IIoPluginController;
import jp.co.hitachi.soft.ucnp.plugin.inputoutput.common.UCNPPluginException;
import jp.co.hitachi.soft.ucnp.plugin.inputoutput.util.ParamConvertUtil;
 
public class IoPluginController implements IIoPluginController {
    /* The member variable that retains the input parameter values received from the client */
    private String param1 = null;
    private String param2 = null;
    private String param3 = null;
 
    public Map<String, Object> inputFromNode(HttpSession session,
            Map<String, Object> param) {
 
        /* Create a Map used for sending processing results to the client. */
        Map<String, Object> map = new HashMap<String, Object>();
 
        /* Processing changes depending on the button type.*/
        String buttonType = (String) param.get("ucnp.button.type");
        if ("show_next_page".equals(buttonType)) {
            /* If the Next button is clicked, input values are obtained and then retained in the member variables. */
 
            /* Expand the data received from the client to the Map. */
            Map<?, ?> inParamMap = (Map<?, ?>) param.get("ucnp.current.params.map");
 
           /* Obtain the value to be converted from the Map. */
           String inParam1 = (String) inParamMap.get("inputItemName1");
 
            Map<String, String> decodedMap = null;
            /* Enclose the API to be used in the try-catch block.*/
            try {
                decodedMap = ParamConvertUtil.decodeHtmlPartParam(inParam1);
 
            } catch (UCNPPluginException e) {
                /* Perform exception processing. */
                String errMsg = e.getMessage();
                /* Perform processing such as outputting plugin log data. */
                /* Return the map with an error message added.*/
                map.put("ucnp.error.message", errMsg);
                return map;
            }
            /* Obtain the value of the value attribute corresponding to the name attribute "order".*/
            String value = decodedMap.get("order");
 
            /* Set the input parameter values in the member variables. */
            param1 = value;
            param2 = (String) inParamMap.get("inputItemName2");
            param3 = (String) inParamMap.get("inputItemName3");
 
        } else if ("show_previous_page".equals(buttonType)) {
            /* If the Back button is clicked, nothing is performed. */
        }
 
        return map;
    }
 
    public Map<String, Object> outputToNode(HttpSession session, 
            Map<String, Object> param) {
 
        /* Create a Map to be sent to the client. */
        Map<String, Object> map = new HashMap<String, Object>();
 
        /* Processing changes depending on the button type.*/
        String buttonType = (String) param.get("ucnp.button.type");
        if ("show_next_page".equals(buttonType)) {
            /* If the Next button is clicked, input values are mapped to the output items.  */
 
            Map<String, String> outParamMap = new HashMap<String, String>();
 
            /* Set data to be sent to the Map. */
            /* Because the static text parts are set for outputItemName1,
               the values obtained from the HTML Part are set as the values of the static text parts. */
            outParamMap.put("outputItemName1", param1);
            outParamMap.put("outputItemName2", param2);
            outParamMap.put("outputItemName3", param3);
 
            map.put("ucnp.next.params.map", outParamMap);
 
        } else if ("show_previous_page".equals(buttonType)) {
            /* If the Back button is clicked, nothing is performed. */
        }
 
        return map;
    }
 
}