Tag: url
The
wcf:url tag builds a URL
and applies the appropriate WebSphere Commerce supported rewriting
rules.The
wcf:url tag contains the following
additions in comparison to the c:url tag:- The
wcf:urltag builds SEO-compliant URLs if SEO is enabled for WebSphere Commerce. - The tag adds a prefix to the URL with the appropriate protocol, HTTP or HTTPS, depending on the Struts configuration files.
- By default, the tag builds a full path URL, rather than a relative path.Note: To enable the URL to build a relative path instead, add the following line to the instance.xml file, as a direct child to the
<config>node:<UrlTagConfiguration useRelativePath="true" /> <SEOConfiguration defaultUrl="" dynamicURL="true" enable="true" constructUrlWithoutHost = "true"/>
| Tag information | |
|---|---|
| Body Content | empty |
Attributes
| Attribute | Required | Request-time | Type | Description |
|---|---|---|---|---|
var |
false |
true |
java.lang.String |
The name of the exported scoped variable for the processed URL. |
value |
true
|
true |
java.lang.String |
The URL to process or the mapped name that is used in the SEOUrlMapper.xml file. |
patternName |
false |
true |
java.lang.String |
The pattern name that is defined within the pattern template files. This pattern is used to construct the SEO URL. The value can be equal to the name attribute of the patterns that are defined for the store. |
context |
false |
true |
java.lang.String |
The name of the context when you specify a relative URL resource that belongs to a foreign context. |
scope |
false |
true |
java.lang.String |
The scope for the variable that is specified
by var. |
type |
false |
true |
java.lang.String |
Specifies whether the current URL is used
in an Ajax call. Valid type values are Ajax or Base.
The default value is Base. If the type value is Ajax,
the scheme for the URL is taken from the current request, rather than
from the Struts configuration file. |
Note: Either the
value or patternName attribute is required. If
workspaces are used, both the value and patternName are required.
If the value attribute and the patternName attribute is provided
and SEO is enabled in the wc-server.xml file as shown in the following example,
then the URLs are constructed by using the pattern template definitions. Preference is given to the
patternName attribute over the value attribute when both
attributes are specified.
<SEOConfiguration enable="true" dynamicUrl="true" defaultUrl="www.aurora.com">
<context-root-rewrite value="/shop"/>
<mapper-class-name value="com.ibm.commerce.seo.url.helpers.SEOURLMapperImpl"/>
</SEOConfiguration>If
URL construction by using the patternName attribute fails (as a result of an
invalid patternName or a missing parameter), dynamic URLs are constructed when the
dynamicUrl attribute is set to true. If the
dynamicUrl attribute is set to false, then
wcf:url tag returns the defaultUrl value that is specified in the
wc-server.xml file.The URL creation order is:
- If SEO is enabled and the
patternNameattribute is specified, thepatternNameattribute constructs a new SEO URL.- If a new SEO URL construction fails and dynamicUrl = true, a dynamic URL is constructed.
- If dynamicUrl = false, a defaultUrl is constructed
- Otherwise, the
valueattribute is used and an older style SEO URL is constructed.
Variables
No variables are defined for the wcf:url tag.
Example
The following example forms a URL
to display the shopping cart by using the wcf:url tag.
It specifies the URL type as an Ajax call.
<wcf:url var="currentShoppingCartLink" value="ShopCartPageView" type="Ajax">
<wcf:param name="storeId" value="${WCParam.storeId}" />
<wcf:param name="catalogId" value="${WCParam.catalogId}" />
<wcf:param name="langId" value="${WCParam.langId}" />
</wcf:url>