|
Creating path-specific associationsNow that you've seen how retrieving children from a path works, let's use the application to create some children, and see how that is accomplished. Remember that I use the term path-specific to refer to associations that require knowledge of other relationships -- exactly what the PathProxy is for. If you deploy the application and look at the first page, you'll see something similar to the screenshot in Figure 4.
![]()
Figure 4. Index.jsp with no dataThe extremely Spartan interface in Figure 4 has just enough to show off PathProxy's stuff. You can see that there are no instances of our domain classes. Creating some of these objects is straightforward, just use the Add links. After you do that, you'll see the tree reflect the new data, as in Figure 5.
![]()
Figure 5. Index.jsp with some objects createdNow we can add a manager to a project by clicking on the project. Selecting a manager you've created previously and hitting OK will add it. Remember, that is being done via a JPA many-to-many mapping. Its pretty standard stuff. Once you've done that, however, you will be able to expand the tree down to the manager on the project. Clicking on the manager in the tree allows you to add a developer to the manager -- but only for that project!
How does that work? The first thing to realize is that when you click on the manager under the Managers on Project node of a Project, it actually sends back a nodeString to the server, which is saved in the session for use while the manager is being edited. To see what I mean, look at the SessionBean. Specifically, look at getCurrentSelection() in the (heavily truncated) Listing 8. That method is used by the managerDetail.jsp screen to get the current object, which also causes the method to grab the nodeString from the request parameters and save it. Since this bean is session scoped, we can then grab the nodeString later on and use it when setting a developer on the manager. That is, we'll use the nodeString to actually set the developer, via the pathProxy mechanism, on the path represented by the nodeString. |
|