[Building Sakai] using UIMessage.make

Joshua Swink joshua.swink at gmail.com
Thu Oct 11 11:06:20 PDT 2012


I'm trying to make sense of some behavior seen when I use
UIMessage.make. My objective is to change some messages when you are
adding participants to a site. When I used some code in
SameRoleProducer.fillComponents() that was similar to
AddProducer.fillComponents(), the SameRole page failed to render
properly.

When you are adding participants to a site, on the first page ("Add
Participants") there is a message that only appears when you are
adding people to a course site. The logic for making the message
available is in
org.sakaiproject.site.tool.helper.participant.rsf.AddProducer.fillComponents(),
like this:

if (isCourseSite) {
     // show specific instructions for adding participant into course site
     UIMessage.make(content, "add.official", "add.official");
     UIMessage.make(content, "add.official1", "add.official1");
     UIMessage.make(content, "add.official.instruction",
"add.official.instruction");
}

I desired to have the same thing happen in the role selection pages,
so I duplicated the logic. This is when something strange happened. I
added the following to SameRoleProducer.fillComponents():

if (isCourseSite) {
            UIMessage.make(content, "add.official1", "add.official1");
}

This resulted in the same-role page consisting entirely of the text of
the message labeled 'add.official1' (except for the text in the h3
header which is literally included in the html file). This happened
before I had even made any changes to the file (SameRole.html). In
other words, the add.official1 message was not even referenced
anywhere in the file:

---- Begin rendering of SameRole.html ----
Choose a Role for Participant
This is the add.official1 message text explaining why you cannot add
students here.
---- End ----

I managed to work around this by calling UIMessage.make on the
original UIContainer that was passed to the fillComponents method. But
I have no idea why this works, or whether it could have undesirable
side effects. (UIMessage.make is passed 'tofill' rather than
'content')

    public void fillComponents(UIContainer tofill, ViewParameters
arg1, ComponentChecker arg2) {
        boolean isCourseSite = handler.isCourseSite();
        UIBranchContainer content = UIBranchContainer.make(tofill, "content:");

        if (isCourseSite) {
            UIMessage.make(tofill, "add.official1", "add.official1");
        }

   UIForm sameRoleForm = UIForm.make(content, "sameRole-form");
   ...

This has resulted in the behavior I want, where add.official1's
message text appears in the page only for course sites, and the other
items on the page are showing up normally. But I am unclear as to why
UIMessage.make is acting differently in these two classes.

Josh


More information about the sakai-dev mailing list