A"
Line 63: | Line 63: | ||
=File download link problem= | =File download link problem= | ||
+ | Clicking a file download link below on a ZK page can cause the client engine to terminate while the page is still open. You will find ZK doesn't send AJAX requests anymore to the server. | ||
<syntaxhighlight lang='xml> | <syntaxhighlight lang='xml> | ||
Line 68: | Line 69: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
There are several alternatives to provide file download: | There are several alternatives to provide file download: |
Revision as of 07:42, 5 November 2021
A
Employment/Purpose
The same as HTML A tag.
Properties
Autodisable
A.setAutodisable(String) is used to disable an anchor automatically, when it is clicked. It is useful to prevent the user from clicking it twice (and firing redundant requests), which is common if the request takes long to serve.
The simplest use is to specify it with self as follows. Then, the anchor is disabled when it is clicked.
<a id="ok" label="OK" autodisable="self" />
If you'd like to disable several anchors, you could specify all of them in this property by separating with a comma. For example, the following disables both anchors, when one of them is clicked.
<a id="ok" label="OK" autodisable="ok,cancel" />
<a id="cancel" label="Cancel" autodisable="ok,cancel" />
The anchor will be enabled automatically, after the request has been served (i.e., the response has been sent back to the client). If you prefer to enable them manually (i.e., by calling A.setDisabled(boolean) explicitly), you could prefix the ID with a plus (+). For example,
<a id="ok" label="OK" autodisable="+self, +cancel" />
Then, you could enable them manually under the situation depending on your application's requirement, such as
if (something_happens) {
ok.setDisabled(false);
cancel.setDisabled(false);
}
Enable Autodisable for All Anchors
As described in ZK Developer's Reference: Customization, you could customize ZK to enable autodisable for all anchors by specifying the following in the custom language addon:
<language-addon>
<language-name>xul/html</language-name>
<component>
<component-name>a</component-name>
<extends>a</extends>
<property>
<property-name>autodisable</property-name>
<property-value>self</property-value>
</property>
</component>
</language-addon>
File download link problem
Clicking a file download link below on a ZK page can cause the client engine to terminate while the page is still open. You will find ZK doesn't send AJAX requests anymore to the server.
<a href="report.pdf" target='_self'>download</a>
There are several alternatives to provide file download:
open a new tab
specify _blank
and your browser will produce a new tab.
<a href="report.pdf" target='_blank'>download</a>
download attribute
A browser will prompt the user to save the linked URL instead of navigating to it. <zk xmlns:c="client/attribute"> <a href="report.xls" c:download="" target='_self'>download</a> </zk>
Please refer to download attribute
Filedownload API
Example
<a href="http://www.zkoss.org" label="Visit ZK!"/>
In addition, you could add child components to A too:
<a href="http://www.zkoss.org" label="Visit ZK!" image="zk.png">
<grid>
<rows>
<row>What ever content</row>
</rows>
</grid>
</a>
Notice that a child component might also handle the mouse click, so the final result of clicking on a child component is really up to which child component is used.
The href attribute can be an URI. For example,
<a href="/foo" label="Foo" />
<a href="goo" label="Goo" />
If the URI starts with "/", ZK will encode it with the application's context path. Otherwise the path is relative to the path given by Desktop.getDirectory().
Supported Events
None | None |
- Inherited Supported Events: LabelImageElement
Supported Children
*ALL
Use Cases
Version | Description | Example Location |
---|---|---|
Version History
Version | Date | Content |
---|---|---|
5.0.5 | October, 2010 | A supports any children. |
7.0.2 | May, 2014 | Support autodisable property for A component |