/* * This file was automatically generated by MD4J. * * Licensed under the GNU General Public License, Version 2.0 (the "License") or above; * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * *http://www.gnu.org/licenses/gpl.txt * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package gr.abiss.md4j.sampledomain.web; import java.util.Map; import java.util.HashMap; import java.util.HashMap; import java.util.Date; import java.text.SimpleDateFormat; import gr.abiss.md4j.sampledomain.City; import org.apache.commons.lang.BooleanUtils; import org.apache.struts.validator.ValidatorForm; import gr.abiss.md4j.util.Md4jGlobals; import org.apache.log4j.Logger; /** * @struts.form name="CityCrudForm" * */ public class CityCrudForm extends ValidatorForm{ private static Logger log = Logger.getLogger(CityCrudForm.class); private Map parentSelectOptions = new HashMap(); // before property call: id element // property: id element /** * id */ private String id; // before property call: property element // property: property element /** * name */ private String name; // before property call: property element // property: property element /** * region */ private String region; // before property call: property element // property: property element /** * population */ private String population; // before property call: many-to-one element // property: many-to-one element /** * country */ private String country; public Map getParentSelectOptions() { return this.parentSelectOptions; } /** */ public void setParentSelectOptions(Map options) { String countryKey = Md4jGlobals.PARENT_OPTIONS + "#country"; this.parentSelectOptions.put(countryKey, options.get(countryKey)); } // before propertyMethods call: id element // propertyMethods: id element /** * Get the id * @return the id */ public String getId(){ return this.id; } /** * Set the id * @param id the id to set * @struts.validator type="long" * @struts.validator-args arg0resource="CityCrudForm.id" */ public void setId(String id){ this.id = id; } // before propertyMethods call: property element // propertyMethods: property element /** * Get the name * @return the name */ public String getName(){ return this.name; } /** * Set the name * @param name the name to set * @struts.validator type="required" * @struts.validator-args arg0resource="name" */ public void setName(String name){ this.name = name; } // before propertyMethods call: property element // propertyMethods: property element /** * Get the region * @return the region */ public String getRegion(){ return this.region; } /** * Set the region */ public void setRegion(String region){ this.region = region; } // before propertyMethods call: property element // propertyMethods: property element /** * Get the population * @return the population */ public String getPopulation(){ return this.population; } /** * Set the population * @param population the population to set * @struts.validator type="required,integer" * @struts.validator-args arg0resource="CityCrudForm.population" */ public void setPopulation(String population){ this.population = population; } // before propertyMethods call: many-to-one element // propertyMethods: many-to-one element /** * Get the country * @return the country */ public String getCountry(){ return this.country; } /** * Set the country * @param country the country to set * @struts.validator type="required" * @struts.validator-args arg0resource="country" */ public void setCountry(String country){ this.country = country; } /** * Populate own properties from the given POJO */ public void copyProperties(Object bean) { City pojo = (City) bean; this.setId(pojo.getId().toString()); this.setName(pojo.getName()); this.setRegion(pojo.getRegion()); this.setPopulation(pojo.getPopulation().toString()); // Uncomment line below to copy from feched/non-lazy // this.setCountry(pojo.getCountry().getId().toString()); } /** * Populate own properties from the given map */ public void copyProperties(Map from) { Object idObj = from.get("id"); if(idObj != null){ this.setId(idObj.toString()); } Object nameObj = from.get("name"); if(nameObj != null){ this.setName((String) nameObj); } Object regionObj = from.get("region"); if(regionObj != null){ this.setRegion((String) regionObj); } Object populationObj = from.get("population"); if(populationObj != null){ this.setPopulation(populationObj.toString()); } Object countryObj = from.get("country"); if(countryObj != null){ this.setCountry(countryObj.toString()); } } /** * Get the attribute vale pairs of this form bean instance as a Map * @see gr.abiss.md4j.web.Md4jActionForm#toMap() */ public Map toMap() { Map params = new HashMap(); if(this.id != null && this.id.length() > 0){ params.put("id", this.id); } if(this.name != null && this.name.length() > 0){ params.put("name", this.name); } if(this.region != null && this.region.length() > 0){ params.put("region", this.region); } if(this.population != null && this.population.length() > 0){ params.put("population", this.population); } if(this.country != null && this.country.length() > 0){ params.put("country", this.country); } return params; } }