diff --git a/source/java/org/alfresco/web/bean/generator/DatePickerGenerator.java b/source/java/org/alfresco/web/bean/generator/DatePickerGenerator.java index f0068f32e5..5a2e3badd5 100644 --- a/source/java/org/alfresco/web/bean/generator/DatePickerGenerator.java +++ b/source/java/org/alfresco/web/bean/generator/DatePickerGenerator.java @@ -1,5 +1,7 @@ package org.alfresco.web.bean.generator; +import java.util.Date; + import javax.faces.component.UIComponent; import javax.faces.component.UIOutput; import javax.faces.context.FacesContext; @@ -21,8 +23,43 @@ import org.alfresco.web.ui.repo.component.property.UIPropertySheet; */ public class DatePickerGenerator extends BaseComponentGenerator { + private int yearCount = 30; + private int startYear = new Date().getYear() + 1900 + 2; + private static final String MSG_DATE = "date_pattern"; + /** + * @return Returns the year to start counting back from + */ + public int getStartYear() + { + return startYear; + } + + /** + * @param startYear Sets the year to start counting back from + */ + public void setStartYear(int startYear) + { + this.startYear = startYear; + } + + /** + * @return Returns the number of years to show + */ + public int getYearCount() + { + return yearCount; + } + + /** + * @param yearCount Sets the number of years to show + */ + public void setYearCount(int yearCount) + { + this.yearCount = yearCount; + } + @SuppressWarnings("unchecked") public UIComponent generate(FacesContext context, String id) { @@ -30,7 +67,8 @@ public class DatePickerGenerator extends BaseComponentGenerator createComponent(ComponentConstants.JAVAX_FACES_INPUT); component.setRendererType(RepoConstants.ALFRESCO_FACES_DATE_PICKER_RENDERER); FacesHelper.setupComponentId(context, component, id); - component.getAttributes().put("yearCount", new Integer(30)); + component.getAttributes().put("startYear", this.startYear); + component.getAttributes().put("yearCount", this.yearCount); component.getAttributes().put("style", "margin-right: 7px;"); return component; diff --git a/source/java/org/alfresco/web/bean/generator/TextAreaGenerator.java b/source/java/org/alfresco/web/bean/generator/TextAreaGenerator.java new file mode 100644 index 0000000000..7a2af9bc09 --- /dev/null +++ b/source/java/org/alfresco/web/bean/generator/TextAreaGenerator.java @@ -0,0 +1,64 @@ +package org.alfresco.web.bean.generator; + +import javax.faces.component.UIComponent; +import javax.faces.context.FacesContext; + +import org.alfresco.web.app.servlet.FacesHelper; +import org.alfresco.web.ui.common.ComponentConstants; + +/** + * Generates a text field component. + * + * @author gavinc + */ +public class TextAreaGenerator extends TextFieldGenerator +{ + private int rows = 3; + private int columns = 32; + + /** + * @return Returns the number of columns + */ + public int getColumns() + { + return columns; + } + + /** + * @param columns Sets the number of columns + */ + public void setColumns(int columns) + { + this.columns = columns; + } + + /** + * @return Returns the number of rows + */ + public int getRows() + { + return rows; + } + + /** + * @param rows Sets the number of rows + */ + public void setRows(int rows) + { + this.rows = rows; + } + + @SuppressWarnings("unchecked") + public UIComponent generate(FacesContext context, String id) + { + UIComponent component = context.getApplication(). + createComponent(ComponentConstants.JAVAX_FACES_INPUT); + component.setRendererType(ComponentConstants.JAVAX_FACES_TEXTAREA); + FacesHelper.setupComponentId(context, component, id); + + component.getAttributes().put("rows", this.rows); + component.getAttributes().put("cols", this.columns); + + return component; + } +} diff --git a/source/java/org/alfresco/web/bean/generator/TextFieldGenerator.java b/source/java/org/alfresco/web/bean/generator/TextFieldGenerator.java index cef4447498..4a84e10f44 100644 --- a/source/java/org/alfresco/web/bean/generator/TextFieldGenerator.java +++ b/source/java/org/alfresco/web/bean/generator/TextFieldGenerator.java @@ -26,6 +26,41 @@ import org.alfresco.web.ui.repo.component.property.UIPropertySheet; */ public class TextFieldGenerator extends BaseComponentGenerator { + private int size = 35; + private int maxLength = 1024; + + /** + * @return Returns the default size for a text field + */ + public int getSize() + { + return size; + } + + /** + * @param size Sets the size of a text field + */ + public void setSize(int size) + { + this.size = size; + } + + /** + * @return Returns the max length for the text field + */ + public int getMaxLength() + { + return maxLength; + } + + /** + * @param maxLength Sets the max length of the text field + */ + public void setMaxLength(int maxLength) + { + this.maxLength = maxLength; + } + @SuppressWarnings("unchecked") public UIComponent generate(FacesContext context, String id) { @@ -33,8 +68,9 @@ public class TextFieldGenerator extends BaseComponentGenerator createComponent(ComponentConstants.JAVAX_FACES_INPUT); component.setRendererType(ComponentConstants.JAVAX_FACES_TEXT); FacesHelper.setupComponentId(context, component, id); - component.getAttributes().put("size", "35"); - component.getAttributes().put("maxlength", "1024"); + + component.getAttributes().put("size", this.size); + component.getAttributes().put("maxlength", this.maxLength); return component; } diff --git a/source/java/org/alfresco/web/ui/common/ComponentConstants.java b/source/java/org/alfresco/web/ui/common/ComponentConstants.java index 6b3508a7ea..4f7e6d3d1b 100644 --- a/source/java/org/alfresco/web/ui/common/ComponentConstants.java +++ b/source/java/org/alfresco/web/ui/common/ComponentConstants.java @@ -23,6 +23,7 @@ public final class ComponentConstants { public static final String JAVAX_FACES_INPUT = "javax.faces.Input"; public static final String JAVAX_FACES_TEXT = "javax.faces.Text"; + public static final String JAVAX_FACES_TEXTAREA = "javax.faces.Textarea"; public static final String JAVAX_FACES_OUTPUT = "javax.faces.Output"; public static final String JAVAX_FACES_GRID = "javax.faces.Grid"; public static final String JAVAX_FACES_PANEL = "javax.faces.Panel"; diff --git a/source/java/org/alfresco/web/ui/repo/RepoConstants.java b/source/java/org/alfresco/web/ui/repo/RepoConstants.java index c2f2597d0d..7382c89772 100644 --- a/source/java/org/alfresco/web/ui/repo/RepoConstants.java +++ b/source/java/org/alfresco/web/ui/repo/RepoConstants.java @@ -43,6 +43,7 @@ public final class RepoConstants public static final String GENERATOR_LABEL = "LabelGenerator"; public static final String GENERATOR_TEXT_FIELD = "TextFieldGenerator"; + public static final String GENERATOR_TEXT_AREA = "TextAreaGenerator"; public static final String GENERATOR_CHECKBOX = "CheckboxGenerator"; public static final String GENERATOR_DATE_PICKER = "DatePickerGenerator"; public static final String GENERATOR_DATETIME_PICKER = "DateTimePickerGenerator"; diff --git a/source/java/org/alfresco/web/ui/repo/component/UISearchCustomProperties.java b/source/java/org/alfresco/web/ui/repo/component/UISearchCustomProperties.java index b45916ab67..fc085b9029 100644 --- a/source/java/org/alfresco/web/ui/repo/component/UISearchCustomProperties.java +++ b/source/java/org/alfresco/web/ui/repo/component/UISearchCustomProperties.java @@ -78,6 +78,7 @@ public class UISearchCustomProperties extends SelfRenderingComponent implements /** * @see javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext) */ + @SuppressWarnings("unchecked") public void encodeBegin(FacesContext context) throws IOException { if (isRendered() == false) @@ -133,6 +134,7 @@ public class UISearchCustomProperties extends SelfRenderingComponent implements * * @param context FacesContext */ + @SuppressWarnings("unchecked") private void createComponentsFromConfig(FacesContext context) { DictionaryService dd = Repository.getServiceRegistry(context).getDictionaryService(); @@ -236,6 +238,7 @@ public class UISearchCustomProperties extends SelfRenderingComponent implements * * @return UIComponent */ + @SuppressWarnings("unchecked") private UIComponent generateControl(FacesContext context, PropertyDefinition propDef, String displayLabel, String beanBinding) { UIComponent control = null; @@ -265,6 +268,22 @@ public class UISearchCustomProperties extends SelfRenderingComponent implements { Boolean showTime = Boolean.valueOf(typeName.equals(DataTypeDefinition.DATETIME)); + // create value bindings for the start year and year count attributes + ValueBinding startYearBind = null; + ValueBinding yearCountBind = null; + + if (showTime) + { + startYearBind = facesApp.createValueBinding("#{DateTimePickerGenerator.startYear}"); + yearCountBind = facesApp.createValueBinding("#{DateTimePickerGenerator.yearCount}"); + } + else + { + startYearBind = facesApp.createValueBinding("#{DatePickerGenerator.startYear}"); + yearCountBind = facesApp.createValueBinding("#{DatePickerGenerator.yearCount}"); + } + + // Need to output component for From and To date selectors and labels // also neeed checkbox for enable/disable state - requires an outer wrapper component control = (UIPanel)facesApp.createComponent(ComponentConstants.JAVAX_FACES_PANEL); @@ -298,7 +317,8 @@ public class UISearchCustomProperties extends SelfRenderingComponent implements UIInput inputFromDate = (UIInput)facesApp.createComponent(ComponentConstants.JAVAX_FACES_INPUT); inputFromDate.setId(context.getViewRoot().createUniqueId()); inputFromDate.setRendererType(RepoConstants.ALFRESCO_FACES_DATE_PICKER_RENDERER); - inputFromDate.getAttributes().put("yearCount", new Integer(30)); + inputFromDate.setValueBinding("startYear", startYearBind); + inputFromDate.setValueBinding("yearCount", yearCountBind); inputFromDate.getAttributes().put("showTime", showTime); ValueBinding vbFromDate = facesApp.createValueBinding( "#{" + beanBinding + "[\"" + PREFIX_DATE_FROM + propDef.getName().toString() + "\"]}"); @@ -316,7 +336,8 @@ public class UISearchCustomProperties extends SelfRenderingComponent implements UIInput inputToDate = (UIInput)facesApp.createComponent(ComponentConstants.JAVAX_FACES_INPUT); inputToDate.setId(context.getViewRoot().createUniqueId()); inputToDate.setRendererType(RepoConstants.ALFRESCO_FACES_DATE_PICKER_RENDERER); - inputToDate.getAttributes().put("yearCount", new Integer(30)); + inputToDate.setValueBinding("startYear", startYearBind); + inputToDate.setValueBinding("yearCount", yearCountBind); inputToDate.getAttributes().put("showTime", showTime); ValueBinding vbToDate = facesApp.createValueBinding( "#{" + beanBinding + "[\"" + PREFIX_DATE_TO + propDef.getName().toString() + "\"]}"); @@ -333,8 +354,8 @@ public class UISearchCustomProperties extends SelfRenderingComponent implements // any other type is represented as an input text field control = (UIInput)facesApp.createComponent(ComponentConstants.JAVAX_FACES_INPUT); control.setRendererType(ComponentConstants.JAVAX_FACES_TEXT); - control.getAttributes().put("size", "28"); - control.getAttributes().put("maxlength", "1024"); + control.setValueBinding("size", facesApp.createValueBinding("#{TextFieldGenerator.size}")); + control.setValueBinding("maxlength", facesApp.createValueBinding("#{TextFieldGenerator.maxLength}")); control.setValueBinding(VALUE, vb); } diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml index ca8f971e75..4a5e2a1ac6 100644 --- a/source/web/WEB-INF/faces-config-beans.xml +++ b/source/web/WEB-INF/faces-config-beans.xml @@ -1743,6 +1743,31 @@ TextFieldGenerator org.alfresco.web.bean.generator.TextFieldGenerator request + + + + + + Bean that generates a text area component + + TextAreaGenerator + org.alfresco.web.bean.generator.TextAreaGenerator + request + @@ -1761,6 +1786,16 @@ DatePickerGenerator org.alfresco.web.bean.generator.DatePickerGenerator request + @@ -1770,6 +1805,16 @@ DateTimePickerGenerator org.alfresco.web.bean.generator.DateTimePickerGenerator request + diff --git a/source/web/jsp/dialog/advanced-search.jsp b/source/web/jsp/dialog/advanced-search.jsp index 0e45054bbb..ff72a049a9 100644 --- a/source/web/jsp/dialog/advanced-search.jsp +++ b/source/web/jsp/dialog/advanced-search.jsp @@ -286,35 +286,35 @@ - : + : - : + : - : + : - + - + - + - - + - + -
::
::
: + :
::
::
: + :