Portlet Factory, Version 6.1.2
Creating profile entry value setters
You can assign the values for profile entries at generation time. Use a Java class that implements one of the following interfaces.
- com.bowstreet.profiles.ProfileUpdateValue2
- com.bowstreet.profiles.ProfileUpdateValue
Implementing the ProfileUpdateValue2 interface
The following code example sets a profile entry value to the user name associated with the request.
import com.bowstreet.webapp.ModelInstanceCreator; import com.bowstreet.profiles.*; import javax.servlet.http.*; import java.util.Map; public class SampleTestProfileUpdateValue implements ProfileUpdateValue2 public void updateProfileValues(HttpServletRequest request, Profile profile, String profileSetName, 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: About setting the profile selection handler
Library | Support |