001// --------------------------------------------------------------------------------
002// Copyright 2002-2025 Echo Three, LLC
003//
004// Licensed under the Apache License, Version 2.0 (the "License");
005// you may not use this file except in compliance with the License.
006// You may obtain a copy of the License at
007//
008//     http://www.apache.org/licenses/LICENSE-2.0
009//
010// Unless required by applicable law or agreed to in writing, software
011// distributed under the License is distributed on an "AS IS" BASIS,
012// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013// See the License for the specific language governing permissions and
014// limitations under the License.
015// --------------------------------------------------------------------------------
016
017package com.echothree.view.client.web.struts;
018
019import com.echothree.control.user.party.client.helper.NameSuffixesHelper;
020import com.echothree.control.user.party.client.helper.PersonalTitlesHelper;
021import com.echothree.model.control.party.common.choice.NameSuffixChoicesBean;
022import com.echothree.model.control.party.common.choice.PersonalTitleChoicesBean;
023import java.util.List;
024import javax.naming.NamingException;
025import org.apache.struts.util.LabelValueBean;
026
027public class BasePersonActionForm
028        extends BasePartyActionForm {
029    
030    private PersonalTitleChoicesBean personalTitleChoices = null;
031    private NameSuffixChoicesBean nameSuffixChoices = null;
032    
033    private String personalTitleChoice = null;
034    private String firstName = null;
035    private String middleName = null;
036    private String lastName = null;
037    private String nameSuffixChoice = null;
038    
039    /** Creates a new instance of BasePersonActionForm */
040    public BasePersonActionForm() {
041        super();
042    }
043    
044    private void setupPersonalTitleChoices()
045            throws NamingException {
046        if(personalTitleChoices == null) {
047            personalTitleChoices = PersonalTitlesHelper.getInstance().getPersonalTitleChoices(userVisitPK, true);
048
049            if(personalTitleChoice == null) {
050                personalTitleChoice = personalTitleChoices == null ? null : personalTitleChoices.getDefaultValue();
051            }
052        }
053    }
054    
055    private void setupNameSuffixChoices()
056            throws NamingException {
057        if(nameSuffixChoices == null) {
058            nameSuffixChoices = NameSuffixesHelper.getInstance().getNameSuffixChoices(userVisitPK, true);
059
060            if(nameSuffixChoice == null) {
061                nameSuffixChoice = nameSuffixChoices == null ? null : nameSuffixChoices.getDefaultValue();
062            }
063        }
064    }
065    
066    public List<LabelValueBean> getPersonalTitleChoices()
067            throws NamingException {
068        List<LabelValueBean> choices = null;
069        
070        setupPersonalTitleChoices();
071        if(personalTitleChoices != null) {
072            choices = convertChoices(personalTitleChoices);
073        }
074        
075        return choices;
076    }
077    
078    public void setPersonalTitleChoice(String personalTitleChoice) {
079        this.personalTitleChoice = personalTitleChoice;
080    }
081    
082    public String getPersonalTitleChoice()
083            throws NamingException {
084        setupPersonalTitleChoices();
085        
086        return personalTitleChoice;
087    }
088    
089    public void setFirstName(String firstName) {
090        this.firstName = firstName;
091    }
092    
093    public String getFirstName() {
094        return firstName;
095    }
096    
097    public void setMiddleName(String middleName) {
098        this.middleName = middleName;
099    }
100    
101    public String getMiddleName() {
102        return middleName;
103    }
104    
105    public void setLastName(String lastName) {
106        this.lastName = lastName;
107    }
108    
109    public String getLastName() {
110        return lastName;
111    }
112    
113    public List<LabelValueBean> getNameSuffixChoices()
114            throws NamingException {
115        List<LabelValueBean> choices = null;
116        
117        setupNameSuffixChoices();
118        if(nameSuffixChoices != null) {
119            choices = convertChoices(nameSuffixChoices);
120        }
121        
122        return choices;
123    }
124    
125    public void setNameSuffixChoice(String nameSuffixChoice) {
126        this.nameSuffixChoice = nameSuffixChoice;
127    }
128    
129    public String getNameSuffixChoice()
130            throws NamingException {
131        setupNameSuffixChoices();
132        
133        return nameSuffixChoice;
134    }
135    
136}