mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
- Year field in date picker is now configurable
- Text field length is configurable - Text area controls can now be used and configured git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3443 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
|
@@ -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";
|
||||
|
@@ -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";
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -1743,6 +1743,31 @@
|
||||
<managed-bean-name>TextFieldGenerator</managed-bean-name>
|
||||
<managed-bean-class>org.alfresco.web.bean.generator.TextFieldGenerator</managed-bean-class>
|
||||
<managed-bean-scope>request</managed-bean-scope>
|
||||
<!--
|
||||
<managed-property>
|
||||
<property-name>size</property-name>
|
||||
<value>35</value>
|
||||
</managed-property>
|
||||
-->
|
||||
</managed-bean>
|
||||
|
||||
<managed-bean>
|
||||
<description>
|
||||
Bean that generates a text area component
|
||||
</description>
|
||||
<managed-bean-name>TextAreaGenerator</managed-bean-name>
|
||||
<managed-bean-class>org.alfresco.web.bean.generator.TextAreaGenerator</managed-bean-class>
|
||||
<managed-bean-scope>request</managed-bean-scope>
|
||||
<!--
|
||||
<managed-property>
|
||||
<property-name>rows</property-name>
|
||||
<value>3</value>
|
||||
</managed-property>
|
||||
<managed-property>
|
||||
<property-name>columns</property-name>
|
||||
<value>32</value>
|
||||
</managed-property>
|
||||
-->
|
||||
</managed-bean>
|
||||
|
||||
<managed-bean>
|
||||
@@ -1761,6 +1786,16 @@
|
||||
<managed-bean-name>DatePickerGenerator</managed-bean-name>
|
||||
<managed-bean-class>org.alfresco.web.bean.generator.DatePickerGenerator</managed-bean-class>
|
||||
<managed-bean-scope>request</managed-bean-scope>
|
||||
<!--
|
||||
<managed-property>
|
||||
<property-name>startYear</property-name>
|
||||
<value>2008</value>
|
||||
</managed-property>
|
||||
<managed-property>
|
||||
<property-name>yearCount</property-name>
|
||||
<value>30</value>
|
||||
</managed-property>
|
||||
-->
|
||||
</managed-bean>
|
||||
|
||||
<managed-bean>
|
||||
@@ -1770,6 +1805,16 @@
|
||||
<managed-bean-name>DateTimePickerGenerator</managed-bean-name>
|
||||
<managed-bean-class>org.alfresco.web.bean.generator.DateTimePickerGenerator</managed-bean-class>
|
||||
<managed-bean-scope>request</managed-bean-scope>
|
||||
<!--
|
||||
<managed-property>
|
||||
<property-name>startYear</property-name>
|
||||
<value>2008</value>
|
||||
</managed-property>
|
||||
<managed-property>
|
||||
<property-name>yearCount</property-name>
|
||||
<value>30</value>
|
||||
</managed-property>
|
||||
-->
|
||||
</managed-bean>
|
||||
|
||||
<managed-bean>
|
||||
|
@@ -286,35 +286,35 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left:8px"><h:outputText value="#{msg.title}" id="title" />:</td><td><h:inputText value="#{AdvancedSearchBean.title}" size="28" maxlength="1024" id="txtTitle" /></td>
|
||||
<td style="padding-left:8px"><h:outputText value="#{msg.title}" id="title" />:</td><td><h:inputText value="#{AdvancedSearchBean.title}" size="#{TextFieldGenerator.size}" maxlength="1024" id="txtTitle" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left:8px"><h:outputText value="#{msg.description}" id="desc" />:</td><td><h:inputText value="#{AdvancedSearchBean.description}" size="28" maxlength="1024" id="txtDesc" /></td>
|
||||
<td style="padding-left:8px"><h:outputText value="#{msg.description}" id="desc" />:</td><td><h:inputText value="#{AdvancedSearchBean.description}" size="#{TextFieldGenerator.size}" maxlength="1024" id="txtDesc" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left:8px"><h:outputText value="#{msg.author}" id="author" />:</td><td><h:inputText value="#{AdvancedSearchBean.author}" size="28" maxlength="1024" id="txtAuthor" /></td>
|
||||
<td style="padding-left:8px"><h:outputText value="#{msg.author}" id="author" />:</td><td><h:inputText value="#{AdvancedSearchBean.author}" size="#{TextFieldGenerator.size}" maxlength="1024" id="txtAuthor" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table cellpadding="1" cellspacing="0" border="0">
|
||||
<tr><td colspan=2 class="paddingRow"></td></tr>
|
||||
<tr><td colspan="2" class="paddingRow"></td></tr>
|
||||
<tr>
|
||||
<td colspan=2><h:selectBooleanCheckbox value="#{AdvancedSearchBean.modifiedDateChecked}" id="chkModDate" /><span style="vertical-align:20%"><h:outputText value="#{msg.modified_date}" id="modDate" />:</span></td>
|
||||
<td colspan="2"><h:selectBooleanCheckbox value="#{AdvancedSearchBean.modifiedDateChecked}" id="chkModDate" /><span style="vertical-align:20%"><h:outputText value="#{msg.modified_date}" id="modDate" />:</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left:8px"><h:outputText value="#{msg.from}" id="modDateFrom" />:</td><td><a:inputDatePicker value="#{AdvancedSearchBean.modifiedDateFrom}" yearCount="30" id="dateModFrom" /></td>
|
||||
<td style="padding-left:8px"><h:outputText value="#{msg.from}" id="modDateFrom" />:</td><td><a:inputDatePicker value="#{AdvancedSearchBean.modifiedDateFrom}" yearCount="#{DatePickerGenerator.yearCount}" startYear="#{DatePickerGenerator.startYear}" id="dateModFrom" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left:8px"><h:outputText value="#{msg.to}" id="modDateTo" />:</td><td><a:inputDatePicker value="#{AdvancedSearchBean.modifiedDateTo}" yearCount="30" id="dateModTo" /><td>
|
||||
<td style="padding-left:8px"><h:outputText value="#{msg.to}" id="modDateTo" />:</td><td><a:inputDatePicker value="#{AdvancedSearchBean.modifiedDateTo}" yearCount="#{DatePickerGenerator.yearCount}" startYear="#{DatePickerGenerator.startYear}" id="dateModTo" /></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan=2><h:selectBooleanCheckbox value="#{AdvancedSearchBean.createdDateChecked}" id="chkCreateDate" /><span style="vertical-align:20%"><h:outputText value="#{msg.created_date}" id="createDate" />:</span></td>
|
||||
<td colspan="2"><h:selectBooleanCheckbox value="#{AdvancedSearchBean.createdDateChecked}" id="chkCreateDate" /><span style="vertical-align:20%"><h:outputText value="#{msg.created_date}" id="createDate" />:</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left:8px"><h:outputText value="#{msg.from}" id="createDateFrom" />:</td><td><a:inputDatePicker value="#{AdvancedSearchBean.createdDateFrom}" yearCount="30" id="dateCreatedFrom" /></td>
|
||||
<td style="padding-left:8px"><h:outputText value="#{msg.from}" id="createDateFrom" />:</td><td><a:inputDatePicker value="#{AdvancedSearchBean.createdDateFrom}" yearCount="#{DatePickerGenerator.yearCount}" startYear="#{DatePickerGenerator.startYear}" id="dateCreatedFrom" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding-left:8px"><h:outputText value="#{msg.to}" id="createDateTo" />:</td><td><a:inputDatePicker value="#{AdvancedSearchBean.createdDateTo}" yearCount="30" id="dateCreatedTo" /><td>
|
||||
<td style="padding-left:8px"><h:outputText value="#{msg.to}" id="createDateTo" />:</td><td><a:inputDatePicker value="#{AdvancedSearchBean.createdDateTo}" yearCount="#{DatePickerGenerator.yearCount}" startYear="#{DatePickerGenerator.startYear}" id="dateCreatedTo" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div style="padding:4px"></div>
|
||||
|
Reference in New Issue
Block a user