DirectLinkOnce

Description

Renders an DirectLink component with an onclick event handler that prevents the user from activating the link twice. The component acts together with other SubmitOnce,ImageSubmitOnce,DirectLinkOnce or LinkSubmitOnce components, which means that non of the mentioned components can be activated while another component request is processed.

See also

DirectLink

Parameters

Name Type Required Default Description
onclick java.lang.String no An optional onclick eventhandler that is to be processed prior to any activation of the link, but after the components own check to se if any other request from a SubmitOnce,ImageSubmitOnce,DirectLinkOnce or LinkSubmitOnce component is being processed.
listener IActionListener yes Specifies an object that is notified when the link is clicked, which is typically a listener method of its container (for example, listeners.method).
parameters Object or

Object[] or

java.util.List
yes

An array of objects to be encoded into the URL. These parameters will be decoded when the link is triggered.

In a web application built onto of Enterprise JavaBeans, the context is often the primary key of some Entity bean; typically such keys are Strings or Integers.

A listener method can retrieve the parameters three ways:

parameters are declared in the method itself, e.g. - listenerMethod( parameters)

parameters are declared along with the IRequestCycle, e.g. - listenerMethod(IRequestCycle cycle, parameters)

or through the request cycle, e.g. - listenerMethod(IReuqestCycle cycle), using IRequestCycle.getServiceParameters()

Prior to release 2.2, the parameters were always type String. They may now be of any type; type will be maintained when the parameters are later retrieved by a listener. See SqueezeAdaptor for more details.

disabled boolean no false Controls whether the link is produced. If disabled, the portion of the template the link surrounds is still rendered, but not the link itself.
stateful boolean no true If true (the default), then the component requires an active (i.e., non-new) HttpSession when triggered. Failing that, it throws a StaleLinkException. If false, then no check is necessary. The latter works well with links that encode all necessary state inside the URL itself.
anchor java.lang.String no The name of an anchor or element to link to. The final URL will have '#' and the anchor appended to it.
port java.lang.Integer no The required port (80, 443, 8080. 8443, typically) for the URL. This will force the creation of an absolute URL when the current request's scheme does not match the value for this parameter. This is most often used in conjunction with scheme to switch to "https:443"/"https:8443" for secure portions of an application (such as a login page), before switching back to standard "http:80"/"http:80" for the majority of an application.

Further info

  • Body: Allowed
  • Informal parameters: Allowed
  • Reserved parameters: href, name

Requirements

This component extends the DirectLink component of Tapestry.

Example

Presuming you have defined bayeux library in you application under the library name "bayeux":

Insert an DirectLink that executes a userdefined onclick event, and prevents more than one click from the user: "..."

<a jwcid="@bayeux:DirectLinkOnce" href="#" onclick="return myOwnClientValidation()" listener="listener:myListener">my direct link<a>
                
<script type="javascript">
  function myOwnClientValidation() {
    //some client validation to be done here
    return true;
  }
</script>
                

public class APage extends BasePage {
    public void myListener(IRequestCycle cycle) {
        System.out.println("my directlink is activated");
    }
}