Skip to main content.

JSP Controls Tag Library

Navigation: JSP Controls | About

Buttons And Links Components (Non-Ajax And Ajax Modes)

Description

JSP Controls Tag Library allows to send an event to event handler either by submitting an HTML form, or by activating a link. Link does not submit a form.

Source Code

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://jspcontrols.net/tags/core" prefix="jc" %>

<jc:component id="Showcase_ButtonsAndLinks">

  <jc:handler event="buttonEvent">
    <%
      session.setAttribute("showcase_btns_inputtext", request.getParameter("inputtext"));
      session.setAttribute("showcase_btns_activated", "Command Button");
    %>
  </jc:handler>
  <jc:handler event="linkEvent">
    <%
      session.setAttribute("showcase_btns_activated", "Command Link");
    %>
  </jc:handler>
  <jc:reload/>

  <jc:prerender/>

  <form name="textentryform" class="jspcCommand" method="get" action="${jspcComponentAddress}">
    <table>
      <tr>
        <td>Input Text:</td>
        <td><input type="text" name="inputtext"
                value="${showcase_btns_inputtext}" size="20" /></td>
	    <td>Partial submit disabled</td>
      </tr>

      <tr>
        <td></td>
        <td><input type="submit" name="buttonEvent"
                       value="Command Button" class="jspcCommand"/></td>
        <td>Command button submits a form</td>
      </tr>

      <tr>
        <td></td>
        <td><a href="${jspcComponentAddress}?linkEvent" class="jspcCommand">
          Command Link</a>
        </td>
        <td>Command link does not submit a form</td>
      </tr>

      <tr><td colspan="2">
          Input Text: ${showcase_btns_inputtext}<br/>
          Clicked: ${showcase_btns_activated}
      </td></tr>
    </table>
  </form>

</jc:component>