]> git.mxchange.org Git - addressbook-war.git/commitdiff
Continued:
authorRoland Haeder <roland@mxchange.org>
Wed, 14 Oct 2015 11:22:58 +0000 (13:22 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 14 Oct 2015 11:45:35 +0000 (13:45 +0200)
- added user profile visibility flag to registration form
- moved all converter to proper directory
- added missing strings to i18n file
- renamed some for better naming convention
- registered validator with this application
Signed-off-by:Roland Häder <roland@mxchange.org>

src/java/org/mxchange/addressbook/beans/user/UserWebBean.java
src/java/org/mxchange/addressbook/beans/user/UserWebController.java
src/java/org/mxchange/addressbook/converter/TrueFalseToBooleanConverter.java [deleted file]
web/WEB-INF/templates/generic/form_personal_data.tpl

index 9aaa709a63d516389641665f1d5b5e7f8a82e9dc..650d6540122f439136581e13932db888da52d174 100644 (file)
@@ -198,6 +198,11 @@ public class UserWebBean implements UserWebController {
         */
        private List<User> publicUserList;
 
+       /**
+        * Whether the user wants a public profile
+        */
+       private Boolean userProfilePublic;
+
        /**
         * Default constructor
         */
@@ -241,6 +246,7 @@ public class UserWebBean implements UserWebController {
                // Clear all data
                // - personal data
                this.setUserId(null);
+               this.setUserProfilePublic(null);
                this.setGender(Gender.UNKNOWN);
                this.setFirstName(null);
                this.setFamilyName(null);
@@ -270,6 +276,7 @@ public class UserWebBean implements UserWebController {
                // Copy all fields:
                // - base data
                this.setUserId(user.getUserId());
+               this.setUserProfilePublic(user.getUserPublicProfile());
                this.setGender(user.getUserContact().getContactGender());
                this.setFirstName(user.getUserContact().getContactFirstName());
                this.setFamilyName(user.getUserContact().getContactFamilyName());
@@ -317,6 +324,8 @@ public class UserWebBean implements UserWebController {
                // Create new user instance
                User user = new LoginUser();
                user.setUserName(this.getUserName());
+               user.setUserPublicProfile(this.getUserProfilePublic());
+               user.setUserCreated(new GregorianCalendar());
 
                // Generate phone number
                DialableLandLineNumber phone = new LandLineNumber(this.getPhoneCountry(), this.getPhoneAreaCode(), this.getPhoneNumber());
@@ -398,7 +407,6 @@ public class UserWebBean implements UserWebController {
 
                // Set contact in user
                user.setUserContact(contact);
-               user.setUserCreated(new GregorianCalendar());
 
                // Trace message
                //this.getLogger().logTrace(MessageFormat.format("createUserInstance: user={0} - EXIT!", user));
@@ -636,6 +644,16 @@ public class UserWebBean implements UserWebController {
                this.userPasswordRepeat = userPasswordRepeat;
        }
 
+       @Override
+       public Boolean getUserProfilePublic () {
+               return this.userProfilePublic;
+       }
+
+       @Override
+       public void setUserProfilePublic (final Boolean userProfilePublic) {
+               this.userProfilePublic = userProfilePublic;
+       }
+
        @Override
        public Integer getZipCode () {
                return this.zipCode;
@@ -671,6 +689,7 @@ public class UserWebBean implements UserWebController {
        @Override
        public boolean isRequiredPersonalDataSet () {
                return ((this.getUserName() != null)
+                               && (this.getUserProfilePublic() != null)
                                && (this.getGender() != null)
                                && (this.getFirstName() != null)
                                && (this.getFamilyName() != null)
index c1352663a23e0467012a7a428c2f919a270cc99c..91f6ec10dae0799702d9cc610088ec4d65e6e424 100644 (file)
@@ -394,6 +394,20 @@ public interface UserWebController extends Serializable {
         */
        public void setZipCode (final Integer zipCode);
 
+       /**
+        * Getter for user public profile flag
+        * <p>
+        * @return User public profile flag
+        */
+       public Boolean getUserProfilePublic ();
+
+       /**
+        * Setter for user public profile flag
+        * <p>
+        * @param userProfilePublic User public profile flag
+        */
+       public void setUserProfilePublic (final Boolean userProfilePublic);
+
        /**
         * Checks whether user instance's email address is used
         * <p>
diff --git a/src/java/org/mxchange/addressbook/converter/TrueFalseToBooleanConverter.java b/src/java/org/mxchange/addressbook/converter/TrueFalseToBooleanConverter.java
deleted file mode 100644 (file)
index 9d63a00..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2015 Roland Haeder
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.addressbook.converter;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.faces.convert.FacesConverter;
-
-/**
- * A converter to convert "true" to boolean true and "false" to boolean false
- * <p>
- * @author Roland Haeder
- */
-@FacesConverter(value = "trueFalse")
-public class TrueFalseToBooleanConverter implements Converter {
-
-       @Override
-       public Object getAsObject (final FacesContext context, final UIComponent component, final String value) {
-               return Boolean.valueOf(value);
-       }
-
-       @Override
-       public String getAsString (final FacesContext context, final UIComponent component, final Object value) {
-               return Boolean.toString((Boolean) value);
-       }
-}
index 7a20d404c003144a1c3da98c29b862aabcf7550c..ad7e4133b78fd579b6e83edae20244dddabf409d 100644 (file)
                                </div>
 
                                <div class="table_right">
-                                       <h:selectOneMenu class="select" id="publicUserProfileFlag" required="true" requiredMessage="#{msg.PUBLIC_USER_PROFILE_NOT_CHOOSEN_MESSAGE}">
+                                       <h:selectOneMenu class="select" id="publicUserProfileFlag" value="#{userController.userProfilePublic}" required="true" requiredMessage="#{msg.PUBLIC_USER_PROFILE_NOT_CHOOSEN_MESSAGE}">
                                                <f:selectItem class="option" itemValue="true" itemLabel="#{msg.PUBLIC_PROFILE_ENABLED}" />
                                                <f:selectItem class="option" itemValue="false" itemLabel="#{msg.PUBLIC_PROFILE_DISABLED}" />
-                                               <f:converter for="publicUserProfileFlag" converterId="trueFalse" />
+                                               <!-- <f:converter for="publicUserProfileFlag" converterId="trueFalse" /> //-->
                                                <f:validator for="publicUserProfileFlag" validatorId="UserProfileVisibilityValidator" />
                                        </h:selectOneMenu>
                                </div>