Author: mbooth Date: 2005-02-18 14:42:39 +0100 (Fri, 18 Feb 2005) New Revision: 270 Added: ccm-core/trunk/src/com/arsdigita/formbuilder/PersistentEmailField.java ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/EmailFieldForm.java Removed: ccm-core/trunk/src/com/arsdigita/formbuilder/ui/jsp/ Modified: ccm-cms-types-formitem/trunk/src/com/arsdigita/cms/ui/formbuilder/FormProperties.java ccm-cms/trunk/src/com/arsdigita/cms/enterprise.init ccm-core/trunk/src/com/arsdigita/formbuilder/HiddenIDGenerator.java ccm-core/trunk/src/com/arsdigita/formbuilder/PersistentWidget.java ccm-core/trunk/src/com/arsdigita/formbuilder/actions/ConfirmEmailListener.java ccm-core/trunk/src/com/arsdigita/formbuilder/actions/SimpleEmailListener.java ccm-core/trunk/src/com/arsdigita/formbuilder/actions/TemplateEmailListener.java ccm-core/trunk/src/com/arsdigita/formbuilder/actions/XMLEmailListener.java ccm-core/trunk/src/com/arsdigita/formbuilder/ui/FormbuilderResources.properties ccm-core/trunk/src/com/arsdigita/formbuilder/ui/PlaceholdersInitListener.java ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/HeadingForm.java ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/TemplateEmailForm.java ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/TextAreaForm.java ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/TextFieldForm.java ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/TextForm.java ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/WidgetForm.java ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/WidgetLabelForm.java ccm-core/trunk/src/com/arsdigita/formbuilder/util/FormBuilderUtil.java ccm-core/trunk/src/com/arsdigita/formbuilder/util/Placeholders.java ccm-core/trunk/src/com/arsdigita/mail/MailConfig.java ccm-core/trunk/src/com/arsdigita/util/StringUtils.java ccm-core/trunk/web/packages/formbuilder/xsl/TextWidgets.xsl ccm-core/trunk/web/packages/formbuilder/xsl/formbuilder.xsl ccm-ldn-aplaws/trunk/web/__ccm__/themes/aplaws/lib/lib.xsl Log: Integrate formbuilder changes from InfoAxon Add PersistentEmailField which sets the origin of an email Add data protected text to forms in APLAWS stylesheets Fix HiddenIDGenerator Removed unused code in com.arsdigita.formbuilder.ui.jsp Add tool to aid authoring templated emails Modified: ccm-cms/trunk/src/com/arsdigita/cms/enterprise.init =================================================================== --- ccm-cms/trunk/src/com/arsdigita/cms/enterprise.init 2005-02-18 13:21:09 UTC (rev 269) +++ ccm-cms/trunk/src/com/arsdigita/cms/enterprise.init 2005-02-18 13:42:39 UTC (rev 270) @@ -219,7 +219,10 @@ "com.arsdigita.formbuilder.ui.editors.HeadingForm" }, { "forms-cms", "Section Break", "Section Break", "com.arsdigita.formbuilder.PersistentHorizontalRule", - "com.arsdigita.formbuilder.ui.editors.HorizontalRuleForm" } + "com.arsdigita.formbuilder.ui.editors.HorizontalRuleForm" }, + { "forms-cms", "User Email Fields", "User Email Fields", + "com.arsdigita.formbuilder.PersistentEmailField", + "com.arsdigita.formbuilder.ui.editors.EmailFieldForm" } }; processListenerTypes = { { "forms-cms", "Confirmation email", "Confirmation emails", Modified: ccm-cms-types-formitem/trunk/src/com/arsdigita/cms/ui/formbuilder/FormProperties.java =================================================================== --- ccm-cms-types-formitem/trunk/src/com/arsdigita/cms/ui/formbuilder/FormProperties.java 2005-02-18 13:21:09 UTC (rev 269) +++ ccm-cms-types-formitem/trunk/src/com/arsdigita/cms/ui/formbuilder/FormProperties.java 2005-02-18 13:42:39 UTC (rev 270) @@ -102,11 +102,10 @@ add(new Label(GlobalizationUtil .globalize("cms.ui.formbuilder.description"))); add(m_desc); - - add(new Label(GlobalizationUtil - .globalize("cms.formbuilder.css"))); + //Css control hidden + /*add(new Label(GlobalizationUtil.globalize("cms.formbuilder.css"))); m_css = new TextField(new StringParameter("css")); - add(m_css); + add(m_css);*/ } public void init(FormSectionEvent e) @@ -130,7 +129,8 @@ PersistentForm form = item.getForm(); m_desc.setValue(e.getPageState(), form.getDescription()); - m_css.setValue(e.getPageState(), item.getCSS()); + //Css hidden + //m_css.setValue(e.getPageState(), item.getCSS()); return item; } @@ -140,8 +140,9 @@ FormItem item = (FormItem)super.processBasicWidgets(e); PersistentForm form = item.getForm(); - - item.setCSS((String)m_css.getValue(e.getPageState())); + + //Css hidden + //item.setCSS((String)m_css.getValue(e.getPageState())); item.save(); form.setAdminName(item.getName()); form.setHTMLName(item.getName()); @@ -171,8 +172,10 @@ ContentPage.TITLE); add(GlobalizationUtil.globalize("cms.ui.formbuilder.description"), "form", new FormFormatter()); - add(GlobalizationUtil.globalize("cms.formbuilder.css"), - FormItem.CSS); + //Css hidden temporarily + + //add(GlobalizationUtil.globalize("cms.formbuilder.css"), + // FormItem.CSS); } } Modified: ccm-core/trunk/src/com/arsdigita/formbuilder/HiddenIDGenerator.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/formbuilder/HiddenIDGenerator.java 2005-02-18 13:21:09 UTC (rev 269) +++ ccm-core/trunk/src/com/arsdigita/formbuilder/HiddenIDGenerator.java 2005-02-18 13:42:39 UTC (rev 270) @@ -18,17 +18,27 @@ */ package com.arsdigita.formbuilder; +import com.arsdigita.bebop.FormData; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.RequestLocal; +import com.arsdigita.db.Sequences; import com.arsdigita.formbuilder.PersistentHidden; import com.arsdigita.persistence.DataObject; import com.arsdigita.persistence.metadata.ObjectType; -import java.math.BigDecimal; import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.persistence.OID; +import com.arsdigita.util.UncheckedWrapperException; +import com.arsdigita.web.Web; +import java.math.BigDecimal; +import java.sql.SQLException; +import javax.servlet.http.HttpServletRequest; +public class HiddenIDGenerator extends PersistentHidden { + private RequestLocal m_value = new RequestLocal(); + private static final String FORMS_UNIQUE_ID = "forms_unique_id_seq"; -public class HiddenIDGenerator extends PersistentHidden { public static final String BASE_DATA_OBJECT_TYPE = PersistentHidden.BASE_DATA_OBJECT_TYPE; @@ -38,14 +48,10 @@ public HiddenIDGenerator(String typeName) { super(typeName); - - setDefaultValue("::system.uniqueid::"); } public HiddenIDGenerator(ObjectType type) { super(type); - - setDefaultValue("::system.uniqueid::"); } public HiddenIDGenerator(DataObject obj) { @@ -63,4 +69,19 @@ super(oid); } + + public Object getValue(FormData data) { + HttpServletRequest req = Web.getRequest(); + BigDecimal id = (BigDecimal) req.getAttribute(FORMS_UNIQUE_ID); + if (null != id) return id.toString(); + + try { + id = Sequences.getNextValue("forms_unique_id_seq"); + } catch (SQLException ex) { + throw new UncheckedWrapperException(ex); + } + req.setAttribute(FORMS_UNIQUE_ID, id); + + return id.toString(); + } } Added: ccm-core/trunk/src/com/arsdigita/formbuilder/PersistentEmailField.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/formbuilder/PersistentEmailField.java 2005-02-18 13:21:09 UTC (rev 269) +++ ccm-core/trunk/src/com/arsdigita/formbuilder/PersistentEmailField.java 2005-02-18 13:42:39 UTC (rev 270) @@ -0,0 +1,177 @@ +/* + * Copyright (C) 2001-2004 Red Hat Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +package com.arsdigita.formbuilder; + +import java.math.BigDecimal; + +import com.arsdigita.bebop.Component; +import com.arsdigita.bebop.form.TextField; +import com.arsdigita.persistence.OID; +import com.arsdigita.persistence.DataObject; +import com.arsdigita.persistence.metadata.ObjectType; + +import org.apache.log4j.Logger; + +/** + * This class is responsible for persisting Bebop TextFields. The TextField + * is saved with the save() method. To resurrect the TextField, use the constructor + * taking the id of the saved TextField and then invoke createComponent(). + * + * @author Shubham nagar + * @company Infoaxon Technology + * @date 13-12-2004 + * + */ +public class PersistentEmailField extends PersistentWidget { + + public static final String versionId = "$Id: //core-platform/dev/src/com/arsdigita/formbuilder/PersistentTextField.java#9 $ by $Author$, $DateTime: 2004/08/16 18:10:38 $"; + + private static final Logger s_log = + Logger.getLogger(PersistentEmailField.class.getName()); + + /** + * The fully qualified name of the underlying DataObject of this class. + */ + public static final String BASE_DATA_OBJECT_TYPE = + "com.arsdigita.formbuilder.Widget"; + + // *** Constructors ------------- + + /** + * Constructor that creates a new TextField domain object that + * can be saved to the database later on. This class was only + * included to make it possible to use this DomainObject with the + * FormGenerator (to make the class JavaBean compliant). Use the constructor + * taking a parameter name instead if possible. + */ + public PersistentEmailField() { + this(BASE_DATA_OBJECT_TYPE); + } + + /** + * Constructor that creates a new TextField domain object that + * can be saved to the database later on. + */ + public PersistentEmailField(String typeName) { + super(typeName); + } + + public PersistentEmailField(ObjectType type) { + super(type); + } + + public PersistentEmailField(DataObject obj) { + super(obj); + } + + /** + * Constructor that retrieves an existing TextField domain object + * from the database. + * + * @param id The object id of the TextField domain object to retrieve + */ + public PersistentEmailField(BigDecimal id) { + this(new OID(BASE_DATA_OBJECT_TYPE, id)); + } + + /** + * Extending classes can use this constructor to set the sub class + * id and object type. + */ + public PersistentEmailField(OID oID) { + super(oID); + } + + public static PersistentEmailField create(String parameterName) { + PersistentEmailField t = new PersistentEmailField(); + t.setup(parameterName); + return t; + } + + /** + * Create the TextField whose persistence is managed + * by this domain object. + */ + public Component createComponent() { + TextField textField = new TextField(getParameterName()); + + copyValuesToWidget(textField); + + if (getComponentAttribute("maxlength") != null) { + textField.setMaxLength(getMaxLength()); + } + + if (getComponentAttribute("size") != null) { + textField.setSize(getSize()); + } + + return textField; + } + + //*** Attribute Methods + public void setMaxLength(int maxLength) { + + setComponentAttribute("maxlength", Integer.toString(maxLength)); + } + + /** + * Defaults to 50 if no value has been set. + */ + public int getMaxLength() { + + String maxLength = getComponentAttribute("maxlength"); + + if (maxLength == null) { + return 50; + } + + return Integer.parseInt(maxLength); + } + + public void setSize(int size) { + + setComponentAttribute("size", Integer.toString(size)); + } + + /** + * Defaults to 12 if no value is set. + */ + public int getSize() { + + String size = getComponentAttribute("size"); + + if (size == null) { + return 12; + } + + return Integer.parseInt(size); + } + + //*** Attribute metadata + public AttributeMetaDataList getAttributeMetaData() { + + AttributeMetaDataList list = super.getAttributeMetaData(); + + list.add(new AttributeMetaData("size", "The size of the Text field as shown on the form")); + list.add(new AttributeMetaData("maxLength", "Maximum number of characters that user can input")); + + return list; + } +} Property changes on: ccm-core/trunk/src/com/arsdigita/formbuilder/PersistentEmailField.java ___________________________________________________________________ Name: svn:keywords + "Id Author DateTime" Modified: ccm-core/trunk/src/com/arsdigita/formbuilder/PersistentWidget.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/formbuilder/PersistentWidget.java 2005-02-18 13:21:09 UTC (rev 269) +++ ccm-core/trunk/src/com/arsdigita/formbuilder/PersistentWidget.java 2005-02-18 13:42:39 UTC (rev 270) @@ -21,6 +21,9 @@ import com.arsdigita.formbuilder.parameters.PersistentParameterListener; import com.arsdigita.formbuilder.util.FormBuilderUtil; +import com.arsdigita.bebop.Form; +import com.arsdigita.bebop.FormData; +import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.parameters.ParameterModel; import com.arsdigita.bebop.form.Widget; import com.arsdigita.domain.DataObjectNotFoundException; @@ -322,6 +325,15 @@ return DEFAULT_VALUE_CLASS; } + /** + * Get the value of this widget in the current request. This is the + * preferred method for retrieving this value. Override this method to + * customise this behaviour. + */ + public Object getValue(FormData data) { + return data.get(getParameterName()); + } + //*** Attribute metadata public AttributeMetaDataList getAttributeMetaData() { Modified: ccm-core/trunk/src/com/arsdigita/formbuilder/actions/ConfirmEmailListener.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/formbuilder/actions/ConfirmEmailListener.java 2005-02-18 13:21:09 UTC (rev 269) +++ ccm-core/trunk/src/com/arsdigita/formbuilder/actions/ConfirmEmailListener.java 2005-02-18 13:42:39 UTC (rev 270) @@ -152,8 +152,7 @@ public void process(FormSectionEvent e) throws FormProcessException { - Placeholders p = new Placeholders(e.getPageState(), - e.getFormData()); + Placeholders p = new Placeholders(getForm(), e.getFormData()); User user = (User) Kernel.getContext().getParty(); if( null == user ) { Modified: ccm-core/trunk/src/com/arsdigita/formbuilder/actions/SimpleEmailListener.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/formbuilder/actions/SimpleEmailListener.java 2005-02-18 13:21:09 UTC (rev 269) +++ ccm-core/trunk/src/com/arsdigita/formbuilder/actions/SimpleEmailListener.java 2005-02-18 13:42:39 UTC (rev 270) @@ -152,8 +152,10 @@ public void process(FormSectionEvent e) throws FormProcessException { + FormData data = e.getFormData(); + PersistentFormSection form = getForm(); - Placeholders p = new Placeholders(e.getPageState(), e.getFormData()); + Placeholders p = new Placeholders(form, data); String subject = p.interpolate(m_subject); @@ -161,27 +163,17 @@ String from; if( null == user ) { from = Mail.getConfig().getDefaultFrom(); - if (from == null || "".equals(from)) { - from = "notloggedin@" + - Web.getConfig().getServer().getName(); - } } else { from = user.getPrimaryEmail().getEmailAddress(); } StringBuffer body = new StringBuffer(); - if( null != user ) { - PersonName name = user.getPersonName(); + body.append(from); + body.append(" submitted the following:\n\n"); - body.append( name.getGivenName() ).append( ' ' ); - body.append( name.getFamilyName() ); - body.append( " submitted the following:\n\n" ); - } - String submit = null; - FormData data = e.getFormData(); DataAssociationCursor components = form.getComponents(); while( components.next() ) { PersistentComponent c = (PersistentComponent) @@ -200,20 +192,20 @@ else body.append( label.getLabel() ); - body.append( '\n' ); + body.append( ": " ); - Object value = data.get( w.getParameterName() ); + Object value = w.getValue(data); if( null != value ) { if( value.getClass().isArray() ) { Object[] values = (Object[]) value; for( int i = 0; i < values.length; i++ ) { body.append( values[i].toString() ); - body.append( '\n' ); + if( values.length - 1 != i ) + body.append( ", " ); } } else { body.append( value.toString() ); - body.append( '\n' ); } body.append( '\n' ); Modified: ccm-core/trunk/src/com/arsdigita/formbuilder/actions/TemplateEmailListener.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/formbuilder/actions/TemplateEmailListener.java 2005-02-18 13:21:09 UTC (rev 269) +++ ccm-core/trunk/src/com/arsdigita/formbuilder/actions/TemplateEmailListener.java 2005-02-18 13:42:39 UTC (rev 270) @@ -21,6 +21,7 @@ import com.arsdigita.formbuilder.PersistentProcessListener; import com.arsdigita.formbuilder.util.Placeholders; +import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.event.FormProcessListener; import com.arsdigita.bebop.event.FormSectionEvent; @@ -151,16 +152,18 @@ public void process(FormSectionEvent e) throws FormProcessException { - Placeholders p = new Placeholders(e.getPageState(), - e.getFormData()); + FormData data = e.getFormData(); - String from; - User user = (User) Kernel.getContext().getParty(); - if( null == user ) { - from = "notloggedin@" + - Web.getConfig().getServer().getName(); - } else { - from = user.getPrimaryEmail().getEmailAddress(); + Placeholders p = new Placeholders(getForm(), data); + + String from = (String) p.interpolate("::user.email::"); + if (null == from) { + User user = (User) Kernel.getContext().getParty(); + if( null == user ) { + from = Mail.getConfig().getDefaultFrom(); + } else { + from = user.getPrimaryEmail().getEmailAddress(); + } } String subject = p.interpolate(m_subject); Modified: ccm-core/trunk/src/com/arsdigita/formbuilder/actions/XMLEmailListener.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/formbuilder/actions/XMLEmailListener.java 2005-02-18 13:21:09 UTC (rev 269) +++ ccm-core/trunk/src/com/arsdigita/formbuilder/actions/XMLEmailListener.java 2005-02-18 13:42:39 UTC (rev 270) @@ -163,15 +163,15 @@ public void process(FormSectionEvent e) throws FormProcessException { - Placeholders p = new Placeholders(e.getPageState(), e.getFormData()); + Placeholders p = new Placeholders(getForm(), e.getFormData()); + String to = p.interpolate(m_to); String subject = p.interpolate(m_subject); String from; User user = (User)Kernel.getContext().getParty(); if( null == user ) { - from = "notloggedin@" + - Web.getConfig().getServer().getName(); + from = Mail.getConfig().getDefaultFrom(); } else { from = user.getPrimaryEmail().getEmailAddress(); } Modified: ccm-core/trunk/src/com/arsdigita/formbuilder/ui/FormbuilderResources.properties =================================================================== --- ccm-core/trunk/src/com/arsdigita/formbuilder/ui/FormbuilderResources.properties 2005-02-18 13:21:09 UTC (rev 269) +++ ccm-core/trunk/src/com/arsdigita/formbuilder/ui/FormbuilderResources.properties 2005-02-18 13:42:39 UTC (rev 270) @@ -18,9 +18,12 @@ formbuilder.ui.editors.description=Description: formbuilder.ui.editors.to=To: formbuilder.ui.editors.label=Widget Variable Label: +formbuilder.ui.editors.UserEmailLabel=Widget Label: formbuilder.ui.editors.height=Height: formbuilder.ui.editors.data_type=Data type: formbuilder.ui.editors.answer_required=Answer Required: +formbuilder.ui.editors.textfieldmsg=Leave these fields blank unless you want to select a maximum number of characters a user can fill in. If you want more space than 3 lines of space for the customer to answer in change enter the number of lines you want in the "width" box. +formbuilder.ui.editors.textareamsg=Leave these fields blank unless you want to select a maximum number of characters a user can fill in. formbuilder.ui.manage_questions_of_a_form=Manage Questions of a Form formbuilder.ui.label_to_be_ignored=label to be ignored formbuilder.ui.select_widget=Select Widget Modified: ccm-core/trunk/src/com/arsdigita/formbuilder/ui/PlaceholdersInitListener.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/formbuilder/ui/PlaceholdersInitListener.java 2005-02-18 13:21:09 UTC (rev 269) +++ ccm-core/trunk/src/com/arsdigita/formbuilder/ui/PlaceholdersInitListener.java 2005-02-18 13:42:39 UTC (rev 270) @@ -36,16 +36,12 @@ Form f = (Form)e.getSource(); - Placeholders placeholders = getPlaceholders(e.getPageState()); + Placeholders placeholders = new Placeholders(); PlaceholdersTraversal t = new PlaceholdersTraversal(placeholders, e.getPageState()); t.preorder(f); } - protected Placeholders getPlaceholders(PageState state) { - return new Placeholders(state); - } - private class PlaceholdersTraversal extends Traversal { Placeholders m_placeholders; PageState m_state; Added: ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/EmailFieldForm.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/EmailFieldForm.java 2005-02-18 13:21:09 UTC (rev 269) +++ ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/EmailFieldForm.java 2005-02-18 13:42:39 UTC (rev 270) @@ -0,0 +1,144 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * This class is newly created to give support for user email field.. + * @author Shubham nagar + * @company Infoaxon Technology + * @date 13-12-2004 + */ + +package com.arsdigita.formbuilder.ui.editors; + +import com.arsdigita.formbuilder.PersistentEmailField; +import com.arsdigita.formbuilder.PersistentWidget; +import com.arsdigita.formbuilder.parameters.PersistentParameterListener; +import com.arsdigita.formbuilder.util.GlobalizationUtil; + +import com.arsdigita.bebop.ColumnPanel; +import com.arsdigita.bebop.FormData; +import com.arsdigita.bebop.FormProcessException; +import com.arsdigita.bebop.FormSection; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.Page; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.SingleSelectionModel; +import com.arsdigita.bebop.event.FormSectionEvent; +import com.arsdigita.bebop.form.TextField; +import com.arsdigita.bebop.parameters.IntegerParameter; +import com.arsdigita.bebop.parameters.NotNullValidationListener; +import com.arsdigita.bebop.parameters.ParameterModel; +import com.arsdigita.bebop.parameters.StringParameter; + +import java.math.BigDecimal; +import java.util.Iterator; + +import org.apache.log4j.Logger; + +public class EmailFieldForm extends WidgetLabelForm { + private static final Logger s_log = Logger.getLogger(EmailFieldForm.class); + private TextField m_width; + private SingleSelectionModel m_control; + + public EmailFieldForm(String name, + SingleSelectionModel form, + SingleSelectionModel control) { + super(name, form, control); + m_control = control; + } + + protected void addWidgets(FormSection section) { + super.addWidgets(section); + //Add code to add a message label for textarea dimension + m_width = new TextField(new IntegerParameter("width")); + m_width.setSize(5); + //m_width.addValidationListener(new NotNullValidationListener()); + section.add(new Label(GlobalizationUtil.globalize("formbuilder.ui.editors.width")), ColumnPanel.RIGHT); + section.add(m_width); + } + + protected PersistentWidget getWidget() { + return new PersistentEmailField(); + } + + protected PersistentWidget getWidget(BigDecimal id) { + return new PersistentEmailField(id); + } + + protected void addName(FormSection section) { + TextField name = new TextField(new StringParameter(NAME)); + name.setSize(50); + section.add(name); + + m_name = name; + } + + protected void automaticallySetName(ParameterModel model) { } + + protected String getName(PageState ps, FormData data) { + return "::user.email::"; + } + + protected void initWidgets(FormSectionEvent e, + PersistentWidget w) + throws FormProcessException { + super.initWidgets(e, w); + PersistentEmailField widget = (PersistentEmailField)w; + PageState state = e.getPageState(); + + if (widget == null) { + m_width.setValue(state, ""); + } + else { + if(widget.getSize()==0) { + m_width.setValue(state, ""); + } else { + m_width.setValue(state, new Integer(widget.getSize())); + } + } + } + + protected void processWidgets(FormSectionEvent e, + PersistentWidget w) + throws FormProcessException { + super.processWidgets(e, w); + + String listenerClassNameEmail = + "com.arsdigita.bebop.parameters.EmailValidationListener"; + PersistentParameterListener listenerEmail = + new PersistentParameterListener(listenerClassNameEmail); + w.addValidationListener(listenerEmail); + } + + /** + * This determines whether or not the "required value" radio group + * is part of the form. This returns true and should be overridden + * by fields where it does not make sense to ask. For instance, + * when the widget is a hidden field then asking if it is required + * or not does not make any logical sense so those widgets should + * return false. + * + * This will always return the same value for a given widget no matter + * what state the widget is in. + */ + protected boolean includeRequiredRadioGroup() { + return false; + } + + public void register(Page p) { + super.register(p); + + p.setVisibleDefault(m_name, false); + } +} Property changes on: ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/EmailFieldForm.java ___________________________________________________________________ Name: svn:keywords + "Id Author DateTime" Modified: ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/HeadingForm.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/HeadingForm.java 2005-02-18 13:21:09 UTC (rev 269) +++ ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/HeadingForm.java 2005-02-18 13:42:39 UTC (rev 270) @@ -15,27 +15,33 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + * Revision: + * Method : getTextWidget() + * Description : New htmlarea component is created inside a textarea. */ + package com.arsdigita.formbuilder.ui.editors; +import com.arsdigita.formbuilder.PersistentHeading; +import com.arsdigita.formbuilder.PersistentText; +import com.arsdigita.formbuilder.util.GlobalizationUtil ; -import com.arsdigita.formbuilder.util.GlobalizationUtil ; import com.arsdigita.bebop.SingleSelectionModel; -import com.arsdigita.bebop.form.TextField; +import com.arsdigita.bebop.form.TextArea; +import com.arsdigita.bebop.form.DHTMLEditor; import com.arsdigita.bebop.parameters.StringParameter; -import com.arsdigita.domain.DataObjectNotFoundException; -import com.arsdigita.formbuilder.PersistentHeading; -import com.arsdigita.formbuilder.PersistentText; import com.arsdigita.bebop.form.Widget; import com.arsdigita.globalization.GlobalizedMessage; + import java.math.BigDecimal; - /** * This is the form used to create a persistent heading element */ public class HeadingForm extends TextForm { + public static final String TEXT_ENTRY = "text_entry"; + public HeadingForm(String name, SingleSelectionModel form, SingleSelectionModel control) { @@ -47,9 +53,13 @@ * can provides subclasses with the ability to use any size desired */ protected Widget getTextWidget(StringParameter parameter) { - TextField field = new TextField(parameter); - field.setSize(40); - return field; + //Create htmlarea component inside textarea + TextArea m_textWidget = new DHTMLEditor(TEXT_ENTRY); + m_textWidget.setRows(25); + m_textWidget.setCols(70); + m_textWidget.setWrap(DHTMLEditor.SOFT); + + return m_textWidget; } /** @@ -65,8 +75,7 @@ return new PersistentHeading(); } - protected PersistentText getPersistentText(BigDecimal id) - throws DataObjectNotFoundException { + protected PersistentText getPersistentText(BigDecimal id) { return new PersistentHeading(id); } } Modified: ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/TemplateEmailForm.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/TemplateEmailForm.java 2005-02-18 13:21:09 UTC (rev 269) +++ ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/TemplateEmailForm.java 2005-02-18 13:42:39 UTC (rev 270) @@ -101,7 +101,7 @@ m_controls = new SingleSelect("controls"); m_controls.addOption(new Option("", "Select a control")); - m_controls.setOnChange("if(this.value.length>0) document.getElementById('templatedEmailBody').value+='::form.'+this.value+'::';"); + m_controls.setOnChange("if(this.value.length>0) document.getElementById('templatedEmailBody').value+=this.value;"); try { m_controls.addPrintListener(new PrintListener() { public void prepare(PrintEvent ev) { @@ -115,6 +115,8 @@ new OID( PersistentFormSection.BASE_DATA_OBJECT_TYPE, formID ); + m_controls.addOption(new Option("::user.email::", "Email address"), ps); + PersistentFormSection form = (PersistentFormSection) DomainObjectFactory.newInstance( formOID ); @@ -126,7 +128,11 @@ if( c instanceof PersistentWidget ) { PersistentWidget w = (PersistentWidget) c; - m_controls.addOption(new Option(w.getParameterName(), w.getParameterName()), ps); + if (!"::user.email::".equals(w.getParameterName())) { + String parameter = "::form." + + w.getParameterName() + "::"; + m_controls.addOption(new Option(parameter, w.getParameterName()), ps); + } } } } @@ -188,4 +194,8 @@ l.setSubject(subject); l.setBody(body); } + + protected boolean showName() { + return false; + } } Modified: ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/TextAreaForm.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/TextAreaForm.java 2005-02-18 13:21:09 UTC (rev 269) +++ ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/TextAreaForm.java 2005-02-18 13:42:39 UTC (rev 270) @@ -1,55 +1,52 @@ /* - * Copyright (C) 2002-2004 Red Hat Inc. All Rights Reserved. - * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. - * + * * This library 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 * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + * Revision: + * Method : addWidgets() + * Description : Message Label added for textarea dimensions. + * NullValidationListener disabled for width and height of the control to make the attributes + * optional. + * Method : processWidgets() + * Description : Set the default value of width and height as 0 which would be replaced by the XSL ont the frontend */ + package com.arsdigita.formbuilder.ui.editors; - import com.arsdigita.formbuilder.util.GlobalizationUtil ; - - +import com.arsdigita.bebop.ColumnPanel; import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormProcessException; import com.arsdigita.bebop.FormSection; import com.arsdigita.bebop.Label; import com.arsdigita.bebop.PageState; - +import com.arsdigita.bebop.SingleSelectionModel; import com.arsdigita.bebop.event.FormSectionEvent; - import com.arsdigita.bebop.form.TextArea; import com.arsdigita.bebop.form.TextField; - import com.arsdigita.bebop.parameters.IntegerParameter; +import com.arsdigita.bebop.parameters.NotNullValidationListener; +import com.arsdigita.bebop.parameters.NumberInRangeValidationListener; import com.arsdigita.bebop.parameters.StringParameter; - import com.arsdigita.domain.DataObjectNotFoundException; import com.arsdigita.formbuilder.PersistentTextArea; +import com.arsdigita.formbuilder.PersistentWidget; - import java.math.BigDecimal; -import com.arsdigita.bebop.SingleSelectionModel; -import com.arsdigita.formbuilder.PersistentWidget; -import com.arsdigita.bebop.parameters.NotNullValidationListener; -import com.arsdigita.bebop.parameters.NumberInRangeValidationListener; -import com.arsdigita.bebop.ColumnPanel; - public class TextAreaForm extends WidgetLabelForm { private TextField m_width; private TextField m_height; @@ -66,14 +63,16 @@ m_width = new TextField(new IntegerParameter("width")); m_width.setSize(5); - m_width.addValidationListener(new NotNullValidationListener()); + //m_width.addValidationListener(new NotNullValidationListener()); //m_width.addValidationListener(new NumberInRangeValidationListener(1, 70)); + section.add(new Label(GlobalizationUtil.globalize("formbuilder.ui.editors.textareamsg")), ColumnPanel.RIGHT); + section.add(new Label("")); section.add(new Label(GlobalizationUtil.globalize("formbuilder.ui.editors.width")), ColumnPanel.RIGHT); section.add(m_width); m_height = new TextField(new IntegerParameter("height")); m_height.setSize(5); - m_height.addValidationListener(new NotNullValidationListener()); + //m_height.addValidationListener(new NotNullValidationListener()); m_height.addValidationListener(new NumberInRangeValidationListener(1, 70)); section.add(new Label(GlobalizationUtil.globalize("formbuilder.ui.editors.height")), ColumnPanel.RIGHT); section.add(m_height); @@ -108,9 +107,20 @@ m_width.setValue(state, ""); m_height.setValue(state, ""); m_value.setValue(state, ""); - } else { - m_width.setValue(state, new Integer(widget.getCols())); - m_height.setValue(state, new Integer(widget.getRows())); + } + else { + if(widget.getCols()==0) { + m_width.setValue(state, ""); + } + else{ + m_width.setValue(state, new Integer(widget.getCols())); + } + if(widget.getRows()==0) { + m_height.setValue(state, ""); + } + else{ + m_height.setValue(state, new Integer(widget.getRows())); + } m_value.setValue(state, widget.getDefaultValue()); } } @@ -119,17 +129,22 @@ PersistentWidget w) throws FormProcessException { super.processWidgets(e, w); - + //set the default width and height to 0 PersistentTextArea widget = (PersistentTextArea)w; FormData data = e.getFormData(); - - Integer width = (Integer)data.get("width"); - Integer height = (Integer)data.get("height"); + Integer width = new Integer(0); + Integer height = new Integer(0); + if(data.get("width")!=null) { + width = (Integer)data.get("width"); + } + if(data.get("height")!=null) { + height = (Integer)data.get("height"); + } + String value = (String)data.get("value"); - widget.setCols(width.intValue()); - widget.setRows(height.intValue()); + widget.setRows(height.intValue()); widget.setDefaultValue(value); } } Modified: ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/TextFieldForm.java =================================================================== --- ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/TextFieldForm.java 2005-02-18 13:21:09 UTC (rev 269) +++ ccm-core/trunk/src/com/arsdigita/formbuilder/ui/editors/TextFieldForm.java 2005-02-18 13:42:39 UTC (rev 270) @@ -16,44 +16,32 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ + package com.arsdigita.formbuilder.ui.editors; - -import com.arsdigita.formbuilder.util.GlobalizationUtil ; - - +import com.arsdigita.formbuilder.PersistentTextField; +import com.arsdigita.formbuilder.PersistentWidget; +import com.arsdigita.formbuilder.parameters.PersistentParameterListener; import com.arsdigita.formbuilder.parameters.TextValidationListener; +import com.arsdigita.formbuilder.util.GlobalizationUtil ; +import com.arsdigita.bebop.ColumnPanel; import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormProcessException; .. |