Search Results Panel

We are now ready to implement the Search Results panel. We will do this by enhancing the Search Timecards activity diagram in two stages. The first stage will introduce the results table and the second stage will introduce the navigation to the Timecard Details page. The modified activity diagram for stage one is shown below:

Search Timecards Activity Diagram

Notice that we have added a page variable called timecardSummaries, which is a collection of TimecardSummaryVO objects. This page variable will be tagged to tell AndroMDA to render it as a table. Follow one of the links below to add the page variable to your model.

We now need to enhance our SearchController to fill in this page variable with search results. For this to happen, we need to do two things:

  1. The page variable must be made available to the populateSearchScreen() method. To do this, add a sixth parameter to this method in the model. The name and type of the parameter must match the timecardSummaries page variable exactly.
  2. SearchController needs access to the TimeTrackingService. Open the Services diagram and add a dependency from SearchController to TimeTrackingService as shown below. Note that we have suppressed the full signature of the findTimeCards() method.
Search Controller

Now let's ask AndroMDA to generate code for the modified Search Timecards functionality:

  1. Execute the command mvn install in the Command Prompt. Make sure you get a BUILD SUCCESSFUL message.

Next we need to modify the SearchController to initialize the timecardSummaries page variable with search results. To do this, open the file SearchControllerImpl.java and add the code shown below in bold:

                // license-header java merge-point
                package org.andromda.timetracker.web.timecardsearch;
                ...
import org.andromda.timetracker.vo.TimecardSearchCriteriaVO;
import org.andromda.timetracker.vo.TimecardSummaryVO;
import org.andromda.timetracker.vo.UserVO;

                public class SearchControllerImpl extends SearchController
                {
                    ...
                    public final void populateSearchScreen(...)
                    throws Exception
                    {
                    ...

                        // Populate submitter and approver dropdowns
                        form.setSubmitterBackingList(userList, "id", "username");
                        form.setApproverBackingList(userList, "id", "username");

                        // Populate timecard summaries
                        TimecardSearchCriteriaVO criteria = new TimecardSearchCriteriaVO(
                            form.getSubmitter(),
                            form.getApprover(),
                            form.getStatus(),
                            form.getStartDateMinimum(),
                            form.getStartDateMaximum());

                        Collection<TimecardSummaryVO> timecards =
                            getTimeTrackingService().findTimecards(criteria);
                        form.setTimecardSummaries(timecards);
                    }

                }
            

Follow the steps below to build and deploy the application to JBoss and test it.

  1. Build only the web project to make sure the code added above is compiled and packaged. Here's how:
    mvn -f web/pom.xml install
  2. Make sure the JBoss server is running.
  3. Deploy the application: Copy timetracker.war from web\target to Jboss standalone\deployments directory.
  4. Open a browser and make it point to http://localhost:8080/timetracker. The TimeTracker search page should appear along with search results. You should be able to change the search parameters to see new search results.

Below is a screen shot of the Search screen so far.

Search Results Panel

What's Next?

Now that the search results table is showing well, we need to add the details column that will allow us to navigate to the Timecard Details page. Click here to add this column.