Portlet Factory, Version 6.1.2


 

Sample profile selection handler

The following code is an example of a simple profile selection handler that associates a request with a profile according to the day of the week:

import com.bowstreet.webapp.ModelInstanceCreator; import com.bowstreet.profiles.*; import com.bowstreet. model .IProfileSelection import javax.servlet.http.*; import java.util.Map; public class SampleProfileSelection extends SelectionHandlerBase public String selectProfile(HttpServletRequest request, ProfileSet profileSet, String modelName, String explicitProfile, ModelInstanceCreator modelInstanceCreator)
// Get the day of the week Calendar calendar = new GregorianCalendar(); int day = calendar.get(Calendar.DAY_OF_WEEK);
// if it's Monday then get the Monday Profile if(day == Calendar.MONDAY) return profileSet.getProfile("Monday").getName(); else return profileSet.DEFAULT;
}

 

About profile names

To support the ability to query a profile set for its hierarchy without having to filter out possible thousands of leaf nodes we are adding the concept of a container node flag. This flag is a boolean on each profile that can specify that it is a container. The hierarchy should be fairly limited in size compared to the number of leaf nodes, which in theory can be thousands or hundreds of thousands. By default, all new profiles created will be containers and therefore manually set its container flag to false if you intend it to not be a container. This flag is also exposed as a profile property in the profile manager.

Parent topic: Creating profile selection handlers


Library | Support |