mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user