Course sites new user profile pages

20
CourseSites New User Profile pages Powered by SpringMVC 2.5

description

SpringMVC powering SaaS-based Learning Management System for a Fortune 500 company

Transcript of Course sites new user profile pages

Page 1: Course sites new user profile pages

CourseSites New User Profile pages

Powered by SpringMVC 2.5

Page 2: Course sites new user profile pages

Goals

• Modernize the code-base from SpringMVC 2.0 to SpringMVC 2.5 with the end goal of SpringMVC 3.0 in the future

• More engaging User experiences drive adoption (91 countries, 6000+ institutions )

Page 3: Course sites new user profile pages

Spring MVC 2.5key concepts

• The importance of annotations – @Controller (no more inheriting from

SimpleFormController, MultiActionController on 2.0 version)

– @ModelAttribute– @SessionAttribute

Page 4: Course sites new user profile pages

General Architecture (Controller)

• @Controller• @RequestMapping(value="/profile.form")• @SessionAttributes("spring25UserVO")• public class ProfileForm {• ……• ……• }

Page 5: Course sites new user profile pages

General Architecture …(1)

• @RequestMapping(method = RequestMethod.GET)

• public String setupForm(HttpServletRequest request, HttpServletResponse response, Model model) {

• …….• }

Page 6: Course sites new user profile pages

General Architecture….(2)

• @RequestMapping(method = RequestMethod.POST)

• public String processSubmit(HttpServletRequest request, @ModelAttribute("spring25UserVO") Spring25UserVO spring25UserVO,

• BindingResult result, SessionStatus status, Model model) {

• ….• }

Page 7: Course sites new user profile pages

Profile

Page 8: Course sites new user profile pages

Profile page

Page 9: Course sites new user profile pages

Modelin particular wiring the Gender

• public class Spring25UserVO {– private UserVO userVO;

• …….• }

Page 10: Course sites new user profile pages

Model…(1)

• public class UserVO {– private User user;

• ………..• }

Page 11: Course sites new user profile pages

Model…(3)• public class User {• …….

• /**• * Returns the gender of this <code>User</code> object.• * <p>• * Requires AttributePermission with name "user.personalinfo", actions "get".• * • * @return a gender value as defined in {@link User.Gender}• * @see User.Gender• */• public User.Gender getGender()• {• if ( _checkPerms )• {• SecurityUtil.checkPermission( _getPersonalInfo );• }

• return (User.Gender) _bbAttributes.getBbEnum( UserDef.GENDER );• }• ……• }

Page 12: Course sites new user profile pages

Profile Controller

• @InitBinder• public void initDataBinder(WebDataBinder

dataBinder)• {• dataBinder.registerCustomEditor(Gender.class,

new GenderEditor());•

dataBinder.registerCustomEditor(EducationLevel.class, new EducationEditor());

• }

Page 13: Course sites new user profile pages

Custom Editor• public class GenderEditor extends PropertyEditorSupport {

– @Override– public String getAsText() {

• // TODO Auto-generated method stub• Gender value = (Gender) getValue();• return value.toFieldName();

– }

– @Override– public void setAsText(String text) throws IllegalArgumentException {

• // TODO Auto-generated method stub• //super.setAsText(text);• if (text.equalsIgnoreCase(Gender.FEMALE.toFieldName())) {

– setValue(Gender.FEMALE);

• }• else if (text.equalsIgnoreCase(Gender.MALE.toFieldName())) {

– setValue(Gender.MALE);

• }• else {

– setValue(Gender.UNKNOWN);

• }

– }

• }

Page 14: Course sites new user profile pages

Profile View/JSP

• <form:form id="profileForm" name="NewUserProfileForm" modelAttribute="spring25UserVO" method="POST">

• ……• </form:form>

Page 15: Course sites new user profile pages

Profile View/JSP• <spring:message code="bb.userProfile.gender" var="gender">

</spring:message>• <bbNG:dataElement label="${gender}" isRequired="false">• <!-- the "path" element (gender) points to the userVO.user.gender

property • so as long as the userVO.user.gender reflects the value from the • DB (User.gender) such as "MALE"...this will be automatically• "selected" as well -->

• <form:select path="userVO.user.gender" items="${genders}"/>

• </bbNG:dataElement>

Page 16: Course sites new user profile pages

Social PagejQuery Dialog

Page 17: Course sites new user profile pages

Social PagejQuery dialog

Page 18: Course sites new user profile pages

jQuery Dialog• jQuery("#dialog").dialog({• modal: true,• bgiframe: true,• width: 500,• height: 200,• autoOpen: false• });

• jQuery("#confirmDeleteImage").dialog({• modal: true,• bgiframe: true,• autoOpen: false });

Page 19: Course sites new user profile pages

jQuery Dialog …(cont)• jQuery(".myavatar").click(function (e) {• jQuery("#dialog").dialog({• buttons : {• "Update" : function() {• window.location.href = "imageUpload.form";• },• "Delete" : function() {• jQuery(this).dialog("close");• jQuery('#confirmDeleteImage').dialog('option', 'buttons', { • "No": function() { jQuery(this).dialog("close"); },• "Yes": function() { window.location.href = "imageDelete.form"; } • });• jQuery('#confirmDeleteImage').dialog('open');• • }, • "Cancel" : function() {• jQuery(this).dialog("close");• }• }• });

• jQuery("#dialog").dialog("open");• return false;• });

Page 20: Course sites new user profile pages

Q&A

• Questions?! Comments?!