URL configuration
in the Discover Electronics reference application is located in the Assembler
context file,
WEB-INF\assembler-context.xml. Configuration is
divided between the
navigationStateBuilder and the
NavigationCartridgeHandler.
The configuration for the
navigationStateBuilder specifies a
urlFormatter to use when serializing a
NavigationState:
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Navigation state (including record state) and related config
-->
<bean id="navigationStateBuilder" scope="request"
class="com.endeca.infront.navigation.url.UrlNavigationStateBuilder">
<property name="urlFormatter" ref="seoUrlFormatter" />
<property name="mdexRequestBroker" ref="mdexRequestBroker"/>
<property name="defaultSearchKey" value="All" />
<property name="defaultMatchMode" value="ALLPARTIAL" />
<property name="defaultFilterState" ref="defaultFilterState"/>
<!-- Filter state properties removed from this example -->
</property>
Note
The
seoUrlFormatter bean is defined in the imported
endeca-seo-url-config file.
The configuration for the
navigationStateBuilder also lets you specify the URL
parameters to remove from the request URL when serializing a
NavigationState or
RecordState:
<property name="removeAlways">
<list>
<value>contentText</value>
<value>Nty</value>
<value>Dy</value>
<value>collection</value>
</list>
</property>
<property name="removeOnUpdateFilterState">
<list>
<value>No</value>
</list>
</property>
<property name="removeOnClearFilterState">
<list>
<value>Ns</value>
<value>Nrpp</value>
<value>more</value>
</list>
</property>
</bean>
The content paths that prefix navigation and record states when
creating Action URLs are configured in the
actionPathProvider of the
NavigationCartridgeHandler as sets of key-value pairs:
<bean id="NavigationCartridgeHandler" abstract="true">
<property name="navigationState" ref="navigationState" />
<property name="mdexRequestBroker" ref="mdexRequestBroker" />
<property name="actionPathProvider" ref="actionPathProvider"/>
<property name="siteState" ref="siteState"/>
<property name="userState" ref="${user.state.ref}"/>
<bean id="actionPathProvider" scope="request" class="com.endeca.infront.refapp.navigation.BasicActionPathProvider">
<constructor-arg index="0" ref="contentSource"/>
<constructor-arg index="1" ref="httpServletRequest"/>
<!-- navigationActionUriMap -->
<constructor-arg index="2">
<map>
<entry key="^/pages/[^/]*/mobile/detail$"value="/mobile/browse"/>
<entry key="^/pages/[^/]*/services/recorddetails/.*$"value="/services/guidedsearch"/>
<entry key="^/pages/[^/]*/detail$"value="/browse"/>
<entry key="^/services/.*$"value="/services/guidedsearch"/>
</map>
</constructor-arg>
<!-- recordActionUriMap -->
<constructor-arg index="3">
<map>
<entry key="^/pages/[^/]*/mobile/.*$"value="/mobile/detail"/>
<entry key="^/pages/[^/]*/services/.*$"value="/services/recorddetails"/>
<entry key="^/pages/[^/]*/.*$"value="/detail"/>
<entry key="^/services/.*$"value="/recorddetails"/>
</map>
</constructor-arg>
<constructor-arg index="4" ref="siteState"/>
</bean>
The Discover Electronics reference application serializes
NavigationState objects through the use of a
UrlNavigationStateBuilder configured with a
UrlFormatter. By default, the application is configured
for search engine optimized (SEO) URLs using the
SeoUrlFormatter class, but it also includes a
BasicUrlFormatter for creating basic URLs.
The following properties can be set on the
basicUrlFormatter bean:
|
Property |
Description |
|---|---|
|
|
Specifies the default query encoding, for
example,
|
|
|
Specifies whether a question mark is prepended to the URL parameter portion of the URL, after the servlet path. |
The configuration in
WEB-INF\endeca-url-config is shown below:
<!--
########################################################################
# BEAN: basicUrlFormatter
#
# This is an UrlFormatter that generates "classic" URLs.
#
-->
<bean id="basicUrlFormatter" class="com.endeca.soleng.urlformatter.basic.BasicUrlFormatter">
<property name="defaultEncoding">
<value>UTF-8</value>
</property>
<property name="prependQuestionMark">
<value>true</value>
</property>
</bean>
The following properties can be set on the
seoUrlFormatter bean:
|
Property |
Description |
|---|---|
|
|
Specifies the default query encoding, for
example,
|
|
|
The separator token used to separate the path section of the URL from the parameter section. |
|
|
The character used to separate key/value pairs in the parameter section of the URL. |
|
|
Specifies the URL parameter keys for the following:
|
|
|
The
|
|
|
The
|
|
|
The
|
|
|
Specifies the canonicalizer used to sort URL parameters to ensure that included parameters are arranged a specific order. |
|
|
Determines whether or not the canonicalizer
specified in
|
|
|
A list of
|
The configuration in
WEB-INF\endeca-seo-url-config is shown below:
<!--
########################################################################
# BEAN: seoUrlFormatter
#
# This is the SEO URL formatter, which is responsible for
# transforming UrlState objects into URL strings.
#
-->
<bean id="seoUrlFormatter" class="com.endeca.soleng.urlformatter.seo.SeoUrlFormatter">
<property name="defaultEncoding">
<value>UTF-8</value>
</property>
<property name="pathSeparatorToken">
<value>_</value>
</property>
<property name="pathKeyValueSeparator">
<value>-</value>
</property>
<property name="pathParamKeys">
<list>
<value>R</value>
<value>A</value>
<value>N</value>
</list>
</property>
<property name="navStateFormatter">
<ref bean="navStateFormatter"/>
</property>
<property name="ERecFormatter">
<ref bean="erecFormatter"/>
</property>
<property name="aggrERecFormatter">
<ref bean="aggrERecFormatter"/>
</property>
<property name="navStateCanonicalizer">
<ref bean="navStateCanonicalizer"/>
</property>
<property name="useNavStateCanonicalizer">
<value>false</value>
</property>
<property name="urlParamEncoders">
<list>
<ref bean="N-paramEncoder"/>
</list>
</property>
</bean>

