RSF Debugging Exercise

Introduction

This exercise starts with a CRUD tool generated using Sakai App Builder plugin for eclipse. The tool source has been modified to introduce a range of common errors that an RSF developer may encounter.

Getting Started

  1. Download the source code for the exercise into an existing sakai source directory.
  2. Import the source code for the exercise into Eclipse.
  3. Go to command line, run "maven bld dpl" from source directory (keep the command line window open)
  4. Stop Sakai, start Sakai, watch console output
  5. Wait for "Server startup", and then attempt to load site.

Your portal should fail to load, there will be errors in the console output from tomcat. If you wish to work through the exercise yourself, stop reading now and work on your own. The remainder of the document is an answer key that describes the errors that appear and details how to fix them.

Answer Key

  1. Error 1
    1. In short, the error that appears is cryptic, but is common when including your own version of the Spring jars with your tool.
    2. Edit tool/project.xml and comment out or remove the lines that bundle the spring jars in the tool war file.
    3. Stop sakai, run "maven sakai", start Sakai
    4. The startup of Sakai and our tool should proceed normally and the portal should be available again.
  2. Add the Tool to a Site
    1. Log in as an admin
    2. Create a test site that includes our tool.
    3. Open tool. An error appears in both the web interface and the console.
  3. Error 2
    1. The console output indicates that this is an RSF error. Looking at the available templates, we can see that the template filename is different from the View ID specified in the producer.
    2. Open tool/src/java/ItemsProducer.java and tool/src/webapp/templates
    3. Update the view ID to match the name of the template file.
    4. Stop sakai, run "maven sakai", start Sakai
    5. Log in, open test site, open tool.
    6. A Spring error should appear in the console output.
  4. Error 3
    1. Looking at the console output, we can see that somewhere "locale" is incorrectly specified as "localle".
    2. Open tool/src/java/ItemsProducer.java, look for the SetLocale method which exists and appears to be appropriate.
    3. Open tools/src/webapp/WEB-INF/applicationContext.xml. The locale does not appear to be injected in the application context, so we should look at the request context instead.
    4. Open tool/src/webapp/WEB-INF/requestcontext.xml. Looking at the file, we can see that the property that should tell Spring to inject the locale into the producer has a typo. Fix the typo.
    5. Stop sakai, run "maven sakai", start Sakai
    6. Log in, open test site, open tool
    7. The tool loads without any further stack traces.
  5. Error 4
    1. Try "Add Item". An error appears.
    2. Looking at the console output, this appears to be an RSF template error, the error includes a filename and line number.
    3. open the file specified (tool/src/webapp/templates/AddItem.html) and add a closing div before the </body> tag.
    4. Stop sakai, run "maven sakai", start Sakai
    5. Log in, open test site, open tool
    6. Add two items, one hidden, one not hidden. The add function works.
  6. Error 5
    1. Looking at the items view, note that the hidden column is not displayed.
    2. Open Items.html. Note the area of the template that should display the hidden field and make a note of the rsf:id value used.
    3. Open ItemsProducer.java. Note that the section of code that should fill in the hidden field uses an RSF ID that doesn't match the template.
    4. Make it match.
    5. Stop sakai, run "maven sakai", start Sakai
    6. Log in, open test site, open tool
    7. The hidden field now displays correctly
  7. Error 6
    1. Note that the timestamp is not filled in (it says "DATE")
    2. Open ItemsProducer.java. Show the section that fills in the id.
    3. Open Items.html. Show them the definition for the date stamp (rsf:id attribute is wrong).
    4. Fix it, restart, reopen tool
    5. The timestamp is now displayed correctly.
  8. Error 7
    1. Attempt to change the hidden field for an existing item without changing the title.
    2. Note that the update message contains the text "null" where the title of the updated field should appear.
    3. Quick Tip: Find the file that handles the updates by searching for "Updated item". In this case, it's an action handling method in the backing bean.
    4. Open the backing bean. Note that the displayed message uses newItem (which only reflects the information that has been passed). Change newItem.getTitle() to updateItem.getTitle() like so:
      String message = "Updated item: " + updateItem.getTitle();
      
    5. Rebuild, restart, reopen tool.
    6. Edit an existing item and change the value of the hidden field without updating the title. The title is now displayed correctly.