Author: andrei_exadel
Date: 2007-12-10 11:45:34 -0500 (Mon, 10 Dec 2007)
New Revision: 4665
Modified:
trunk/sandbox/ui/columns/src/main/java/org/richfaces/taglib/html/facelets/ColumnsHandler.java
Log:
RF-1201 refactoring
Modified:
trunk/sandbox/ui/columns/src/main/java/org/richfaces/taglib/html/facelets/ColumnsHandler.java
===================================================================
---
trunk/sandbox/ui/columns/src/main/java/org/richfaces/taglib/html/facelets/ColumnsHandler.java 2007-12-10
16:25:41 UTC (rev 4664)
+++
trunk/sandbox/ui/columns/src/main/java/org/richfaces/taglib/html/facelets/ColumnsHandler.java 2007-12-10
16:45:34 UTC (rev 4665)
@@ -30,7 +30,6 @@
import com.sun.facelets.tag.jsf.ComponentConfig;
import com.sun.facelets.tag.jsf.ComponentHandler;
-
/**
* TODO Class description goes here.
*
@@ -50,7 +49,7 @@
/** index attribute */
private TagAttribute index;
-
+
/** rendered attribute */
private TagAttribute rendered;
@@ -88,9 +87,7 @@
*/
public ColumnsHandler(ComponentConfig config) {
super(config);
- this.value = getAttribute("value");
- this.var = getAttribute("var");
- this.index = getAttribute("index");
+
}
/**
@@ -112,6 +109,8 @@
initVariables(ctx);
try {
+
+ this.value = getAttribute("value");
// produce the right sort of ForEachIterator
if (value != null) {
@@ -125,7 +124,7 @@
.supportedTypeForEachIterator(rawItems);
} else {
// no 'items', so use 'begin' and 'end'
- items = SimpleForEachIterator.beginEndForEachIterator(_end);
+ items = SimpleForEachIterator.beginEndForEachIterator(_end - 1);
}
} catch (Exception e) {
// TODO: handle exception
@@ -173,9 +172,10 @@
* Extracts integer value from end attr
*/
private void initEnd(FaceletContext ctx) {
+ this.end = getAttribute("end");
if (end != null) {
try {
- _end = (Integer) end.getObject(ctx);
+ _end = Integer.parseInt((String)end.getObject(ctx));
if (_end < 0) {
_end = 0; // If end is negative set up zero
}
@@ -191,6 +191,7 @@
* Extracts string value from var attr
*/
private void initVar(FaceletContext ctx) {
+ this.var = getAttribute("var");
if (var != null) {
try {
_itemId = (String) var.getObject(ctx);
@@ -205,6 +206,7 @@
* Extracts string value from index attr
*/
private void initIndex(FaceletContext ctx) {
+ this.index = getAttribute("index");
if (index != null) {
try {
_indexId = (String) index.getObject(ctx);
@@ -264,15 +266,16 @@
*/
private void exposeVariables(FaceletContext ctx, int k) {
-
VariableMapper vm = ctx.getVariableMapper();
if (_itemId != null) {
if (vm != null) {
- ValueExpression srcVE = value.getValueExpression(ctx,
- Object.class);
- ValueExpression ve = getVarExpression(ctx, srcVE, k);
- vm.setVariable(_itemId, ve);
+ if (value != null) {
+ ValueExpression srcVE = value.getValueExpression(ctx,
+ Object.class);
+ ValueExpression ve = getVarExpression(ctx, srcVE, k);
+ vm.setVariable(_itemId, ve);
+ }
}
}
@@ -347,20 +350,18 @@
// remove created component if columns count is zero
if (atFirst()) {
c.setRendered(false);
- }
+ }
if (vCounter == _index || atFirst()) {
release();
return;
}
-
+
exposeVariables(ctx, vCounter);
vCounter++;
-
}
-
/**
* Sets attribute to column
*
@@ -594,8 +595,8 @@
*
*/
public IndexedValueExpression(ValueExpression orig, int i) {
- this.i = new Integer(i);
- this.orig = orig;
+ this.i = new Integer(i);
+ this.orig = orig;
}
/*
@@ -604,12 +605,12 @@
* @see javax.el.ValueExpression#getValue(javax.el.ELContext)
*/
public Object getValue(ELContext context) {
- Object base = this.orig.getValue(context);
- if (base != null) {
- context.setPropertyResolved(false);
- return context.getELResolver().getValue(context, base, i);
- }
- return null;
+ Object base = this.orig.getValue(context);
+ if (base != null) {
+ context.setPropertyResolved(false);
+ return context.getELResolver().getValue(context, base, i);
+ }
+ return null;
}
/*
@@ -619,11 +620,11 @@
* java.lang.Object)
*/
public void setValue(ELContext context, Object value) {
- Object base = this.orig.getValue(context);
- if (base != null) {
- context.setPropertyResolved(false);
- context.getELResolver().setValue(context, base, i, value);
- }
+ Object base = this.orig.getValue(context);
+ if (base != null) {
+ context.setPropertyResolved(false);
+ context.getELResolver().setValue(context, base, i, value);
+ }
}
/*
@@ -632,12 +633,12 @@
* @see javax.el.ValueExpression#isReadOnly(javax.el.ELContext)
*/
public boolean isReadOnly(ELContext context) {
- Object base = this.orig.getValue(context);
- if (base != null) {
- context.setPropertyResolved(false);
- return context.getELResolver().isReadOnly(context, base, i);
- }
- return true;
+ Object base = this.orig.getValue(context);
+ if (base != null) {
+ context.setPropertyResolved(false);
+ return context.getELResolver().isReadOnly(context, base, i);
+ }
+ return true;
}
/*
@@ -646,12 +647,12 @@
* @see javax.el.ValueExpression#getType(javax.el.ELContext)
*/
public Class getType(ELContext context) {
- Object base = this.orig.getValue(context);
- if (base != null) {
- context.setPropertyResolved(false);
- return context.getELResolver().getType(context, base, i);
- }
- return null;
+ Object base = this.orig.getValue(context);
+ if (base != null) {
+ context.setPropertyResolved(false);
+ return context.getELResolver().getType(context, base, i);
+ }
+ return null;
}
/*
@@ -660,7 +661,7 @@
* @see javax.el.ValueExpression#getExpectedType()
*/
public Class getExpectedType() {
- return Object.class;
+ return Object.class;
}
/*
@@ -669,7 +670,7 @@
* @see javax.el.Expression#getExpressionString()
*/
public String getExpressionString() {
- return this.orig.getExpressionString();
+ return this.orig.getExpressionString();
}
/*
@@ -678,7 +679,7 @@
* @see javax.el.Expression#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
- return this.orig.equals(obj);
+ return this.orig.equals(obj);
}
/*
@@ -687,7 +688,7 @@
* @see javax.el.Expression#hashCode()
*/
public int hashCode() {
- return this.orig.hashCode();
+ return this.orig.hashCode();
}
/*
@@ -696,7 +697,7 @@
* @see javax.el.Expression#isLiteralText()
*/
public boolean isLiteralText() {
- return false;
+ return false;
}
}