Chapter 10. Customizing the search page 225
These steps are useful in your customization, as they provide a quick and easy
way to dynamically change the search results server at the back end without
bringing the whole WebSphere Commerce Server down. You can change back
and forth the parameters in the struts-ext-config.xml during your development
and customization efforts.
10.3.4 Code customization using WCDSTabbedNav: main.jsp
Once the Struts configuration changes are successfully applied using the steps
described in section 10.3.3, “Struts configuration” on page 219, all places in the
WebSphere Commerce Consumer-Direct store’s code that use
SearchCatalogView would now be directed to the program control to main.jsp
under the
WCDSTabbedNav directory.
Open a browser and point it to the following URL:
The Consumer-Direct store appears as shown in Figure 10-3 on page 215.
Perform a search for
tables within this store. A Web page similar to Figure 10-9
Figure 10-9 WCDSTabbedNav server address empty error page
Notice that the new page does not look like the default search result page shown
in Figure 10-4 on page 216. Let us try to understand the components of
and make the appropriate changes.
main.jsp code is responsible for rendering the search result page and for
providing navigational controls along with the rendered search results. It calls a
number of JSP files as listed in Table 10-1.
Table 10-1 JSP files that are called by main.jsp
JSP file File description
taglibdecl.jsp Contains declarations of tag libraries used by the Web
search application.
config.jsp Contains configuration templates.
226 Getting Started with Commerce Module for OmniFind Discovery Edition
Refer to Figure 10-1 on page 199 and Figure 10-2 on page 200 for graphical
representations of the search result page and its associated JSP files.
To modified the code so that Figure 10-9 on page 225 looks like Figure 10-4,
we leverage the existing code that come along with the integration solution. The
code, including JSPF code fragments and wrappers for the integration solution,
can be found under the application directory.
Copy the files under the application directory from WCDSSearchApplication to
WCDSTabbedNav area. Specifically, copy from:
globalForm.jsp Contains JavaScript functions, form controls, query input
box, the New Search and Search Within radio buttons.
voiceover.jsp Contains code to format and render the voiceover
component in the search result page.
tabbedDrillDown.jsp Contains code to format and render the tabs display.
refineByList.jsp Contains code to format and render the refinement options.
drillSideways.jsp Contains code to format and render the breadcrumb
directAnswer.jsp Contains code to control the display of direct answers (if any
pageContext.jsp Contains code to control the format of the range of results.
mainResultsTable.jsp Contains code to control the main results table rendering.
pagination.jsp Determines the format of the page navigation controls.
viewByOptions.jsp Displays the following controls:
򐂰 group by
򐂰 sort by
򐂰 summarize by
򐂰 auto summarize
򐂰 (results) per page
sidebars.jsp Displays business rules results (if any exist). We do not use
this in our book.
JSP file File description
Chapter 10. Customizing the search page 227
Customizing main.jsp
We have to modify main.jsp such that WCDSTabbedNav returns the correct
search result set. This includes the following steps:
1. Comment out the page encoding code.
2. Add application\jstl.jspf as an include directive to main.jsp.
3. Add application\resourceBundle.jspf as an include directive to main.jsp.
4. Add application\mainInit.jspf to main.jsp.
5. Set BaseDir parameter value.
6. Add application\preInitializeWithPageContext.jspf.
7. Add application\preQuery.jspf.
Step 1. Commenting out the page encoding code
Locate and remove the pageEncoding part of the code in main.jsp. Because
WebSphere Commerce already uses UTF-8 page encoding, OmniFind
Discovery Edition tries to override the existing page encoding with ISO-8859-1.
This creates ambiguity and causes exceptions to be thrown. We comment out
this part of the code by doing as shown in Example 10-14.
Example 10-14 Remove pageEncoding directive from main.jsp
VG: removed
@page pageEncoding="ISO-8859-1" contentType="text/html;
Step 2. Adding application\jstl.jspf as include directive to main.jsp
The jstl.jspf code fragment lists the standard JSTL core and fmt taglibs and the
proprietary wcbase taglib directives used throughout the user interface design.
Add the include directive as follows to
main.jsp just after the include directive of
<%@ jsp include file=”application\jstl.jspf”%>
Important: Make sure that you search for pageEncoding across all JSP files
under WCDSTabbedNav and comment out this line of code. Special attention
should be paid for new code or JSP that will be inserted into the current code
base in the future. If there are any pageEncoding commands, they should be
commented out.

Get Getting Started with Commerce Module for OmniFind Discovery Edition Customization 101 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.