Portlet Factory, Version 6.1.2


 

Example: custom value class implementation

Here is a sample implementation of a custom value class that replaces a value named "UserName" with the name of the current user name.

import com.bowstreet.webapp.ModelInstanceCreator; import com.bowstreet.profiles.*; import javax.servlet.http.*; import java.util.Map;
public class SampleTestProfileUpdateValue implements ProfileUpdateValue void updateProfileValues(HttpServletRequest request, Profile profile, String modelName, String explicitProfile, ModelInstanceCreator modelInstanceCreator)
// Get the value for the "UserName" and replace it with the current users name. ProfileValue profileValue = profile.getValue("UserName"); if(profileValue != null && request != null)
// assume user is authenticated String strUserName = request.getUserPrincipal().getName();
// now replace it profileValue.setData(strUserName);
}

Parent topic: Default profile selection handler


Library | Support |