| Search Criteria Panel |
|
|
| Thursday, 29 June 2006 09:18 | ||||||
|
We are finally ready to attack the front-end! In this section, we will use the AndroMDA BPM4Struts cartridge to develop a Struts based web front-end. Note that AndroMDA offers another cartridge to generate JSF based front-ends. However, if you like some other front-end framework better, you can roll your own cartridge! But remember to share it with the community :-). The BPM4Struts cartridge generates Struts web pages from a UML model that defines the flow of your application. Before we get into modeling our application, please read the following material to understand fundamental concepts behind the BPM4Struts cartridge.
As you might have gathered, there are 3 important concepts associated with creating
a web page: a use case, an activity diagram (that details the use case), and one
or more controllers (whose methods can be called from the activity diagram). So
let's discuss how we will model our search screen. We will start with a use case
called
We will then add details to this use case by creating an activity diagram. The activity diagram is shown below:
The activity diagram can use the
Now let's enter the use case, the activity diagram and the controller in our model. Please follow one of the links below to edit the model with the UML tool of your choice.
Now let's ask AndroMDA to generate code for the
The only code we need to write by hand is the call from the
// license-header java merge-point
package org.andromda.timetracker.web.timecardsearch;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.andromda.timetracker.vo.UserVO;
import org.andromda.timetracker.vo.UserVOComparator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionMapping;
public class SearchControllerImpl extends SearchController
{
private Log logger = LogFactory.getLog(SearchControllerImpl.class);
private static final String ALL_STRING = "-- All --";
public final void populateSearchScreen(
ActionMapping mapping,
org.andromda.timetracker.web.timecardsearch.PopulateSearchScreenForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception
{
if (logger.isDebugEnabled()) {
logger.debug("form: " + form);
}
// Get list of users and add the "All" option at the top
UserVO[] users = getUserService().getAllUsers();
Arrays.sort(users, new UserVOComparator());
List userList = new ArrayList(Arrays.asList(users));
userList.add(0, new UserVO(null, ALL_STRING, null, null));
// Populate submitter and approver dropdowns
form.setSubmitterBackingList(userList, "id", "username");
form.setApproverBackingList(userList, "id", "username");
}
}
Note that we sort the Now follow the steps below to build and deploy the application to JBoss and test it.
2006-06-29 02:47:41,541 DEBUG form:
org.andromda.timetracker.web.timecardsearch.SearchTimecardsSearchFormImpl@a2bd15
[startDateMinimum=Tue Jun 13 00:00:00 EDT 2006,
startDateMaximum=Wed Jun 07 00:00:00 EDT 2006,
submitter=3,
status=<null>,
approver=2]
Below is a screen shot of the Search screen so far. Isn't it amazing that we were able to get all this functionality without much coding? Of course, the look and feel is nowhere near what we want, but we will take care of that once the screen is fully functional.
What's Next?Congratulations! You have successfully deployed a complete vertical slice of the application that includes a front-end, middle-tier and a back-end. We are now ready start our second iteration with the goal to build the Search Results panel. Click the Next link below to start iteration 2.
|
||||||
| Last Updated on Sunday, 02 November 2008 23:15 |





