[richfaces-svn-commits] JBoss Rich Faces SVN: r324 - in trunk/richfaces/suggestionbox/src/main/java/org/richfaces: renderkit/html and 1 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Mon Apr 9 10:59:06 EDT 2007
Author: A.Skokov
Date: 2007-04-09 10:59:05 -0400 (Mon, 09 Apr 2007)
New Revision: 324
Modified:
trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/AjaxSuggestionEvent.java
trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/SuggestionEvent.java
trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java
trunk/richfaces/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
trunk/richfaces/suggestionbox/src/main/java/org/richfaces/taglib/SuggestionBoxTagHandler.java
Log:
checkstyle refactoring
Modified: trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/AjaxSuggestionEvent.java
===================================================================
--- trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/AjaxSuggestionEvent.java 2007-04-09 14:42:34 UTC (rev 323)
+++ trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/AjaxSuggestionEvent.java 2007-04-09 14:59:05 UTC (rev 324)
@@ -21,51 +21,61 @@
package org.richfaces.component;
+import org.ajax4jsf.framework.ajax.AjaxEvent;
+
import javax.faces.component.UIComponent;
-import org.ajax4jsf.framework.ajax.AjaxEvent;
-
+/**
+ * Ajax event for SuggestionBox component.
+ */
public class AjaxSuggestionEvent extends AjaxEvent {
/**
- *
- */
- private static final long serialVersionUID = 9212067213575185754L;
- /**
- *
+ * Serial Version UID.
*/
- private Object _submittedValue;
+ private static final long serialVersionUID = 9212067213575185754L;
/**
- * @param component
- * @param submittedValie
+ * Submitted value.
*/
- public AjaxSuggestionEvent(UIComponent component, Object submittedValue) {
+ private Object submittedValue;
+
+ /**
+ * Constructor.
+ *
+ * @param component {@link javax.faces.component.UIComponent}
+ * @param value The submitted value to set
+ */
+ public AjaxSuggestionEvent(final UIComponent component,
+ final Object value) {
super(component);
- // TODO Auto-generated constructor stub
- this._submittedValue = submittedValue;
+ this.submittedValue = value;
}
/**
- * @param component
+ * Constructor.
+ *
+ * @param component {@link javax.faces.component.UIComponent}
*/
- public AjaxSuggestionEvent(UIComponent component) {
+ public AjaxSuggestionEvent(final UIComponent component) {
super(component);
- // TODO Auto-generated constructor stub
}
/**
+ * Gets submitted value.
+ *
* @return Returns the submittedValie.
*/
- public Object getSubmittedValue() {
- return this._submittedValue;
+ public final Object getSubmittedValue() {
+ return this.submittedValue;
}
/**
- * @param submittedValie The submittedValie to set.
+ * Sets submitted value.
+ *
+ * @param value The submitted value to set.
*/
- public void setSubmittedValue(Object submittedValue) {
- this._submittedValue = submittedValue;
+ public final void setSubmittedValue(final Object value) {
+ this.submittedValue = value;
}
-
-}
\ No newline at end of file
+}
Modified: trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/SuggestionEvent.java
===================================================================
--- trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/SuggestionEvent.java 2007-04-09 14:42:34 UTC (rev 323)
+++ trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/SuggestionEvent.java 2007-04-09 14:59:05 UTC (rev 324)
@@ -23,47 +23,52 @@
import javax.faces.component.UIComponent;
+/**
+ * Event implementation for SuggestionBox component.
+ */
public class SuggestionEvent extends javax.faces.event.ActionEvent {
/**
- *
+ * Serial Version UID.
*/
private static final long serialVersionUID = 3192468135298986660L;
+
/**
- *
+ * Submitted value.
*/
- private Object _submittedValue;
+ private Object submittedValue;
/**
- * @param component
- * @param submittedValie
+ * Constructor.
+ *
+ * @param component {@link javax.faces.component.UIComponent}
+ * @param value The submitted value to set
*/
- public SuggestionEvent(UIComponent component, Object submittedValue) {
+ public SuggestionEvent(final UIComponent component, final Object value) {
super(component);
- // TODO Auto-generated constructor stub
- this._submittedValue = submittedValue;
+ this.submittedValue = value;
}
/**
- * @param component
+ * Constructor.
+ *
+ * @param component {@link javax.faces.component.UIComponent}
*/
- public SuggestionEvent(UIComponent component) {
+ public SuggestionEvent(final UIComponent component) {
super(component);
- // TODO Auto-generated constructor stub
}
/**
* @return Returns the submittedValie.
*/
- public Object getSubmittedValue() {
- return this._submittedValue;
+ public final Object getSubmittedValue() {
+ return this.submittedValue;
}
/**
- * @param submittedValie The submittedValie to set.
+ * @param value The submittedValie to set.
*/
- public void setSubmittedValue(Object submittedValue) {
- this._submittedValue = submittedValue;
+ public final void setSubmittedValue(final Object value) {
+ this.submittedValue = value;
}
-
-}
\ No newline at end of file
+}
Modified: trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java
===================================================================
--- trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java 2007-04-09 14:42:34 UTC (rev 323)
+++ trunk/richfaces/suggestionbox/src/main/java/org/richfaces/component/UISuggestionBox.java 2007-04-09 14:59:05 UTC (rev 324)
@@ -40,85 +40,235 @@
/**
+ * UI implementation for SuggestionBox component.
+ *
* @author shura (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.5 $ $Date: 2007/03/01 22:37:50 $
*/
-public abstract class UISuggestionBox extends UIData implements AjaxComponent, AjaxSource {
+public abstract class UISuggestionBox extends UIData
+ implements AjaxComponent, AjaxSource {
+ /**
+ * Log for component.
+ */
private static Log log = LogFactory.getLog(UISuggestionBox.class);
+ /**
+ * Component type.
+ */
private static final String COMPONENT_TYPE = "org.richfaces.SuggestionBox";
- private static final String COMPONENT_FAMILY = "org.richfaces.SuggestionBox";
+ /**
+ * Component family.
+ */
+ private static final String COMPONENT_FAMILY =
+ "org.richfaces.SuggestionBox";
-
+ /**
+ * TRUE if submitted.
+ */
private transient boolean submitted = false;
+ /**
+ * Getter for for attribute.
+ *
+ * id (or full path of id's) of target components, for which this element
+ * must provide support.
+ * If a target component inside of the same <code>NamingContainer<code>
+ * (UIForm, UIData in base implementstions), can be simple value of the
+ * "id" attribute.
+ * For other cases must include id's of <code>NamingContainer<code>
+ * components, separated by ':'. For search from the root of components,
+ * must be started with ':'.
+ *
+ * @return for value from local variable or value bindings
+ */
public abstract String getFor();
- public abstract void setFor(String __for);
+ /**
+ * Setter for attribute.
+ *
+ * @param f identifier
+ */
+ public abstract void setFor(String f);
+ /**
+ * Getter for suggestionAction.
+ *
+ * Method calls an expression to get a collection of suggestion data
+ * on request. It must have one parameter with a type of Object with
+ * content of input component and must return any type allowed for
+ * <h:datatable>;
+ *
+ * @return suggestionAction value from local variable or value bindings
+ */
public abstract MethodBinding getSuggestionAction();
+ /**
+ * Setter for suggestionAction.
+ *
+ * @param action {@link javax.faces.el.MethodBinding}
+ */
public abstract void setSuggestionAction(MethodBinding action);
+ /**
+ * Getter for converter.
+ * Id of Converter to be used or reference to a Converter.
+ *
+ * @return converter value from local variable or value bindings
+ */
public abstract Converter getConverter();
+ /**
+ * Setter for converter.
+ *
+ * @param converter {@link javax.faces.convert.Converter}
+ */
public abstract void setConverter(Converter converter);
/**
- * @return
+ * Getter for rowClasses.
+ *
+ * @return rowClasses value from local variable or value bindings
*/
public abstract String getRowClasses();
+ /**
+ * Getter for rowClasses.
+ *
+ * @param rowClasses row classes
+ */
public abstract void setRowClasses(String rowClasses);
/**
- * @return
+ * Getter for selectValueClass.
+ *
+ * Name of the CSS class for a hidden suggestion entry
+ * element (table cell)
+ *
+ * @return selectValueClass value from local variable or value bindings
*/
public abstract String getSelectValueClass();
+ /**
+ * Setter for selectValueClass.
+ *
+ * @param value class
+ */
public abstract void setSelectValueClass(String value);
/**
- * @return
+ * Getter for border.
+ *
+ * This attributes specifies the width (in pixels only) of the frame around a table
+ *
+ * @return border value from local variable or value bindings
*/
public abstract String getBorder();
-//
- public abstract void setCellpadding(String value);
+ /**
+ * Setter for border.
+ *
+ * @param value of border
+ */
+ public abstract void setBorder(String value);
+ /**
+ * Getter for cellpadding.
+ *
+ * This attribute specifies the amount of space between the
+ * border of the cell and its contents. If the value of
+ * this attribute is a pixel length, all four margins
+ * should be this distance from the contents. If the value
+ * of the attribute is percentage length, the top and
+ * bottom margins should be equally separated from the
+ * content based on percentage of the available vertical
+ * space, and the left and right margins should be equally
+ * separated from the content based on percentage of the
+ * available horizontal space
+ */
public abstract String getCellpadding();
- public abstract void setBorder(String value);
+ /**
+ * Setter for cellpadding.
+ *
+ * @param value of cellpadding
+ */
+ public abstract void setCellpadding(String value);
+ /**
+ * Getter for immediate.
+ *
+ * @return immediate value from local variable or value bindings
+ */
public abstract boolean isImmediate();
+ /**
+ * Getter for immediate.
+ *
+ * @param value of immediate
+ */
public abstract void setImmediate(boolean value);
+ /**
+ * Getter for selfRendered.
+ *
+ * If true, forces active Ajax region render response
+ * directly from stored components tree, bypasses page
+ * processing. Can be used for increase performance. Also,
+ * must be set to 'true' inside iteration components, such
+ * as dataTable
+ *
+ * @return selfRendered value from local variable or value bindings
+ */
+
public abstract boolean isSelfRendered();
+ /**
+ * Getter for selfRendered.
+ *
+ * @param value for attribute
+ */
public abstract void setSelfRendered(boolean value);
/**
- * @return
+ * Getter for entryClass.
+ *
+ * Name of the CSS class for a suggestion entry element (table row)
+ *
+ * @return entryClass value from local variable or value bindings
*/
public abstract String getEntryClass();
+ /**
+ * Setter for entryClass.
+ *
+ * @param value of entry class
+ */
public abstract void setEntryClass(String value);
+ /**
+ * Getter for submitted.
+ *
+ * @return TRUE if submited
+ */
public boolean isSubmitted() {
return submitted;
}
- public void setSubmitted(boolean submitted) {
- this.submitted = submitted;
+ /**
+ * Setter for submitted.
+ *
+ * @param s of entry class
+ */
+ public void setSubmitted(boolean s) {
+ this.submitted = s;
}
/* (non-Javadoc)
* @see javax.faces.component.UIComponentBase#queueEvent(javax.faces.event.FacesEvent)
*/
- public void queueEvent(FacesEvent event) {
+ public final void queueEvent(final FacesEvent event) {
if (event instanceof SuggestionEvent) {
if (isImmediate()) {
event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);
@@ -133,17 +283,19 @@
/* (non-Javadoc)
- * @see javax.faces.component.UIData#broadcast(javax.faces.event.FacesEvent)
- */
- public void broadcast(FacesEvent event) throws AbortProcessingException {
+ * @see javax.faces.component.UIData#broadcast(javax.faces.event.FacesEvent)
+ */
+ public final void broadcast(final FacesEvent event)
+ throws AbortProcessingException {
super.broadcast(event);
if (event instanceof SuggestionEvent) {
SuggestionEvent suggestionEvent = (SuggestionEvent) event;
- Object value = suggestionEvent.getSubmittedValue();
+ Object value = suggestionEvent.getSubmittedValue();
MethodBinding suggestingAction = getSuggestionAction();
- if (null != suggestingAction ) {
+ if (null != suggestingAction) {
// TODO - use converter
- setValue(suggestingAction.invoke(getFacesContext(), new Object[]{value}));
+ setValue(suggestingAction.invoke(
+ getFacesContext(), new Object[]{value}));
getFacesContext().renderResponse();
}
} else if (event instanceof AjaxEvent) {
@@ -152,22 +304,21 @@
AjaxRendererUtils.addRegionByName(context, this, this.getId());
setSubmitted(true);
if (isSelfRendered()) {
- AjaxContext.getCurrentInstance(context).renderSubmittedAjaxRegion(context, true);
+ AjaxContext.getCurrentInstance(context)
+ .renderSubmittedAjaxRegion(context, true);
}
}
}
- public void addAjaxListener(AjaxListener listener) {
- addFacesListener(listener);
- }
+ public void addAjaxListener(final AjaxListener listener) {
+ addFacesListener(listener);
+ }
- public AjaxListener[] getAjaxListeners() {
- return (AjaxListener[]) getFacesListeners(AjaxListener.class);
- }
+ public AjaxListener[] getAjaxListeners() {
+ return (AjaxListener[]) getFacesListeners(AjaxListener.class);
+ }
- public void removeAjaxListener(AjaxListener listener) {
- removeFacesListener(listener);
- }
-
-
+ public void removeAjaxListener(final AjaxListener listener) {
+ removeFacesListener(listener);
+ }
}
Modified: trunk/richfaces/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java
===================================================================
--- trunk/richfaces/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2007-04-09 14:42:34 UTC (rev 323)
+++ trunk/richfaces/suggestionbox/src/main/java/org/richfaces/renderkit/html/SuggestionBoxRenderer.java 2007-04-09 14:59:05 UTC (rev 324)
@@ -22,7 +22,6 @@
package org.richfaces.renderkit.html;
import org.ajax4jsf.framework.ajax.AjaxContext;
-import org.ajax4jsf.framework.ajax.AjaxEvent;
import org.ajax4jsf.framework.renderer.AjaxComponentRendererBase;
import org.ajax4jsf.framework.renderer.AjaxRendererUtils;
import org.ajax4jsf.framework.renderer.RendererBase;
@@ -55,49 +54,84 @@
import java.util.Map;
import java.util.regex.Pattern;
+/**
+ * Renderer for SuggestionBox component.
+ */
public class SuggestionBoxRenderer extends AjaxComponentRendererBase {
-
+ /**
+ * Component options.
+ */
private static final String[] OPTIONS = {"popupClass", "popupStyle",
"width", "height", "entryClass", "selectedClass", "param",
"frequency", "minChars", "tokens", "rows"};
+ /**
+ * Shadow depth.
+ */
public static final int SHADOW_DEPTH = 4;
+ /**
+ * Styles.
+ */
private InternetResource[] styles = {new TemplateCSSResource(
"org/richfaces/renderkit/html/css/suggestionbox.xcss")};
+ /**
+ * Additional scripts.
+ */
private final InternetResource[] additionalScripts = {
- new org.ajax4jsf.framework.resource.PrototypeScript(),
- new org.ajax4jsf.framework.resource.SmartPositionScript(),
- getResource("/org/richfaces/renderkit/html/scripts/browser_info.js"),
- getResource("scripts/scriptaculo.js"),
- getResource("scripts/suggestionbox.js")};
+ new org.ajax4jsf.framework.resource.PrototypeScript(),
+ new org.ajax4jsf.framework.resource.SmartPositionScript(),
+ getResource("/org/richfaces/renderkit/html/scripts/browser_info.js"),
+ getResource("scripts/scriptaculo.js"),
+ getResource("scripts/suggestionbox.js")};
+ /**
+ * Template for table.
+ */
private PreparedTemplate body = HtmlCompiler
- .compileResource("org/richfaces/renderkit/html/templates/table.jspx");
+ .compileResource("org/richfaces/renderkit/html/templates/table.jspx");
+ /**
+ * Template for popup.
+ */
private PreparedTemplate popup = HtmlCompiler
- .compileResource("org/richfaces/renderkit/html/templates/popup.jspx");
+ .compileResource("org/richfaces/renderkit/html/templates/popup.jspx");
- protected Class getComponentClass() {
+ /**
+ * Gets component class.
+ *
+ * @return component class
+ */
+ protected final Class getComponentClass() {
return UISuggestionBox.class;
}
- public boolean getRendersChildren() {
+ /**
+ * Is render children.
+ *
+ * @return boolean
+ */
+ public final boolean getRendersChildren() {
return true;
}
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.renderer.RendererBase#doDecode(javax.faces.context.FacesContext,
- * javax.faces.component.UIComponent)
- */
- protected void doDecode(FacesContext context, UIComponent component) {
+ /**
+ * Decode.
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ *
+ * @see org.ajax4jsf.framework.renderer.RendererBase#doDecode(
+ * javax.faces.context.FacesContext,
+ * javax.faces.component.UIComponent)
+ */
+ protected final void doDecode(final FacesContext context,
+ final UIComponent component) {
String clientId = component.getClientId(context);
Map requestParameterMap = context.getExternalContext()
- .getRequestParameterMap();
- String reqValue = (String) requestParameterMap.get(clientId);
+ .getRequestParameterMap();
+ String reqValue = (String) requestParameterMap.get(clientId);
if (reqValue != null && reqValue.equals(clientId)) {
String paramName = (String) component.getAttributes().get("param");
if (null == paramName) {
@@ -106,17 +140,43 @@
Object elementValue = requestParameterMap.get(paramName);
FacesEvent event = new SuggestionEvent(component, elementValue);
component.queueEvent(event);
- component.queueEvent(new AjaxSuggestionEvent(component, elementValue));
+ component.queueEvent(
+ new AjaxSuggestionEvent(component, elementValue));
}
}
- protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+ /**
+ * Encode begin.
+ *
+ * @param writer {@link javax.faces.context.ResponseWriter}
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @throws IOException
+ *
+ * @see {@link org.ajax4jsf.framework.renderer.RendererBase#doEncodeBegin}
+ */
+ protected final void doEncodeBegin(final ResponseWriter writer,
+ final FacesContext context,
+ final UIComponent component)
+ throws IOException {
super.doEncodeBegin(writer, context, component);
- org.richfaces.component.util.FormUtil.throwEnclFormReqExceptionIfNeed(context, component);
+ org.richfaces.component.util.FormUtil.throwEnclFormReqExceptionIfNeed(
+ context, component);
}
- protected void doEncodeEnd(ResponseWriter writer, FacesContext context,
- UIComponent component) throws IOException {
+ /**
+ * Encode end.
+ *
+ * @param writer {@link javax.faces.context.ResponseWriter}
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @throws IOException
+ *
+ * @see {@link org.ajax4jsf.framework.renderer.RendererBase#doEncodeEnd}
+ */
+ protected void doEncodeEnd(final ResponseWriter writer,
+ final FacesContext context,
+ final UIComponent component) throws IOException {
UISuggestionBox suggestionBox = (UISuggestionBox) component;
if (!suggestionBox.isSubmitted()) {
suggestionBox.setRowIndex(-1);
@@ -124,7 +184,8 @@
getUtils().encodeId(context, component);
Map attributes = component.getAttributes();
- StringBuffer clazz = new StringBuffer("dr-sb-common-container rich-sb-common-container");
+ StringBuffer clazz = new StringBuffer(
+ "dr-sb-common-container rich-sb-common-container");
Object popupClass = attributes.get("popupClass");
if (null != popupClass) {
clazz.append(" ").append(popupClass);
@@ -156,11 +217,12 @@
writer.endElement(HTML.DIV_ELEM);
writer.startElement("iframe", component);
writer.writeAttribute("src",
- getResource("/org/richfaces/renderkit/html/images/spacer.gif")
- .getUri(context, null), null);
+ getResource("/org/richfaces/renderkit/html/images/spacer.gif")
+ .getUri(context, null), null);
writer.writeAttribute("id", component.getClientId(context)
+ "_iframe", null);
- writer.writeAttribute("style", "position:absolute;display:none;z-index:0;", null);
+ writer.writeAttribute(
+ "style", "position:absolute;display:none;z-index:0;", null);
writer.endElement("iframe");
} else {
suggestionBox.setSubmitted(false);
@@ -170,13 +232,17 @@
((UISuggestionBox) component).setValue(null);
}
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.render.Renderer#encodeChildren(javax.faces.context.FacesContext,
- * javax.faces.component.UIComponent)
- */
- public void encodeChildren(FacesContext context, UIComponent component)
+ /**
+ * Encode children.
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @throws IOException
+ *
+ * @see javax.faces.render.Renderer#encodeChildren
+ */
+ public void encodeChildren(final FacesContext context,
+ final UIComponent component)
throws IOException {
UISuggestionBox suggestionBox = (UISuggestionBox) component;
if (suggestionBox.isSubmitted()) {
@@ -189,8 +255,13 @@
}
}
- private UIComponent getTarget(UIComponent component)
- throws FacesException {
+ /**
+ * Gets component.
+ *
+ * @param component {@link javax.faces.component.UIComponent}
+ * @return component
+ */
+ private UIComponent getTarget(final UIComponent component) {
String target = ((UISuggestionBox) component).getFor();
if (null != target) {
// Use parent since UIData - naming container
@@ -208,7 +279,15 @@
}
}
- private String getScript(FacesContext context, UIComponent component) {
+ /**
+ * Gets script.
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @return script
+ */
+ private String getScript(final FacesContext context,
+ final UIComponent component) {
Map attributes = component.getAttributes();
StringBuffer script = new StringBuffer(" new ");
// Build ajax function call
@@ -251,7 +330,15 @@
return script.toString();
}
- private TemplateContext getTemplateContext(FacesContext context, UIData data) {
+ /**
+ * Gets template.
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param data
+ * @return {@link org.ajax4jsf.framework.renderer.compiler.TemplateContext}
+ */
+ private TemplateContext getTemplateContext(final FacesContext context,
+ final UIData data) {
data.setRowIndex(-1);
return new DataTemplateContext(this, context, data);
}
@@ -267,27 +354,30 @@
private List columns;
- private int _first;
+ private int first;
- private int _last;
+ private int last;
- private int _rows;
+ private int rows;
- private int _rowCount;
+ private int rowCount;
- private int _current;
+ private int current;
- private String[] _rowClasses = new String[0];
+ private String[] rowClasses = new String[0];
- private String _entryClass;
+ private String entryClass;
/**
- * @param renderer
- * @param facesContext
- * @param component
+ * Constructor.
+ *
+ * @param renderer {@link org.ajax4jsf.framework.renderer.RendererBase}
+ * @param facesContext {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
*/
- public DataTemplateContext(RendererBase renderer,
- FacesContext facesContext, UIComponent component) {
+ public DataTemplateContext(final RendererBase renderer,
+ final FacesContext facesContext,
+ final UIComponent component) {
super(renderer, facesContext, component);
if (component.getFacet("head") != null) {
this.putParameter("hasHead", Boolean.TRUE);
@@ -314,49 +404,50 @@
}
// fill rows counters
UISuggestionBox box = (UISuggestionBox) component;
- this._first = box.getFirst();
- this._rows = box.getRows();
- this._rowCount = box.getRowCount();
+ this.first = box.getFirst();
+ this.rows = box.getRows();
+ this.rowCount = box.getRowCount();
// return all records; CH-1330
- if (_rows <= 0 || true) {
- _rows = _rowCount - _first;
+ if (rows <= 0 || true) {
+ rows = rowCount - first;
}
- _last = _first + _rows;
- if (_last > _rowCount) {
- _last = _rowCount;
+ last = first + rows;
+ if (last > rowCount) {
+ last = rowCount;
}
- _current = _first;
+ current = first;
// rows classes
- _entryClass = box.getEntryClass();
+ entryClass = box.getEntryClass();
String rowClasses = box.getRowClasses();
if (null != rowClasses && rowClasses.length() > 0) {
- _rowClasses = rowClasses.split("\\s+");
+ this.rowClasses = rowClasses.split("\\s+");
}
}
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.renderer.compiler.TemplateContext#getParameter(java.lang.Object)
- */
+ /**
+ * Gets parameter.
+ *
+ * @param key parameter key
+ * @return parameter
+ */
public Object getParameter(Object key) {
if ("rows".equals(key)) {
// Iterate over rows in datatable
return new Iterator() {
public boolean hasNext() {
- if (_current >= _last) {
+ if (current >= last) {
return false;
}
UIData data = ((UIData) getComponent());
- data.setRowIndex(_current);
+ data.setRowIndex(current);
return data.isRowAvailable();
}
public Object next() {
// TODO reset rows and columns classes counters
- _current++;
+ current++;
return getComponent();
}
@@ -369,18 +460,19 @@
} else if ("rowClass".equals(key)) {
// Build row class string from entryClass and row classes
StringBuffer rowClass = new StringBuffer();
- if (null != _entryClass) {
- rowClass.append(_entryClass);
- if (_rowClasses.length > 0) {
+ if (null != entryClass) {
+ rowClass.append(entryClass);
+ if (rowClasses.length > 0) {
rowClass.append(" ");
}
}
- if (_rowClasses.length > 0) {
- int currentClass = (_current - _first - 1)
- % _rowClasses.length;
- if (currentClass < 0)
+ if (rowClasses.length > 0) {
+ int currentClass = (current - first - 1)
+ % rowClasses.length;
+ if (currentClass < 0) {
currentClass = 0;
- rowClass.append(_rowClasses[currentClass]);
+ }
+ rowClass.append(rowClasses[currentClass]);
}
// for iterate over columns
return rowClass.toString();
@@ -393,10 +485,17 @@
return super.getParameter(key);
}
}
-
}
- public String opacityStyle(FacesContext context, UIComponent component) {
+ /**
+ * Gets opacity style.
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @return style
+ */
+ public final String opacityStyle(final FacesContext context,
+ final UIComponent component) {
String opacity = (String) component.getAttributes().get("shadowOpacity");
String filterOpacity;
@@ -412,65 +511,89 @@
// illegal opacity
return ";";
}
- return "opacity:" + opacity + "; filter:alpha(opacity=" + filterOpacity + ");";
+ return "opacity:" + opacity
+ + "; filter:alpha(opacity=" + filterOpacity + ");";
}
- public String border(FacesContext context, UIComponent component) {
+ /**
+ * Gets border style.
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @return style
+ */
+ public final String border(final FacesContext context,
+ final UIComponent component) {
String border = (String) component.getAttributes().get("border");
String frame = (String) component.getAttributes().get("frame");
- if (null == frame)
+ if (null == frame) {
frame = "box";
+ }
StringBuffer stringBuffer = new StringBuffer();
- if (null != border && Pattern.matches("\\d*", border))
+ if (null != border && Pattern.matches("\\d*", border)) {
border += "px";
- /*
- * if (null == border || !Pattern.matches("\\d*px", border)) { Skin skin =
- * SkinFactory.getInstance().getSkin(context); border = (String)
- * skin.getParameter(context, "suggestionbox.borderWidth"); }
- */
+ }
boolean top = false, right = false, bottom = false, left = false;
- if (frame.equalsIgnoreCase("above"))
+ if (frame.equalsIgnoreCase("above")) {
top = true;
// else if (frame.equalsIgnoreCase("border") |
// frame.equalsIgnoreCase("box")) top=right=bottom=left=true;
- else if (frame.equalsIgnoreCase("below"))
+ } else if (frame.equalsIgnoreCase("below")) {
bottom = true;
- else if (frame.equalsIgnoreCase("hsides"))
- top = bottom = true;
- else if (frame.equalsIgnoreCase("lhs"))
+ } else if (frame.equalsIgnoreCase("hsides")) {
+ top = true;
+ bottom = true;
+ } else if (frame.equalsIgnoreCase("lhs")) {
left = true;
- else if (frame.equalsIgnoreCase("rhs"))
+ } else if (frame.equalsIgnoreCase("rhs")) {
right = true;
- else if (frame.equalsIgnoreCase("vsides"))
- right = left = true;
- else
- top = right = bottom = left = true;
+ } else if (frame.equalsIgnoreCase("vsides")) {
+ right = true;
+ left = true;
+ } else {
+ top = true;
+ right = true;
+ bottom = true;
+ left = true;
+ }
stringBuffer.append("; border-width:");
- if (top)
+ if (top) {
stringBuffer.append(" ").append(border).append(" ");
- else
+ } else {
stringBuffer.append(" 0px ");
- if (right)
+ }
+ if (right) {
stringBuffer.append(" ").append(border).append(" ");
- else
+ } else {
stringBuffer.append(" 0px ");
- if (bottom)
+ }
+ if (bottom) {
stringBuffer.append(" ").append(border).append(" ");
- else
+ } else {
stringBuffer.append(" 0px ");
- if (left)
+ }
+ if (left) {
stringBuffer.append(" ").append(border).append(" ");
- else
+ } else {
stringBuffer.append(" 0px ");
+ }
stringBuffer.append(";");
return stringBuffer.toString();
}
- public String bgcolor(FacesContext context, UIComponent component) {
+ /**
+ * Gets background-color style.
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @return background-color style
+ */
+ public final String bgcolor(final FacesContext context,
+ final UIComponent component) {
String bgcolor = (String) component.getAttributes().get("bgcolor");
if (bgcolor != null) {
return "background-color: " + bgcolor + ";";
@@ -478,20 +601,45 @@
return ";";
}
- public String cellPadding(FacesContext context, UIComponent component) {
- UISuggestionBox box = (UISuggestionBox)component;
- String cp = box.getCellpadding();
+ /**
+ * Gets cellpadding style.
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @return cellpadding style
+ */
+ public final String cellPadding(final FacesContext context,
+ final UIComponent component) {
+ UISuggestionBox box = (UISuggestionBox) component;
+ String cp = box.getCellpadding();
if (cp != null) {
return "padding: " + getUtils().encodePctOrPx(cp) + ";";
}
return ";";
}
- public String getContentId(FacesContext context, UIComponent component) {
- return component.getClientId(context) + NamingContainer.SEPARATOR_CHAR + "suggest";
+ /**
+ * Gets context identifier.
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @return context identifier
+ */
+ public final String getContentId(final FacesContext context,
+ final UIComponent component) {
+ return component.getClientId(context)
+ + NamingContainer.SEPARATOR_CHAR + "suggest";
}
- public String overflowSize(FacesContext context, UIComponent component) {
+ /**
+ * Gets overflow sizes.
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @return overflow style
+ */
+ public final String overflowSize(final FacesContext context,
+ final UIComponent component) {
StringBuffer style = new StringBuffer();
style.append(getSizeForStyle(component, "width", null, true));
@@ -500,8 +648,15 @@
return style.toString();
}
-
- public String shadowDepth(FacesContext context, UIComponent component) {
+ /**
+ * Gets shadow style.
+ *
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param component {@link javax.faces.component.UIComponent}
+ * @return shadow style
+ */
+ public final String shadowDepth(final FacesContext context,
+ final UIComponent component) {
String shadow = (String) component.getAttributes().get("shadowDepth");
if (shadow == null) {
shadow = Integer.toString(SHADOW_DEPTH);
@@ -510,27 +665,38 @@
return "top: " + shadow + "; left: " + shadow;
}
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.renderer.AjaxComponentRendererBase#getAdditionalScripts()
- */
- protected InternetResource[] getAdditionalScripts() {
- // TODO Auto-generated method stub
+ /**
+ * Gets additional scripts.
+ *
+ * @return array of resources
+ * {@link org.ajax4jsf.framework.resource.InternetResource}
+ */
+ protected final InternetResource[] getAdditionalScripts() {
return additionalScripts;
}
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.framework.renderer.HeaderResourcesRendererBase#getStyles()
- */
- protected InternetResource[] getStyles() {
- // TODO Auto-generated method stub
+ /**
+ * Gets styles.
+ *
+ * @return array of styles
+ * {@link org.ajax4jsf.framework.resource.InternetResource}
+ */
+ protected final InternetResource[] getStyles() {
return styles;
}
- private String getSizeForStyle(UIComponent component, String attr, String def, boolean isShadow) {
+ /**
+ * Gets style for width & height.
+ * @param component {@link javax.faces.component.UIComponent}
+ * @param attr attribute
+ * @param def default value
+ * @param isShadow TRUE if shadow exists
+ * @return style
+ */
+ private String getSizeForStyle(final UIComponent component,
+ final String attr,
+ final String def,
+ final boolean isShadow) {
Map attributes = component.getAttributes();
StringBuffer style = new StringBuffer();
@@ -541,7 +707,8 @@
if (attribute != null) {
if (isShadow) {
- attribute = String.valueOf(Integer.parseInt(attribute) - SHADOW_DEPTH);
+ attribute = String.valueOf(Integer.parseInt(attribute)
+ - SHADOW_DEPTH);
}
style.append(attr).append(":").append(attribute);
Modified: trunk/richfaces/suggestionbox/src/main/java/org/richfaces/taglib/SuggestionBoxTagHandler.java
===================================================================
--- trunk/richfaces/suggestionbox/src/main/java/org/richfaces/taglib/SuggestionBoxTagHandler.java 2007-04-09 14:42:34 UTC (rev 323)
+++ trunk/richfaces/suggestionbox/src/main/java/org/richfaces/taglib/SuggestionBoxTagHandler.java 2007-04-09 14:59:05 UTC (rev 324)
@@ -1,85 +1,143 @@
+/**
+ * License Agreement.
+ *
+ * Ajax4jsf 1.1 - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
package org.richfaces.taglib;
-import java.lang.String;
-import javax.faces.convert.Converter;
-import java.lang.Object;
-import javax.faces.el.MethodBinding;
-import com.sun.facelets.tag.jsf.ComponentHandler;
-import javax.faces.component.UIComponent;
+import com.sun.facelets.FaceletContext;
+import com.sun.facelets.el.LegacyMethodBinding;
+import com.sun.facelets.tag.MetaRule;
+import com.sun.facelets.tag.MetaRuleset;
+import com.sun.facelets.tag.Metadata;
+import com.sun.facelets.tag.MetadataTarget;
+import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.jsf.ComponentConfig;
import org.richfaces.component.UISuggestionBox;
-import com.sun.facelets.tag.jsf.ComponentHandler;
-import com.sun.facelets.tag.jsf.ComponentConfig;
-import com.sun.facelets.*;
-import com.sun.facelets.el.*;
-import com.sun.facelets.tag.*;
-
/**
+ * Component tag handler for Facelets.
+ *
* @author shura (latest modification by $Author: ishabalov $)
* @version $Revision: 1.1.2.4 $ $Date: 2007/02/20 20:58:03 $
- *
*/
-public class SuggestionBoxTagHandler extends
- com.sun.facelets.tag.jsf.ComponentHandler {
+public class SuggestionBoxTagHandler
+ extends com.sun.facelets.tag.jsf.ComponentHandler {
- private static final SuggestionBoxTagHandlerMetaRule metaRule = new SuggestionBoxTagHandlerMetaRule();
+ /**
+ * Meta rule for tag handler.
+ */
+ private static final SuggestionBoxTagHandlerMetaRule metaRule =
+ new SuggestionBoxTagHandlerMetaRule();
- public SuggestionBoxTagHandler(ComponentConfig config) {
- super(config);
- }
+ /**
+ * Constructor.
+ *
+ * @param config {@link com.sun.facelets.tag.jsf.ComponentConfig}
+ */
+ public SuggestionBoxTagHandler(final ComponentConfig config) {
+ super(config);
+ }
- // Metarule
- protected MetaRuleset createMetaRuleset(Class type) {
- MetaRuleset m = super.createMetaRuleset(type);
- m.addRule(metaRule);
- return m;
- }
+ /**
+ * Creates metarules.
+ *
+ * @param type Class
+ * @return {@link com.sun.facelets.tag.MetaRuleset}
+ */
+ protected final MetaRuleset createMetaRuleset(final Class type) {
+ MetaRuleset m = super.createMetaRuleset(type);
+ m.addRule(metaRule);
+ return m;
+ }
- /**
- * @author shura (latest modification by $Author: ishabalov $)
- * @version $Revision: 1.1.2.4 $ $Date: 2007/02/20 20:58:03 $
- *
- */
- static class SuggestionBoxTagHandlerMetaRule extends MetaRule {
+ /**
+ * Meta rule implementation.
+ *
+ * @author shura (latest modification by $Author: ishabalov $)
+ * @version $Revision: 1.1.2.4 $ $Date: 2007/02/20 20:58:03 $
+ */
+ static class SuggestionBoxTagHandlerMetaRule extends MetaRule {
- /* (non-Javadoc)
- * @see com.sun.facelets.tag.MetaRule#applyRule(java.lang.String, com.sun.facelets.tag.TagAttribute, com.sun.facelets.tag.MetadataTarget)
- */
- public Metadata applyRule(String name, TagAttribute attribute,
- MetadataTarget meta) {
- if (meta.isTargetInstanceOf(UISuggestionBox.class)) {
- if ("suggestionAction".equals(name)) {
- return new suggestionActionMapper(attribute);
- }
+ /**
+ * Apply rule.
+ *
+ * @param name rule name
+ * @param attribute {@link com.sun.facelets.tag.TagAttribute}
+ * @param meta {@link com.sun.facelets.tag.TagAttribute}
+ * @return metadata {@link com.sun.facelets.tag.Metadata}
+ *
+ * @see {@link com.sun.facelets.tag.MetaRule#applyRule(String,
+ * com.sun.facelets.tag.TagAttribute,
+ * com.sun.facelets.tag.MetadataTarget)}
+ */
+ public Metadata applyRule(final String name,
+ final TagAttribute attribute,
+ final MetadataTarget meta) {
+ if (meta.isTargetInstanceOf(UISuggestionBox.class)) {
+ if ("suggestionAction".equals(name)) {
+ return new SuggestionActionMapper(attribute);
+ }
- }
- return null;
- }
+ }
+ return null;
+ }
+ }
- }
+ /**
+ * Meta data implementation.
+ */
+ static class SuggestionActionMapper extends Metadata {
+ /**
+ * Signature.
+ */
+ private static final Class[] SIGNATURE =
+ new Class[]{java.lang.Object.class};
- static class suggestionActionMapper extends Metadata {
+ /**
+ * Action attribute.
+ */
+ private final TagAttribute action;
- private static final Class[] SIGNATURE = new Class[] { java.lang.Object.class };
+ /**
+ * Sets attribute.
+ *
+ * @param attribute {@link com.sun.facelets.tag.TagAttribute}
+ */
+ public SuggestionActionMapper(final TagAttribute attribute) {
+ action = attribute;
+ }
- private final TagAttribute _action;
+ /**
+ * Apply metadata.
- /**
- * @param attribute
- */
- public suggestionActionMapper(TagAttribute attribute) {
- _action = attribute;
- }
-
- /* (non-Javadoc)
- * @see com.sun.facelets.tag.Metadata#applyMetadata(com.sun.facelets.FaceletContext, java.lang.Object)
- */
- public void applyMetadata(FaceletContext ctx, Object instance) {
- ((UISuggestionBox) instance)
- .setSuggestionAction(new LegacyMethodBinding(this._action
- .getMethodExpression(ctx, null, SIGNATURE)));
- }
-
- }
-
+ * @param context {@link javax.faces.context.FacesContext}
+ * @param instance {@link java.lang.Object}
+ *
+ * @see {@link com.sun.facelets.tag.Metadata#applyMetadata(
+ * com.sun.facelets.FaceletContext, Object)}
+ */
+ public void applyMetadata(final FaceletContext context,
+ final Object instance) {
+ ((UISuggestionBox) instance)
+ .setSuggestionAction(new LegacyMethodBinding(this.action
+ .getMethodExpression(context, null, SIGNATURE)));
+ }
+ }
}
More information about the richfaces-svn-commits
mailing list