How Do I: Pass Request-Time Data to a methodParameter?

To pass request-time data in a JSP page to a <netui-data:methodParameter> tag's value, you can use JSP scriptlet and the pageContext, as shown in the following example.

In this code snipet, we define a String handle s for a JSP variable (name) that was set earlier on the page. Next we set its value by using the pageContext.setAttribute, assigning the value to the productName that we use in a JCX control.

     .
     .
     .
     <%
        String s = "name";
        pageContext.setAttribute("productName", s);
     %>
     <netui-data:callControl controlId="productsDBControl" method="insertProduct">      
        <netui-data:methodParameter value="{pageContext.productName}"/>      
     </netui-data:callControl> 
     .
     .
     .

Note how in this example, we used the <netui-data:callControl> tag to specify the control's insertProduct method. Within the <netui-data:callControl> tag set, we used <netui-data:methodParameter> to pass in the productName instance value that was just set by the JSP pageContext.

The productsDBControl JCX file could contain an insertProduct method similar to the one shown here:

    /**
     * @jc:sql statement::
     * insert into product (productid, productName, price, image, instock) 
     * values ({productId}, {productName}, {price}, {image}, {instock})
     * ::
     */
     public int insertProduct(int productId, String productName, double price, String image, boolean instock);

Related Topics

Designing User Interfaces in JSPs

Using Data Binding in Page Flows

Presenting Complex Data Sets in JSPs

<netui-data:methodParameter> Tag

<netui-data:callControl> Tag