From: Roland Haeder Date: Wed, 14 Oct 2015 11:22:58 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=8cb5ac2aa04f38b4dbf9f94abd03c62449c985f4;p=addressbook-war.git Continued: - 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 --- diff --git a/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java b/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java index 9aaa709a..650d6540 100644 --- a/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java +++ b/src/java/org/mxchange/addressbook/beans/user/UserWebBean.java @@ -198,6 +198,11 @@ public class UserWebBean implements UserWebController { */ private List 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) diff --git a/src/java/org/mxchange/addressbook/beans/user/UserWebController.java b/src/java/org/mxchange/addressbook/beans/user/UserWebController.java index c1352663..91f6ec10 100644 --- a/src/java/org/mxchange/addressbook/beans/user/UserWebController.java +++ b/src/java/org/mxchange/addressbook/beans/user/UserWebController.java @@ -394,6 +394,20 @@ public interface UserWebController extends Serializable { */ public void setZipCode (final Integer zipCode); + /** + * Getter for user public profile flag + *

+ * @return User public profile flag + */ + public Boolean getUserProfilePublic (); + + /** + * Setter for user public profile flag + *

+ * @param userProfilePublic User public profile flag + */ + public void setUserProfilePublic (final Boolean userProfilePublic); + /** * Checks whether user instance's email address is used *

diff --git a/src/java/org/mxchange/addressbook/converter/TrueFalseToBooleanConverter.java b/src/java/org/mxchange/addressbook/converter/TrueFalseToBooleanConverter.java deleted file mode 100644 index 9d63a009..00000000 --- a/src/java/org/mxchange/addressbook/converter/TrueFalseToBooleanConverter.java +++ /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 . - */ -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 - *

- * @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); - } -} diff --git a/web/WEB-INF/templates/generic/form_personal_data.tpl b/web/WEB-INF/templates/generic/form_personal_data.tpl index 7a20d404..ad7e4133 100644 --- a/web/WEB-INF/templates/generic/form_personal_data.tpl +++ b/web/WEB-INF/templates/generic/form_personal_data.tpl @@ -201,10 +201,10 @@

- + - +