Organizing Folders for Larger Applications

Refactoring the Prototype
Step 1 of 6

In larger projects, it is important to have all of your files and modules well organized. You’ll make two changes to help better organize your project:

  1. Move the guestbook-web module into the guestbook folder so that it’s in the same place as the guestbook-service and guestbook-api modules that you created.

  2. Since you’ll now have two portlets, reorganize your JSPs to group them by portlet.

Moving guestbook-web

The best way to move modules around is to use Dev Studio CE’s Refactor function. The refactor function scans for and updates project dependencies and links.

  1. In the Project Explorer, right-click on guestbook-web and select RefactorMove.

  2. In the window that appears, click Browse, navigate to the guestbook folder and then click New Folder.

  3. Name the new folder guestbook-web.

  4. Click Open and then OK to confirm.

Your guestbook-web folder now appears in the structure with the other modules.

guestbook-refactor.png

Figure 1: After you move it using the Refactor function, all of your modules are in the same folder..

Reorganizing JSPs

Currently, all your JSPs sit in your web module’s src/main/resources/META-INF/resources folder, which serves as the context root folder. To make a clear separation between the Guestbook portlet and the Guestbook Admin portlet, you must place the files that make up their view layers in separate folders:

  1. In the guestbook-web project, right click the src/main/resources/META-INF/resources folder and select NewFolder. Name the new folder guestbookwebportlet and click Finish.

  2. Copy view.jsp and edit_entry.jsp into the new folder by dragging and dropping them there.

  3. Open both files and change the init.jsp location at the top of the file:

    <%@include file="../init.jsp"%>        
    
  4. Check the other references to JSPs within the files to make sure that they point to the new locations.

As you update your view layer to take full advantage of the new back-end, you’ll update any references to the old paths. In addition, you must update the resource location in your component properties. In the next step, you’ll update all of those properties, including the one that defines the resource location.

0 (0 Votes)
Refactoring the Prototype Previous