JBoss Rich Faces SVN: r12955 - in trunk/test-applications/seleniumTest/richfaces/src: test/java/org/richfaces/testng and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2009-03-13 11:50:46 -0400 (Fri, 13 Mar 2009)
New Revision: 12955
Removed:
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inputNumberSpinner/rf4140.xhtml
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java
Log:
Method "testRF4140" has been removed. Reason: RF-4140
Deleted: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/inputNumberSpinner/rf4140.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java 2009-03-13 15:04:32 UTC (rev 12954)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/InputNumberSpinnerTest.java 2009-03-13 15:50:46 UTC (rev 12955)
@@ -134,14 +134,6 @@
}
@Test
- public void testRF4140(Template template) {
- renderPage(RF4140, template, null);
- // see https://jira.jboss.org/jira/browse/RF-4140)
- writeStatus("Check a spinner works properly when its value is numeric literal");
- Assert.assertEquals(getSpinnerValue(), "20");
- }
-
- @Test
public void testRenderedAttribute(Template template) {
AutoTester tester = getAutoTester(this);
tester.renderPage(template, RESET_METHOD);
15 years, 5 months
JBoss Rich Faces SVN: r12954 - trunk/ui/columns/src/main/java/org/richfaces/taglib.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-03-13 11:04:32 -0400 (Fri, 13 Mar 2009)
New Revision: 12954
Added:
trunk/ui/columns/src/main/java/org/richfaces/taglib/RequestUniqueIdGenerator.java
Modified:
trunk/ui/columns/src/main/java/org/richfaces/taglib/ColumnsHandler.java
trunk/ui/columns/src/main/java/org/richfaces/taglib/ColumnsTag.java
Log:
https://jira.jboss.org/jira/browse/RF-6031
Modified: trunk/ui/columns/src/main/java/org/richfaces/taglib/ColumnsHandler.java
===================================================================
--- trunk/ui/columns/src/main/java/org/richfaces/taglib/ColumnsHandler.java 2009-03-13 14:15:02 UTC (rev 12953)
+++ trunk/ui/columns/src/main/java/org/richfaces/taglib/ColumnsHandler.java 2009-03-13 15:04:32 UTC (rev 12954)
@@ -28,7 +28,6 @@
package org.richfaces.taglib;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
@@ -40,20 +39,24 @@
import javax.el.VariableMapper;
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
import javax.servlet.jsp.JspTagException;
-import org.richfaces.component.UIColumn;
import org.richfaces.el.ELBuilder;
import org.richfaces.iterator.ForEachIterator;
import org.richfaces.iterator.SimpleForEachIterator;
import com.sun.facelets.FaceletContext;
+import com.sun.facelets.FaceletHandler;
import com.sun.facelets.tag.MetaRule;
import com.sun.facelets.tag.MetaRuleset;
import com.sun.facelets.tag.MetaTagHandler;
import com.sun.facelets.tag.Metadata;
import com.sun.facelets.tag.MetadataTarget;
+import com.sun.facelets.tag.Tag;
import com.sun.facelets.tag.TagAttribute;
+import com.sun.facelets.tag.TagAttributes;
import com.sun.facelets.tag.jsf.ComponentConfig;
@@ -65,91 +68,154 @@
*
*/
public class ColumnsHandler extends MetaTagHandler {
-
- com.sun.facelets.tag.jsf.ComponentHandler handler;
-
- static final String DYNAMIC_COLUMN_MARKER = "_richfaces_columns";
-
- /** value attribute */
- private TagAttribute value;
- /** end attribute */
- private TagAttribute columns;
+ com.sun.facelets.tag.jsf.ComponentHandler handler;
- /** begin attribute */
- private TagAttribute begin;
+ private static final String ITERATION_INDEX_VARIABLE = "__richfaces_iteration_index_variable";
+
+ private static final String ITERATION_INDEX_EXPRESSION = "#{" + ITERATION_INDEX_VARIABLE + "}";
- /** var attribute */
- private TagAttribute var;
+ private static final String F_GENERATION_SERIES_ATTRIBUTE = "org.richfaces.F_COLUMNS_GENERATION_SERIES";
- /** index attribute */
- private TagAttribute index;
+ /** value attribute */
+ private TagAttribute value;
- /** end attribute */
- private TagAttribute end;
-
- /** rendered attribute */
- private boolean rendered = true;
+ /** end attribute */
+ private TagAttribute columns;
- class IterationContext {
-
- /** Iterator for columns's tag value attribute */
- public ForEachIterator items; // our 'digested' items
-
- /** Value attribute value */
- public Object rawItems; // our 'raw' items
-
- /** Var attr - defines page variable for current item */
- public String _indexId;
-
- /** Integer value begin attr */
- public Integer _begin;
-
- /** Integer value end attr */
- public Integer _end;
-
- /** Integer value of end attr. */
- public Integer _columns;
-
- /** String value of var attr */
- public String _itemId = null;
-
- /** Current column counter */
- public Integer _index = 0;
-
- /** Expression for var item */
- public IteratedExpression iteratedExpression;
-
- public String valueExpr;
-
- public String getVarReplacement() {
- if (valueExpr == null) {
- return String.valueOf(index);
- }else if (items.getVarReplacement() != null) {
- return items.getVarReplacement();
- }
- return valueExpr + "[" + _index + "]";
- }
-
- public String getIndexReplacement() {
- return String.valueOf(_index);
- }
- };
-
- ThreadLocal<IterationContext> iterationContextLocal = new ThreadLocal<IterationContext>();
-
- public IterationContext getIterationContext() {
- return iterationContextLocal.get();
- }
+ /** begin attribute */
+ private TagAttribute begin;
- /**
- * TODO Description goes here.
- *
- * @param config
- */
- public ColumnsHandler(ComponentConfig config) {
- super(config);
- handler = new ColumnTagHandler(config) {
+ /** var attribute */
+ private TagAttribute var;
+
+ /** index attribute */
+ private TagAttribute index;
+
+ /** end attribute */
+ private TagAttribute end;
+
+ /** rendered attribute */
+ private boolean rendered = true;
+
+ class IterationContext {
+
+ /** Iterator for columns's tag value attribute */
+ public ForEachIterator items; // our 'digested' items
+
+ /** Value attribute value */
+ public Object rawItems; // our 'raw' items
+
+ /** Var attr - defines page variable for current item */
+ public String _indexId;
+
+ /** Integer value begin attr */
+ public Integer _begin;
+
+ /** Integer value end attr */
+ public Integer _end;
+
+ /** Integer value of end attr. */
+ public Integer _columns;
+
+ /** String value of var attr */
+ public String _itemId = null;
+
+ /** Current column counter */
+ public Integer _index = 0;
+
+ /** Expression for var item */
+ public IteratedExpression iteratedExpression;
+
+ public String valueExpr;
+
+ public String getVarReplacement() {
+ if (valueExpr == null) {
+ return String.valueOf(index);
+ }else if (items.getVarReplacement() != null) {
+ return items.getVarReplacement();
+ }
+ return valueExpr + "[" + _index + "]";
+ }
+
+ public String getIndexReplacement() {
+ return String.valueOf(_index);
+ }
+ };
+
+ ThreadLocal<IterationContext> iterationContextLocal = new ThreadLocal<IterationContext>();
+
+ public IterationContext getIterationContext() {
+ return iterationContextLocal.get();
+ }
+
+ /**
+ * TODO Description goes here.
+ *
+ * @param config
+ */
+ public ColumnsHandler(final ComponentConfig config) {
+ super(config);
+
+ final ComponentConfig columnConfig;
+
+ TagAttribute idAttribute = config.getTag().getAttributes().get("id");
+ if (idAttribute != null && idAttribute.isLiteral()) {
+ columnConfig = new ComponentConfig() {
+
+ private Tag tag;
+
+ {
+ Tag initialTag = config.getTag();
+ TagAttribute[] allInitialAttributes = initialTag.getAttributes().getAll();
+ TagAttribute[] attributes = new TagAttribute[allInitialAttributes.length];
+ for (int i = 0; i < allInitialAttributes.length; i++) {
+ TagAttribute initialAttribute = allInitialAttributes[i];
+ String localName = initialAttribute.getLocalName();
+ String attributeValue = initialAttribute.getValue();
+
+ if ("id".equals(localName)) {
+ attributeValue += ITERATION_INDEX_EXPRESSION;
+ }
+
+ attributes[i] = new TagAttribute(initialAttribute.getLocation(),
+ initialAttribute.getNamespace(),
+ localName,
+ initialAttribute.getQName(),
+ attributeValue);
+ }
+
+ TagAttributes tagAttributes = new TagAttributes(attributes);
+ this.tag = new Tag(initialTag, tagAttributes);
+ }
+
+ public String getComponentType() {
+ return config.getComponentType();
+ }
+
+ public String getRendererType() {
+ return config.getRendererType();
+ }
+
+ public FaceletHandler getNextHandler() {
+ return config.getNextHandler();
+ }
+
+ public Tag getTag() {
+ return tag;
+ }
+
+ public String getTagId() {
+ return config.getTagId();
+ }
+
+ };
+ } else {
+ columnConfig = config;
+ }
+
+ handler = new ColumnTagHandler(columnConfig) {
+
@Override
protected MetaRuleset createMetaRuleset(Class type) {
MetaRuleset ruleset = super.createMetaRuleset(type);
@@ -169,7 +235,7 @@
IterationContext itContext = iterationContextLocal.get();
ValueExpression ve = ELBuilder.createValueExpression(expr, Object.class, ctx.getExpressionFactory(), ctx.getFacesContext().getELContext(),
- itContext._itemId, itContext._indexId,
+ itContext._itemId, itContext._indexId,
itContext.getVarReplacement(), itContext.getIndexReplacement());
((UIComponent)instance).setValueExpression(name, ve);
}else {
@@ -185,224 +251,224 @@
});
return ruleset;
}
-
+
@Override
protected void applyNextHandler(FaceletContext ctx, UIComponent c)
- throws IOException, FacesException, ELException {
- c.getAttributes().put(DYNAMIC_COLUMN_MARKER, Boolean.TRUE);
+ throws IOException, FacesException, ELException {
+ c.getAttributes().put(F_GENERATION_SERIES_ATTRIBUTE, RequestUniqueIdGenerator.generateId(ctx.getFacesContext()));
super.applyNextHandler(ctx, c);
}
};
- }
-
-
- /**
- * Extracts tags attributes values
- */
- private void initVariables(FaceletContext ctx) {
- initColumnsCount(ctx);
- initIndex(ctx);
- initVar(ctx);
- initBegin(ctx);
- initEnd(ctx);
- }
+ }
- /**
- * Method prepares all we need for starting of tag rendering
- *
- * @throws JspTagException
- */
- private void prepare(FaceletContext ctx) {
- initVariables(ctx);
+ /**
+ * Extracts tags attributes values
+ */
+ private void initVariables(FaceletContext ctx) {
+ initColumnsCount(ctx);
+ initIndex(ctx);
+ initVar(ctx);
+ initBegin(ctx);
+ initEnd(ctx);
+ }
- IterationContext itContext = getIterationContext();
+ /**
+ * Method prepares all we need for starting of tag rendering
+ *
+ * @throws JspTagException
+ */
+ private void prepare(FaceletContext ctx) {
- try {
+ initVariables(ctx);
- this.value = getAttribute("value");
+ IterationContext itContext = getIterationContext();
- // produce the right sort of ForEachIterator
- if (this.value != null) {
- itContext.valueExpr = ELBuilder.getVarReplacement(this.value.getValue());
+ try {
- // If this is a deferred expression, make a note and get
- // the 'items' instance.
+ this.value = getAttribute("value");
- itContext.rawItems = this.value.getObject(ctx);
+ // produce the right sort of ForEachIterator
+ if (this.value != null) {
+ itContext.valueExpr = ELBuilder.getVarReplacement(this.value.getValue());
- // extract an iterator over the 'items' we've got
- itContext.items = SimpleForEachIterator
- .supportedTypeForEachIterator(itContext.rawItems);
- } else {
- // no 'items', so use 'begin' and 'end'
- itContext.items = SimpleForEachIterator.beginEndForEachIterator(itContext._columns - 1);
- }
- } catch (Exception e) {
- // TODO: handle exception
- }
+ // If this is a deferred expression, make a note and get
+ // the 'items' instance.
- correctFirst(ctx);
- }
+ itContext.rawItems = this.value.getObject(ctx);
- /**
- * Inits first iteration item
- */
- private void correctFirst(FaceletContext ctx) {
- IterationContext itContext = getIterationContext();
- if (itContext.items != null) {
- if (itContext._begin > 0 && (itContext._index < itContext._begin)) {
- while ((itContext._index < itContext._begin && hasNext())) {
- next(ctx);
+ // extract an iterator over the 'items' we've got
+ itContext.items = SimpleForEachIterator
+ .supportedTypeForEachIterator(itContext.rawItems);
+ } else {
+ // no 'items', so use 'begin' and 'end'
+ itContext.items = SimpleForEachIterator.beginEndForEachIterator(itContext._columns - 1);
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
}
- if (!hasNext()) {
- itContext._index = 0;
- }
- }
+
+ correctFirst(ctx);
}
- }
- /**
- * Return true if we didn't complete column's count
- *
- * @return
- * @throws JspTagException
- */
- private boolean hasNext() {
- IterationContext itContext = getIterationContext();
- try {
- if (itContext._end != 0) {
- return (itContext._index < itContext._end) ? itContext.items.hasNext() : false;
- } else {
- return itContext.items.hasNext();
- }
- } catch (Exception e) {
- return false;
+ /**
+ * Inits first iteration item
+ */
+ private void correctFirst(FaceletContext ctx) {
+ IterationContext itContext = getIterationContext();
+ if (itContext.items != null) {
+ if (itContext._begin > 0 && (itContext._index < itContext._begin)) {
+ while ((itContext._index < itContext._begin && hasNext())) {
+ next(ctx);
+ }
+ if (!hasNext()) {
+ itContext._index = 0;
+ }
+ }
+ }
}
- }
+ /**
+ * Return true if we didn't complete column's count
+ *
+ * @return
+ * @throws JspTagException
+ */
+ private boolean hasNext() {
+ IterationContext itContext = getIterationContext();
+ try {
+ if (itContext._end != 0) {
+ return (itContext._index < itContext._end) ? itContext.items.hasNext() : false;
+ } else {
+ return itContext.items.hasNext();
+ }
+ } catch (Exception e) {
+ return false;
+ }
- /**
- * Iterate to next column
- *
- * @return
- * @throws JspTagException
- */
- private Object next(FaceletContext ctx) {
- IterationContext itContext = getIterationContext();
- try {
- Object o = itContext.items.next();
- itContext._index++;
- return o;
- } catch (Exception e) {
- return null;
}
- }
- /**
- * Extracts integer value from end attr
- */
- private void initColumnsCount(FaceletContext ctx) {
- IterationContext itContext = getIterationContext();
- this.columns = getAttribute("columns");
- if (columns != null) {
- try {
- itContext._columns = Integer.parseInt((String) columns.getObject(ctx));
- if (itContext._columns < 0) {
- itContext._columns = 0; // If end is negative set up zero
+ /**
+ * Iterate to next column
+ *
+ * @return
+ * @throws JspTagException
+ */
+ private Object next(FaceletContext ctx) {
+ IterationContext itContext = getIterationContext();
+ try {
+ Object o = itContext.items.next();
+ itContext._index++;
+ return o;
+ } catch (Exception e) {
+ return null;
}
- } catch (Exception e) {
- itContext._columns = 0;
- }
- } else {
- itContext._columns = 0;
}
- }
- /**
- * Extracts integer value from begin attr
- */
- private void initBegin(FaceletContext ctx) {
- IterationContext itContext = getIterationContext();
- this.begin = getAttribute("begin");
- if (begin != null) {
- try {
- Object o = begin.getObject(ctx);
- if (o instanceof Number) {
- itContext._begin = ((Number)o).intValue();
- }else if (o instanceof String) {
- itContext._begin = Integer.parseInt((String) o);
- }
- itContext._begin--;
- if (itContext._begin < 0) {
- itContext._begin = 0; // If end is negative set up zero
+ /**
+ * Extracts integer value from end attr
+ */
+ private void initColumnsCount(FaceletContext ctx) {
+ IterationContext itContext = getIterationContext();
+ this.columns = getAttribute("columns");
+ if (columns != null) {
+ try {
+ itContext._columns = Integer.parseInt((String) columns.getObject(ctx));
+ if (itContext._columns < 0) {
+ itContext._columns = 0; // If end is negative set up zero
+ }
+ } catch (Exception e) {
+ itContext._columns = 0;
+ }
+ } else {
+ itContext._columns = 0;
}
- } catch (Exception e) {
- itContext._begin = 0;
- }
- } else {
- itContext._begin = 0;
}
- }
- /**
- * Extracts integer value from end attr
- */
- private void initEnd(FaceletContext ctx) {
- IterationContext itContext = getIterationContext();
- this.end = getAttribute("end");
- if (end != null) {
- try {
- Object o = end.getObject(ctx);
- if (o instanceof Number) {
- itContext._end = ((Number)o).intValue();
- }else if ( o instanceof String) {
- itContext._end = Integer.parseInt((String) o);
- }
- if (itContext._end < 0) {
- itContext._end = 0; // If end is negative set up zero
+ /**
+ * Extracts integer value from begin attr
+ */
+ private void initBegin(FaceletContext ctx) {
+ IterationContext itContext = getIterationContext();
+ this.begin = getAttribute("begin");
+ if (begin != null) {
+ try {
+ Object o = begin.getObject(ctx);
+ if (o instanceof Number) {
+ itContext._begin = ((Number)o).intValue();
+ }else if (o instanceof String) {
+ itContext._begin = Integer.parseInt((String) o);
+ }
+ itContext._begin--;
+ if (itContext._begin < 0) {
+ itContext._begin = 0; // If end is negative set up zero
+ }
+ } catch (Exception e) {
+ itContext._begin = 0;
+ }
+ } else {
+ itContext._begin = 0;
}
- } catch (Exception e) {
- itContext._end = 0;
- }
- } else {
- itContext._end = 0;
}
- }
- /**
- * Extracts string value from var attr
- */
- private void initVar(FaceletContext ctx) {
- IterationContext itContext = getIterationContext();
- this.var = getAttribute("var");
- if (var != null) {
- try {
- itContext._itemId = (String) var.getObject(ctx);
- } catch (ClassCastException e) {
- itContext._itemId = null;
- }
+ /**
+ * Extracts integer value from end attr
+ */
+ private void initEnd(FaceletContext ctx) {
+ IterationContext itContext = getIterationContext();
+ this.end = getAttribute("end");
+ if (end != null) {
+ try {
+ Object o = end.getObject(ctx);
+ if (o instanceof Number) {
+ itContext._end = ((Number)o).intValue();
+ }else if ( o instanceof String) {
+ itContext._end = Integer.parseInt((String) o);
+ }
+ if (itContext._end < 0) {
+ itContext._end = 0; // If end is negative set up zero
+ }
+ } catch (Exception e) {
+ itContext._end = 0;
+ }
+ } else {
+ itContext._end = 0;
+ }
+ }
+ /**
+ * Extracts string value from var attr
+ */
+ private void initVar(FaceletContext ctx) {
+ IterationContext itContext = getIterationContext();
+ this.var = getAttribute("var");
+ if (var != null) {
+ try {
+ itContext._itemId = (String) var.getObject(ctx);
+ } catch (ClassCastException e) {
+ itContext._itemId = null;
+ }
+
+ }
}
- }
- /**
- * Extracts string value from index attr
- */
- private void initIndex(FaceletContext ctx) {
- IterationContext itContext = getIterationContext();
- this.index = getAttribute("index");
- if (index != null) {
- try {
- itContext._indexId = (String) index.getObject(ctx);
- } catch (ClassCastException e) {
- itContext._indexId = null;
- }
+ /**
+ * Extracts string value from index attr
+ */
+ private void initIndex(FaceletContext ctx) {
+ IterationContext itContext = getIterationContext();
+ this.index = getAttribute("index");
+ if (index != null) {
+ try {
+ itContext._indexId = (String) index.getObject(ctx);
+ } catch (ClassCastException e) {
+ itContext._indexId = null;
+ }
+ }
}
- }
-
- private void initRendered(FaceletContext ctx) {
+
+ private void initRendered(FaceletContext ctx) {
TagAttribute renderedAttribute = getAttribute("rendered");
if (renderedAttribute != null) {
try {
@@ -412,152 +478,154 @@
}
}
}
-
- /*
+
+ /*
* (non-Javadoc)
*
* @see org.richfaces.taglib.ComponentHandler#apply(com.sun.facelets.FaceletContext,
* javax.faces.component.UIComponent)
*/
- //@Override
- public void apply(FaceletContext ctx, UIComponent parent)
- throws IOException, FacesException, ELException {
-
- initRendered(ctx);
- if(!rendered){
- return;
- }
-
- IterationContext iterationContext = new IterationContext();
- iterationContextLocal.set(iterationContext);
-
- clearOldColumns(parent);
- prepare(ctx); // prepare data
-
- try {
- while (hasNext()) { // for each
- exposeVariables(ctx);
- handler.apply(ctx, parent);
- next(ctx);
- }
- } catch (Exception e) {
- // TODO: handle exception
- } finally {
- release();
- unExposeVariables(ctx);
- }
-
- }
+ //@Override
+ public void apply(FaceletContext ctx, UIComponent parent)
+ throws IOException, FacesException, ELException {
-
- private void clearOldColumns (UIComponent parent) {
- if (parent.getChildren() != null) {
- Iterator<UIComponent> childrenIt = parent.getChildren().iterator();
- List<UIComponent> forDelete = new ArrayList<UIComponent>();
- while (childrenIt.hasNext()) {
- UIComponent c = childrenIt.next();
- if (c instanceof UIColumn && c.getAttributes().get(DYNAMIC_COLUMN_MARKER) != null
- && (Boolean)c.getAttributes().get(DYNAMIC_COLUMN_MARKER)) {
- forDelete.add(c);
- }
- }
- if (forDelete.size() > 0) {
- Iterator<UIComponent> it = forDelete.iterator();
- while (it.hasNext()) {
- parent.getChildren().remove(it.next());
- }
- }
- }
-
- }
-
- /**
- * Sets page request variables
- *
- * @throws JspTagException
- */
- private void exposeVariables(FaceletContext ctx) {
- IterationContext itContext = getIterationContext();
- VariableMapper vm = ctx.getVariableMapper();
- int k = itContext._index;
+ initRendered(ctx);
+ if(!rendered){
+ return;
+ }
- if (itContext._itemId != null) {
- if (vm != null) {
- if (value != null) {
- ValueExpression srcVE = value.getValueExpression(ctx,
- Object.class);
- ValueExpression ve = getVarExpression(ctx, srcVE);
- vm.setVariable(itContext._itemId, ve);
+ IterationContext iterationContext = new IterationContext();
+ iterationContextLocal.set(iterationContext);
+
+ clearOldColumns(ctx.getFacesContext(), parent);
+ prepare(ctx); // prepare data
+
+ try {
+ while (hasNext()) { // for each
+ exposeVariables(ctx);
+ handler.apply(ctx, parent);
+ next(ctx);
+ }
+ } catch (Exception e) {
+ // TODO: handle exception
+ } finally {
+ release();
+ unExposeVariables(ctx);
}
- }
}
- // Set up index variable
- if (itContext._indexId != null) {
- if (vm != null) {
- ValueExpression ve = new IteratedIndexExpression(k);
- vm.setVariable(itContext._indexId, ve);
- }
+ private void clearOldColumns(FacesContext context, UIComponent parent) {
+ if (parent.getChildCount() > 0) {
+ Integer generatedId = RequestUniqueIdGenerator.generateId(context);
+
+ Iterator<UIComponent> childrenIt = parent.getChildren().iterator();
+ while (childrenIt.hasNext()) {
+ UIComponent c = childrenIt.next();
+ Object generationSeries = c.getAttributes().get(F_GENERATION_SERIES_ATTRIBUTE);
+ if (generationSeries != null && !generationSeries.equals(generatedId)) {
+ childrenIt.remove();
+ }
+ }
+ }
}
- }
+ /**
+ * Sets page request variables
+ *
+ * @throws JspTagException
+ */
+ private void exposeVariables(FaceletContext ctx) {
+ IterationContext itContext = getIterationContext();
+ VariableMapper vm = ctx.getVariableMapper();
+ int k = itContext._index;
- /**
- * Removes page attributes that we have exposed and, if applicable, restores
- * them to their prior values (and scopes).
- */
- private void unExposeVariables(FaceletContext ctx) {
- IterationContext itContext = getIterationContext();
- VariableMapper vm = ctx.getVariableMapper();
- // "nested" variables are now simply removed
- if (itContext._itemId != null) {
- if (vm != null)
- vm.setVariable(itContext._itemId, null);
+ if (itContext._itemId != null) {
+ if (vm != null) {
+ if (value != null) {
+ ValueExpression srcVE = value.getValueExpression(ctx,
+ Object.class);
+ ValueExpression ve = getVarExpression(ctx, srcVE);
+ vm.setVariable(itContext._itemId, ve);
+ }
+ }
+
+ }
+
+ // Set up index variable
+
+ if (itContext._indexId != null) {
+ if (vm != null) {
+ ValueExpression ve = new IteratedIndexExpression(k);
+ vm.setVariable(itContext._indexId, ve);
+ }
+
+ }
+
+ int componentsCount = itContext._index - itContext._begin;
+ if (componentsCount != 0) {
+ ValueExpression ve = ctx.getExpressionFactory().createValueExpression(UIViewRoot.UNIQUE_ID_PREFIX + componentsCount, String.class);
+ vm.setVariable(ITERATION_INDEX_VARIABLE, ve);
+ }
}
- if (itContext._indexId != null) {
- if (vm != null)
- vm.setVariable(itContext._indexId, null);
- }
- }
- /**
- * Return expression for page variables
- *
- * @param expr
- * @return
- */
- private ValueExpression getVarExpression(FaceletContext ctx,
- ValueExpression expr/*, IterationContext itContext*/) {
- IterationContext itContext = getIterationContext();
- Object o = expr.getValue(ctx.getFacesContext().getELContext());
- int k = itContext._index;
- if (o.getClass().isArray() || o instanceof List) {
- return new IndexedValueExpression(expr, k);
+ /**
+ * Removes page attributes that we have exposed and, if applicable, restores
+ * them to their prior values (and scopes).
+ */
+ private void unExposeVariables(FaceletContext ctx) {
+ IterationContext itContext = getIterationContext();
+ VariableMapper vm = ctx.getVariableMapper();
+ // "nested" variables are now simply removed
+ if (itContext._itemId != null) {
+ if (vm != null)
+ vm.setVariable(itContext._itemId, null);
+ }
+ if (itContext._indexId != null) {
+ if (vm != null)
+ vm.setVariable(itContext._indexId, null);
+ }
+
+ vm.setVariable(ITERATION_INDEX_VARIABLE, null);
}
- if (o instanceof Collection || o instanceof Iterator
- || o instanceof Enumeration || o instanceof Map
- || o instanceof String) {
+ /**
+ * Return expression for page variables
+ *
+ * @param expr
+ * @return
+ */
+ private ValueExpression getVarExpression(FaceletContext ctx,
+ ValueExpression expr/*, IterationContext itContext*/) {
+ IterationContext itContext = getIterationContext();
+ Object o = expr.getValue(ctx.getFacesContext().getELContext());
+ int k = itContext._index;
+ if (o.getClass().isArray() || o instanceof List) {
+ return new IndexedValueExpression(expr, k);
+ }
- if (itContext.iteratedExpression == null) {
- itContext.iteratedExpression = new IteratedExpression(expr, ",");
- }
- return new IteratedValueExpression(itContext.iteratedExpression, k);
+ if (o instanceof Collection || o instanceof Iterator
+ || o instanceof Enumeration || o instanceof Map
+ || o instanceof String) {
+
+ if (itContext.iteratedExpression == null) {
+ itContext.iteratedExpression = new IteratedExpression(expr, ",");
+ }
+ return new IteratedValueExpression(itContext.iteratedExpression, k);
+ }
+
+ throw new ELException("FOREACH_BAD_ITEMS");
}
- throw new ELException("FOREACH_BAD_ITEMS");
- }
+ /**
+ * Release iteration variables
+ */
+ private void release() {
+ IterationContext itContext = getIterationContext();
+ itContext.items = null;
+ itContext._index = 0;
+ }
- /**
- * Release iteration variables
- */
- private void release() {
- IterationContext itContext = getIterationContext();
- itContext.items = null;
- itContext._index = 0;
- }
-
}
Modified: trunk/ui/columns/src/main/java/org/richfaces/taglib/ColumnsTag.java
===================================================================
--- trunk/ui/columns/src/main/java/org/richfaces/taglib/ColumnsTag.java 2009-03-13 14:15:02 UTC (rev 12953)
+++ trunk/ui/columns/src/main/java/org/richfaces/taglib/ColumnsTag.java 2009-03-13 15:04:32 UTC (rev 12954)
@@ -21,7 +21,6 @@
package org.richfaces.taglib;
import java.lang.reflect.Field;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.Iterator;
@@ -36,6 +35,7 @@
import javax.el.ValueExpression;
import javax.el.VariableMapper;
import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import javax.faces.webapp.UIComponentClassicTagBase;
import javax.servlet.jsp.JspException;
@@ -57,6 +57,8 @@
/** Data table */
private UIComponent dataTable;
+ private static final String J_GENERATION_SERIES_ATTRIBUTE = "org.richfaces.J_COLUMNS_GENERATION_SERIES";
+
/** Prefix before id to be assigned for column */
private static final String COLUMN_ID_PREFIX = "rf";
@@ -107,7 +109,8 @@
private String jspId;
-
+ private String pageId;
+
/**
* style CSS style(s) is/are to be applied when this component is rendered
*/
@@ -285,6 +288,8 @@
*/
@Override
public int doStartTag() throws JspException {
+ pageId = getId();
+
initRendered();
if(!rendered){
return SKIP_BODY;
@@ -313,6 +318,9 @@
if (hasNext()) {
super.doAfterBody();
super.doEndTag();
+
+ setId(pageId);
+
next();
exposeVariables();
super.doStartTag();
@@ -359,9 +367,10 @@
throws JspException {
UIComponent c = getFacesContext().getApplication().createComponent(
getComponentType());
- c.setId(generateColumnId());
+ c.setId(newId);
c.setTransient(false);
setProperties(c);
+ c.getAttributes().put(J_GENERATION_SERIES_ATTRIBUTE, RequestUniqueIdGenerator.generateId(context));
return c;
}
@@ -491,22 +500,17 @@
*/
private void deleteRichColumns() {
List<UIComponent> children = dataTable.getChildren();
+ Integer generatedId = RequestUniqueIdGenerator.generateId(getFacesContext());
+
Iterator<UIComponent> it = children.iterator();
- List<UIComponent> forDelete = new ArrayList<UIComponent>();
- Integer i = 0;
while (it.hasNext()) {
UIComponent child = it.next();
- String id = child.getId();
- if (id != null && id.startsWith(COLUMN_ID_PREFIX)) {
- forDelete.add(child);
+
+ Object generationSeries = child.getAttributes().get(J_GENERATION_SERIES_ATTRIBUTE);
+ if (generationSeries != null && !generationSeries.equals(generatedId)) {
+ it.remove();
}
- i++;
}
- it = forDelete.iterator();
- while (it.hasNext()) {
- UIComponent elem = it.next();
- children.remove(elem);
- }
}
/**
@@ -733,7 +737,12 @@
}
private String generateColumnId() {
- return COLUMN_ID_PREFIX + Integer.toString(index);
+ String id = getId();
+ if (id == null) {
+ id = getFacesJspId();
+ }
+
+ return id;
}
/**
Added: trunk/ui/columns/src/main/java/org/richfaces/taglib/RequestUniqueIdGenerator.java
===================================================================
--- trunk/ui/columns/src/main/java/org/richfaces/taglib/RequestUniqueIdGenerator.java (rev 0)
+++ trunk/ui/columns/src/main/java/org/richfaces/taglib/RequestUniqueIdGenerator.java 2009-03-13 15:04:32 UTC (rev 12954)
@@ -0,0 +1,59 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - 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.util.Map;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.1
+ */
+final class RequestUniqueIdGenerator {
+
+ private static final String GENERATOR_ATTRIBUTE = RequestUniqueIdGenerator.class.getName();
+
+ public static Integer generateId(FacesContext context) {
+ Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
+ Integer id = (Integer) requestMap.get(GENERATOR_ATTRIBUTE);
+
+ if (id == null) {
+ Map<String, Object> attributes = context.getViewRoot().getAttributes();
+ id = (Integer) attributes.get(GENERATOR_ATTRIBUTE);
+ if (id == null) {
+ //start from zero
+ id = Integer.valueOf(0);
+ } else {
+ //increase id used for last view creation
+ id = Integer.valueOf(id.intValue() + 1);
+ }
+
+ attributes.put(GENERATOR_ATTRIBUTE, id);
+ requestMap.put(GENERATOR_ATTRIBUTE, id);
+ } else {
+ //already generated id for this request, reuse
+ }
+
+ return id;
+ }
+}
15 years, 5 months
JBoss Rich Faces SVN: r12953 - in trunk/test-applications/realworld2/web/src/main/webapp: stylesheet and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: alevkovsky
Date: 2009-03-13 10:15:02 -0400 (Fri, 13 Mar 2009)
New Revision: 12953
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/userAlbums.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/userImages.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/userShelfs.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/stylesheet/realworld2.css
Log:
Realworld: correct headers
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/userAlbums.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/userImages.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/userShelfs.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/stylesheet/realworld2.css
===================================================================
--- trunk/test-applications/realworld2/web/src/main/webapp/stylesheet/realworld2.css 2009-03-13 13:59:13 UTC (rev 12952)
+++ trunk/test-applications/realworld2/web/src/main/webapp/stylesheet/realworld2.css 2009-03-13 14:15:02 UTC (rev 12953)
@@ -294,6 +294,9 @@
a{color : #DF6400;}
h1{font-size : 175%; font-weight : normal; margin : 0px;}
+.h1-style{
+ font-size : 175%; font-weight : normal; margin : 0px;
+}
.content_box {padding : 15px 35px 15px 35px;}
.content_box p {margin : 0px 0px 5px 0px; FONT-SIZE : 12PX}
15 years, 5 months
JBoss Rich Faces SVN: r12952 - in trunk/test-applications/realworld2/web/src/main: webapp/img/shell and 5 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alevkovsky
Date: 2009-03-13 09:59:13 -0400 (Fri, 13 Mar 2009)
New Revision: 12952
Added:
trunk/test-applications/realworld2/web/src/main/webapp/img/shell/avatar_w_default.png
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByAlbum.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByImage.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByTag.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByUser.java
trunk/test-applications/realworld2/web/src/main/webapp/includes/image/userImageMainBlock.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/image/userImagePreviewBlock.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/search.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/albumsResult.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/imageResult.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/userResult.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/shelf/userShelfPreview.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/userAlbum.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/stylesheet/realworld2.css
Log:
Realworld: apply new design for search, add default woman avatar, add security check for editing and deleting
Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByAlbum.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByAlbum.java 2009-03-13 13:58:57 UTC (rev 12951)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByAlbum.java 2009-03-13 13:59:13 UTC (rev 12952)
@@ -21,7 +21,7 @@
@Override
public String getSearchResultName() {
- return "Albums";
+ return "Albums search result";
}
@Override
Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByImage.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByImage.java 2009-03-13 13:58:57 UTC (rev 12951)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByImage.java 2009-03-13 13:59:13 UTC (rev 12952)
@@ -3,12 +3,10 @@
*/
package org.richfaces.realworld.search;
-import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.jboss.seam.annotations.In;
import org.jboss.seam.core.Events;
import org.richfaces.realworld.domain.Image;
import org.richfaces.realworld.service.ISearchAction;
@@ -30,7 +28,7 @@
@Override
public String getSearchResultName() {
- return "Images";
+ return "Images search result";
}
@Override
Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByTag.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByTag.java 2009-03-13 13:58:57 UTC (rev 12951)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByTag.java 2009-03-13 13:59:13 UTC (rev 12952)
@@ -28,7 +28,7 @@
*/
@Override
public String getSearchResultName() {
- return "Tags";
+ return "Tags search result";
}
/* (non-Javadoc)
Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByUser.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByUser.java 2009-03-13 13:58:57 UTC (rev 12951)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByUser.java 2009-03-13 13:59:13 UTC (rev 12952)
@@ -28,7 +28,7 @@
*/
@Override
public String getSearchResultName() {
- return "Users";
+ return "Users search result";
}
/* (non-Javadoc)
Added: trunk/test-applications/realworld2/web/src/main/webapp/img/shell/avatar_w_default.png
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/realworld2/web/src/main/webapp/img/shell/avatar_w_default.png
___________________________________________________________________
Name: svn:mime-type
+ image/png
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/image/userImageMainBlock.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/image/userImagePreviewBlock.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/albumsResult.xhtml
===================================================================
--- trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/albumsResult.xhtml 2009-03-13 13:58:57 UTC (rev 12951)
+++ trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/albumsResult.xhtml 2009-03-13 13:59:13 UTC (rev 12952)
@@ -38,6 +38,9 @@
<f:convertDateTime />
</h:outputText>
</h:panelGroup>
+ <h:panelGroup layout="block" styleClass="album_data">
+ <a href="#">#{album.owner.firstName} #{album.owner.secondName}</a>
+ </h:panelGroup>
</h:panelGroup>
</a4j:repeat>
</ui:composition>
\ No newline at end of file
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/imageResult.xhtml
===================================================================
--- trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/imageResult.xhtml 2009-03-13 13:58:57 UTC (rev 12951)
+++ trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/imageResult.xhtml 2009-03-13 13:59:13 UTC (rev 12952)
@@ -27,7 +27,10 @@
<h:outputText value="#{image.created}">
<f:convertDateTime />
</h:outputText>
- </h:panelGroup>
+ </h:panelGroup>
+ <h:panelGroup layout="block" styleClass="photo_data">
+ <a href="#">#{image.album.owner.firstName} #{image.album.owner.secondName}</a>
+ </h:panelGroup>
</h:panelGroup>
</a4j:repeat>
</ui:composition>
\ No newline at end of file
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/userResult.xhtml
===================================================================
--- trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/userResult.xhtml 2009-03-13 13:58:57 UTC (rev 12951)
+++ trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/userResult.xhtml 2009-03-13 13:59:13 UTC (rev 12952)
@@ -5,9 +5,31 @@
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<a4j:repeat id="userList" value="#{result}" var="user">
- <a4j:mediaOutput rendered="#{user.hasAvatar}" element="img" createContent="#{imageLoader.paintImage}"
- styleClass="avatar"
- value="/#{user.login}/avatar.jpg" />
- <a4j:commandLink reRender="mainArea" actionListener="#{controller.showUser(user)}" value="#{user.login}"></a4j:commandLink><br/>
+ <h:panelGroup layout="block" styleClass="preview_box_photo_120">
+ <h:graphicImage styleClass="pr_photo_bg" value="/img/shell/frame_photo_200.png" style="border:none"/>
+ <h:panelGrid cellpadding="0">
+ <h:panelGroup>
+ <a4j:commandLink reRender="mainArea" actionListener="#{controller.showUser(user)}">
+ <a4j:mediaOutput rendered="#{user.hasAvatar}" element="img" createContent="#{imageLoader.paintImage}"
+ styleClass="avatar"
+ value="/#{user.login}/avatar.jpg" />
+ <h:graphicImage rendered="#{!user.hasAvatar and user.sex.key =='1' }" value="/img/shell/avatar_default.png" width="80" height="80" alt="" style="border:none"/>
+ <h:graphicImage rendered="#{!user.hasAvatar and user.sex.key =='0' }" value="/img/shell/avatar_w_default.png" width="80" height="80" alt="" style="border:none"/>
+ </a4j:commandLink>
+ <br/>
+ </h:panelGroup>
+ </h:panelGrid>
+ <h:panelGroup layout="block" styleClass="photo_name">
+ <strong>#{user.firstName} #{user.secondName}</strong>
+ </h:panelGroup>
+ <h:panelGroup layout="block" styleClass="photo_data">
+ <h:outputText value="#{user.birthDate}" >
+ <f:convertDateTime />
+ </h:outputText>
+ </h:panelGroup>
+ <h:panelGroup layout="block" styleClass="photo_data">
+ <a href="#"><h:outputText value="#{userManager.countAlbums(user)} albums "/></a> | <a href="#"><h:outputText value="#{userManager.countImages(user)} photos"/></a>
+ </h:panelGroup>
+ </h:panelGroup>
</a4j:repeat>
</ui:composition>
\ No newline at end of file
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/search.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/shelf/userShelfPreview.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/userAlbum.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/stylesheet/realworld2.css
===================================================================
--- trunk/test-applications/realworld2/web/src/main/webapp/stylesheet/realworld2.css 2009-03-13 13:58:57 UTC (rev 12951)
+++ trunk/test-applications/realworld2/web/src/main/webapp/stylesheet/realworld2.css 2009-03-13 13:59:13 UTC (rev 12952)
@@ -661,4 +661,42 @@
.main-menu-add-icons-img{
padding : 4px 0px 0px 5px;
border : 0px;
+}
+
+.rich-tabpanel-content{
+ border: none;
+ background: none;
+}
+.rich-tabhdr-side-cell{
+ border: none;
+}
+.rich-tabhdr-side-border{
+ border: none;
+ background: none;
+}
+.rich-tab-bottom-line{
+ border: none;
+ background: none;
+}
+
+.rich-tab-active{
+ border-right: 1px solid;
+ border-right-color: black;
+ border-left: 0px;
+ border-top: 0px;
+ font-size : 175%;
+ background: none;
+ font-weight : normal;
+ margin : 4px;
+}
+
+.rich-tab-inactive{
+ border-right: 1px solid;
+ border-right-color: black;
+ border-left: 0px;
+ border-top: 0px;
+ background: none;
+ color : #DF6400;
+ text-decoration: underline;
+ cursor: pointer;
}
\ No newline at end of file
15 years, 5 months
JBoss Rich Faces SVN: r12951 - in trunk/test-applications/realworld2/ejb/src/main: resources and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: alevkovsky
Date: 2009-03-13 09:58:57 -0400 (Fri, 13 Mar 2009)
New Revision: 12951
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Sex.java
trunk/test-applications/realworld2/ejb/src/main/resources/import.sql
Log:
Realworld: apply new design for search, add default woman avatar, add security check for editing and deleting
Modified: trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Sex.java
===================================================================
--- trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Sex.java 2009-03-13 13:33:17 UTC (rev 12950)
+++ trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Sex.java 2009-03-13 13:58:57 UTC (rev 12951)
@@ -9,6 +9,20 @@
private Sex(String key) {
this.key = key;
}
+
+ /**
+ * @return the key
+ */
+ public String getKey() {
+ return key;
+ }
+
+ /**
+ * @param key the key to set
+ */
+ public void setKey(String key) {
+ this.key = key;
+ }
Modified: trunk/test-applications/realworld2/ejb/src/main/resources/import.sql
===================================================================
--- trunk/test-applications/realworld2/ejb/src/main/resources/import.sql 2009-03-13 13:33:17 UTC (rev 12950)
+++ trunk/test-applications/realworld2/ejb/src/main/resources/import.sql 2009-03-13 13:58:57 UTC (rev 12951)
@@ -1,4 +1,4 @@
-INSERT INTO Users(user_id, firstname, secondname, email, login, passwordHash, birthdate, sex, doNotShowMail, informAboutNews, hasAvatar) VALUES (1, 'Andrey', 'Markhel', 'amarkhel(a)exadel.com', 'amarkhel', '8cb2237d0679ca88db6464eac60da96345513964', '1985-01-08', 1, 1, 1, 0);
+INSERT INTO Users(user_id, firstname, secondname, email, login, passwordHash, birthdate, sex, doNotShowMail, informAboutNews, hasAvatar) VALUES (1, 'Andrey', 'Markhel', 'amarkhel(a)exadel.com', 'amarkhel', '8cb2237d0679ca88db6464eac60da96345513964', '1985-01-08', 0, 1, 1, 0);
INSERT INTO Users(user_id, firstname, secondname, email, login, passwordHash, birthdate, sex, doNotShowMail, informAboutNews, hasAvatar) VALUES (2, 'Nick', 'Curtis', 'nkurtis(a)iba.com', 'Viking', '8cb2237d0679ca88db6464eac60da96345513964', '1978-01-08', 1, 1, 1, 0);
INSERT INTO Users(user_id, firstname, secondname, email, login, passwordHash, birthdate, sex, doNotShowMail, informAboutNews, hasAvatar) VALUES (3, 'John', 'Smith', 'jsmith(a)jboss.com', 'Noname', '8cb2237d0679ca88db6464eac60da96345513964', '1970-01-08', 1, 1, 1, 0);
15 years, 5 months
JBoss Rich Faces SVN: r12950 - trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2009-03-13 09:33:17 -0400 (Fri, 13 Mar 2009)
New Revision: 12950
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/BeanValidatorTest.java
Log:
add reset method
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/BeanValidatorTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/BeanValidatorTest.java 2009-03-12 20:24:03 UTC (rev 12949)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/BeanValidatorTest.java 2009-03-13 13:33:17 UTC (rev 12950)
@@ -27,7 +27,9 @@
public class BeanValidatorTest extends SeleniumTestBase {
- private static final String NAME = "name";
+ private static final String RESET_METHOD = "#{validationBean.reset}" ;
+
+ private static final String NAME = "name";
private static final String AGE = "age";
@@ -39,7 +41,7 @@
@Test
public void testBeanValidatorComponent(Template template) {
- renderPage(template);
+ renderPage(template, RESET_METHOD);
writeStatus("Check bean validator component with model-based constraints defined using hibernate validator.");
15 years, 5 months
JBoss Rich Faces SVN: r12949 - trunk/ui/fileUpload/src/main/java/org/richfaces/renderkit.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-03-12 16:24:03 -0400 (Thu, 12 Mar 2009)
New Revision: 12949
Modified:
trunk/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java
Log:
rich:fileUpload refactored
Modified: trunk/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java
===================================================================
--- trunk/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java 2009-03-12 20:23:04 UTC (rev 12948)
+++ trunk/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java 2009-03-12 20:24:03 UTC (rev 12949)
@@ -505,7 +505,7 @@
*/
public String getStopScript(FacesContext context, UIComponent component)
throws IOException {
- return getActionScript(context, component, "richfaces_file_upload_action_stop", null);
+ return getActionScript(context, component, FileUploadConstants.FILE_UPLOAD_ACTION_STOP, null);
}
/**
15 years, 5 months
JBoss Rich Faces SVN: r12948 - trunk/framework/impl/src/main/java/org/richfaces/component.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-03-12 16:23:04 -0400 (Thu, 12 Mar 2009)
New Revision: 12948
Modified:
trunk/framework/impl/src/main/java/org/richfaces/component/FileUploadConstants.java
Log:
rich:fileUpload refactored
Modified: trunk/framework/impl/src/main/java/org/richfaces/component/FileUploadConstants.java
===================================================================
--- trunk/framework/impl/src/main/java/org/richfaces/component/FileUploadConstants.java 2009-03-12 20:22:50 UTC (rev 12947)
+++ trunk/framework/impl/src/main/java/org/richfaces/component/FileUploadConstants.java 2009-03-12 20:23:04 UTC (rev 12948)
@@ -49,6 +49,8 @@
/** Session bean name where stop keys will be stored */
public static final String REQUEST_KEYS_BEAN_NAME = "_richfaces_request_keys";
+ public static final String FILE_UPLOAD_ACTION = "_richfaces_file_upload_action";
+
public static final String FILE_UPLOAD_ACTION_STOP = "richfaces_file_upload_action_stop";
private FileUploadConstants() {
15 years, 5 months
JBoss Rich Faces SVN: r12947 - in trunk/ui/fileUpload/src/main/java/org/richfaces: component and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-03-12 16:22:50 -0400 (Thu, 12 Mar 2009)
New Revision: 12947
Added:
trunk/ui/fileUpload/src/main/java/org/richfaces/event/
trunk/ui/fileUpload/src/main/java/org/richfaces/event/UploadAjaxActionEvent.java
Modified:
trunk/ui/fileUpload/src/main/java/org/richfaces/component/UIFileUpload.java
trunk/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java
Log:
rich:fileUpload refactored
Modified: trunk/ui/fileUpload/src/main/java/org/richfaces/component/UIFileUpload.java
===================================================================
--- trunk/ui/fileUpload/src/main/java/org/richfaces/component/UIFileUpload.java 2009-03-12 19:57:38 UTC (rev 12946)
+++ trunk/ui/fileUpload/src/main/java/org/richfaces/component/UIFileUpload.java 2009-03-12 20:22:50 UTC (rev 12947)
@@ -41,6 +41,7 @@
import org.ajax4jsf.context.AjaxContextImpl;
import org.ajax4jsf.request.MultipartRequest;
import org.richfaces.event.FileUploadListener;
+import org.richfaces.event.UploadAjaxActionEvent;
import org.richfaces.event.UploadEvent;
import org.richfaces.renderkit.FileUploadRendererBase;
@@ -52,232 +53,229 @@
*/
public abstract class UIFileUpload extends UIInput {
- /**
- * <p>
- * The standard component type for this component.
- * </p>
- */
- public static final String COMPONENT_TYPE = "org.richfaces.component.FileUpload";
+ /**
+ * <p>
+ * The standard component type for this component.
+ * </p>
+ */
+ public static final String COMPONENT_TYPE = "org.richfaces.component.FileUpload";
- /**
- * <p>
- * The standard component family for this component.
- * </p>
- */
- public static final String COMPONENT_FAMILY = "org.richfaces.component.FileUpload";
+ /**
+ * <p>
+ * The standard component family for this component.
+ * </p>
+ */
+ public static final String COMPONENT_FAMILY = "org.richfaces.component.FileUpload";
- private String localContentType;
+ private String localContentType;
- private String localFileName;
+ private String localFileName;
- private Integer localFileSize;
+ private Integer localFileSize;
- private InputStream localInputStream;
-
- private void setupProgressBarValueExpression(FacesContext context, String uid) {
- FileUploadRendererBase renderer = (FileUploadRendererBase)this.getRenderer(context);
- UIComponent progressBar = renderer.getProgressBar(context, this);
- String percentExpression = FileUploadConstants.PERCENT_BEAN_NAME + "['"+uid+"']";
+ private InputStream localInputStream;
+
+ private void setupProgressBarValueExpression(FacesContext context, String uid) {
+ FileUploadRendererBase renderer = (FileUploadRendererBase)this.getRenderer(context);
+ UIComponent progressBar = renderer.getProgressBar(context, this);
+ String percentExpression = FileUploadConstants.PERCENT_BEAN_NAME + "['"+uid+"']";
ExpressionFactory expressionFactory = context.getApplication().getExpressionFactory();
ELContext elContext = context.getELContext();
-
+
ValueExpression value = expressionFactory
- .createValueExpression(elContext, "#{" + percentExpression + "}",
+ .createValueExpression(elContext, "#{" + percentExpression + "}",
Integer.class);
progressBar.setValueExpression("value", value);
-
+
ValueExpression enabled = expressionFactory
- .createValueExpression(elContext,
+ .createValueExpression(elContext,
"#{" + percentExpression + " < 100}", //100 - disable progress when upload reaches 100%
Boolean.class);
progressBar.setValueExpression("enabled", enabled);
- }
+ }
-
- public String getLocalContentType() {
- return localContentType;
- }
- public void setLocalContentType(String localContentType) {
- this.localContentType = localContentType;
- }
+ public String getLocalContentType() {
+ return localContentType;
+ }
- public String getLocalFileName() {
- return localFileName;
- }
+ public void setLocalContentType(String localContentType) {
+ this.localContentType = localContentType;
+ }
+ public String getLocalFileName() {
+ return localFileName;
+ }
+
public void setLocalFileName(String localFileName) {
- this.localFileName = localFileName;
- }
+ this.localFileName = localFileName;
+ }
- public Integer getLocalFileSize() {
- return localFileSize;
- }
+ public Integer getLocalFileSize() {
+ return localFileSize;
+ }
- public void setLocalFileSize(Integer localFileSize) {
- this.localFileSize = localFileSize;
- }
+ public void setLocalFileSize(Integer localFileSize) {
+ this.localFileSize = localFileSize;
+ }
- public InputStream getLocalInputStream() {
- return localInputStream;
- }
+ public InputStream getLocalInputStream() {
+ return localInputStream;
+ }
- public void setLocalInputStream(InputStream localInputStream) {
- this.localInputStream = localInputStream;
- }
+ public void setLocalInputStream(InputStream localInputStream) {
+ this.localInputStream = localInputStream;
+ }
- public abstract void setAcceptedTypes(String acceptedTypes);
+ public abstract void setAcceptedTypes(String acceptedTypes);
- public abstract String getAcceptedTypes();
+ public abstract String getAcceptedTypes();
- public abstract Integer getMaxFilesQuantity();
+ public abstract Integer getMaxFilesQuantity();
- public abstract void setMaxFilesQuantity(Integer maxFilesQuantity);
+ public abstract void setMaxFilesQuantity(Integer maxFilesQuantity);
- public abstract String getListHeight();
+ public abstract String getListHeight();
- public abstract void setListHeight(String listHeight);
+ public abstract void setListHeight(String listHeight);
- public abstract String getListWidth();
+ public abstract String getListWidth();
- public abstract void setListWidth(String listWidth);
+ public abstract void setListWidth(String listWidth);
- public abstract String getStyleClass();
+ public abstract String getStyleClass();
- public abstract String getStyle();
+ public abstract String getStyle();
- public abstract void setStyleClass(String styleClass);
+ public abstract void setStyleClass(String styleClass);
- public abstract void setStyle(String style);
-
- public abstract Object getLocale();
+ public abstract void setStyle(String style);
- public abstract void setLocale(Object locale);
+ public abstract Object getLocale();
- public abstract MethodBinding getFileUploadListener();
+ public abstract void setLocale(Object locale);
- public abstract void setFileUploadListener(MethodBinding scrollerListener);
+ public abstract MethodBinding getFileUploadListener();
- public void addFileUploadListener(FileUploadListener listener) {
- addFacesListener(listener);
- }
+ public abstract void setFileUploadListener(MethodBinding scrollerListener);
- public FileUploadListener[] getFileUploadListeners() {
- return (FileUploadListener[]) getFacesListeners(FileUploadListener.class);
- }
+ public void addFileUploadListener(FileUploadListener listener) {
+ addFacesListener(listener);
+ }
- public void removeFileUploadListener(FileUploadListener listener) {
- removeFacesListener(listener);
- }
-
- public void reset () {
- this.localContentType = null;
- this.localContentType = null;
- this.localFileName = null;
- this.localFileSize = null;
- this.localInputStream = null;
- }
+ public FileUploadListener[] getFileUploadListeners() {
+ return (FileUploadListener[]) getFacesListeners(FileUploadListener.class);
+ }
- public void broadcast(FacesEvent e) {
+ public void removeFileUploadListener(FileUploadListener listener) {
+ removeFacesListener(listener);
+ }
- if (e instanceof UploadEvent) {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- MethodBinding binding = getFileUploadListener();
- if (binding != null) {
- binding.invoke(facesContext, new Object[] { e });
- }
+ public void reset () {
+ this.localContentType = null;
+ this.localContentType = null;
+ this.localFileName = null;
+ this.localFileSize = null;
+ this.localInputStream = null;
+ }
- } else {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- ExternalContext externalContext = facesContext.getExternalContext();
- Map<String, String> requestParameterMap = externalContext.getRequestParameterMap();
-
- String actionString = requestParameterMap.get("action");
-
- if (actionString != null && requestParameterMap.containsKey(this.getClientId(facesContext))) {
- AjaxContext ajaxContext = AjaxContextImpl.getCurrentInstance(facesContext);
- String uid = requestParameterMap.get(FileUploadConstants.UPLOAD_FILES_ID);
+ public void broadcast(FacesEvent e) {
- Map<String, Object> sessionMap = externalContext.getSessionMap();
+ if (e instanceof UploadEvent) {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ MethodBinding binding = getFileUploadListener();
+ if (binding != null) {
+ binding.invoke(facesContext, new Object[] { e });
+ }
- if ("progress".equals(actionString)) {
- setupProgressBarValueExpression(facesContext, uid);
- Map<String, Integer> requestsSizeMap = (Map<String, Integer>) sessionMap.get(FileUploadConstants.REQUEST_SIZE_BEAN_NAME);
-
- if (requestsSizeMap != null) {
- ajaxContext.setResponseData(requestsSizeMap.get(uid));
- } else {
- ajaxContext.setResponseData(null);
- }
- } else if (FileUploadConstants.FILE_UPLOAD_ACTION_STOP.equals(actionString)) {
- MultipartRequest multipartRequest = MultipartRequest.lookupRequest(facesContext, uid);
- if (multipartRequest != null) {
- multipartRequest.stop();
- }
- }
- }
- }
+ } else if (e instanceof UploadAjaxActionEvent) {
+ UploadAjaxActionEvent uploadActionEvent = (UploadAjaxActionEvent) e;
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ ExternalContext externalContext = facesContext.getExternalContext();
+
+ AjaxContext ajaxContext = AjaxContextImpl.getCurrentInstance(facesContext);
+ String uid = uploadActionEvent.getUploadId();
+ String actionString = uploadActionEvent.getAction();
+
+ if ("progress".equals(actionString)) {
+ setupProgressBarValueExpression(facesContext, uid);
+ Map<String, Object> sessionMap = externalContext.getSessionMap();
+ Map<String, Integer> requestsSizeMap = (Map<String, Integer>) sessionMap.get(FileUploadConstants.REQUEST_SIZE_BEAN_NAME);
- }
-
- /**
- *Parse Locale from String.
- *String must be represented as Locale.toString(); xx_XX_XXXX
-*/
-
- public Locale parseLocale(String localeStr){
-
- int length = localeStr.length();
- if(null==localeStr||length<2){
- return Locale.getDefault();
+ if (requestsSizeMap != null) {
+ ajaxContext.setResponseData(requestsSizeMap.get(uid));
+ } else {
+ ajaxContext.setResponseData(null);
+ }
+ } else if (FileUploadConstants.FILE_UPLOAD_ACTION_STOP.equals(actionString)) {
+ MultipartRequest multipartRequest = MultipartRequest.lookupRequest(facesContext, uid);
+ if (multipartRequest != null) {
+ multipartRequest.stop();
+ }
+ }
}
- //Lookup index of first '_' in string locale representation.
- int index1 = localeStr.indexOf("_");
- //Get first charters (if exist) from string
- String language = null;
- if(index1!=-1){
- language = localeStr.substring(0, index1);
- }else{
- return new Locale(localeStr);
- }
- //Lookup index of second '_' in string locale representation.
- int index2 = localeStr.indexOf("_", index1+1);
- String country = null;
- if(index2!=-1){
- country = localeStr.substring(index1+1, index2);
- String variant = localeStr.substring(index2+1);
- return new Locale(language, country, variant);
- }else{
- country = localeStr.substring(index1+1);
- return new Locale(language, country);
- }
+ super.broadcast(e);
}
-
- public Locale getAsLocale(Object locale) {
- if (locale instanceof Locale) {
+/**
+ *Parse Locale from String.
+ *String must be represented as Locale.toString(); xx_XX_XXXX
+ */
- return (Locale) locale;
+public Locale parseLocale(String localeStr){
- } else if (locale instanceof String) {
+ int length = localeStr.length();
+ if(null==localeStr||length<2){
+ return Locale.getDefault();
+ }
- return parseLocale((String) locale);
+ //Lookup index of first '_' in string locale representation.
+ int index1 = localeStr.indexOf("_");
+ //Get first charters (if exist) from string
+ String language = null;
+ if(index1!=-1){
+ language = localeStr.substring(0, index1);
+ }else{
+ return new Locale(localeStr);
+ }
+ //Lookup index of second '_' in string locale representation.
+ int index2 = localeStr.indexOf("_", index1+1);
+ String country = null;
+ if(index2!=-1){
+ country = localeStr.substring(index1+1, index2);
+ String variant = localeStr.substring(index2+1);
+ return new Locale(language, country, variant);
+ }else{
+ country = localeStr.substring(index1+1);
+ return new Locale(language, country);
+ }
+}
- } else {
+public Locale getAsLocale(Object locale) {
- FacesContext context = FacesContext.getCurrentInstance();
- Application application = context.getApplication();
- Converter converter = application
- .createConverter(locale.getClass());
- if (null != converter) {
- return parseLocale(converter.getAsString(context, this, locale));
- } else {
- throw new FacesException(
- "Wrong locale attibute type or there is no converter for custom attibute type");
- }
+ if (locale instanceof Locale) {
+
+ return (Locale) locale;
+
+ } else if (locale instanceof String) {
+
+ return parseLocale((String) locale);
+
+ } else {
+
+ FacesContext context = FacesContext.getCurrentInstance();
+ Application application = context.getApplication();
+ Converter converter = application
+ .createConverter(locale.getClass());
+ if (null != converter) {
+ return parseLocale(converter.getAsString(context, this, locale));
+ } else {
+ throw new FacesException(
+ "Wrong locale attibute type or there is no converter for custom attibute type");
}
}
}
+}
Added: trunk/ui/fileUpload/src/main/java/org/richfaces/event/UploadAjaxActionEvent.java
===================================================================
--- trunk/ui/fileUpload/src/main/java/org/richfaces/event/UploadAjaxActionEvent.java (rev 0)
+++ trunk/ui/fileUpload/src/main/java/org/richfaces/event/UploadAjaxActionEvent.java 2009-03-12 20:22:50 UTC (rev 12947)
@@ -0,0 +1,40 @@
+/**
+ *
+ */
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+
+import org.ajax4jsf.event.AjaxEvent;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.1
+ */
+public class UploadAjaxActionEvent extends AjaxEvent {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -9018152705741192920L;
+
+ private String action;
+
+ private String uploadId;
+
+ public UploadAjaxActionEvent(UIComponent component, String action, String uploadId) {
+ super(component);
+
+ this.action = action;
+ this.uploadId = uploadId;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
+ public String getUploadId() {
+ return uploadId;
+ }
+
+}
Modified: trunk/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java
===================================================================
--- trunk/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java 2009-03-12 19:57:38 UTC (rev 12946)
+++ trunk/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java 2009-03-12 20:22:50 UTC (rev 12947)
@@ -48,7 +48,6 @@
import javax.servlet.http.HttpSession;
import org.ajax4jsf.context.AjaxContext;
-import org.ajax4jsf.event.AjaxEvent;
import org.ajax4jsf.javascript.JSFunction;
import org.ajax4jsf.javascript.JSFunctionDefinition;
import org.ajax4jsf.javascript.JSLiteral;
@@ -64,6 +63,7 @@
import org.richfaces.component.UIFileUpload;
import org.richfaces.component.UIProgressBar;
import org.richfaces.component.util.HtmlUtil;
+import org.richfaces.event.UploadAjaxActionEvent;
import org.richfaces.event.UploadEvent;
import org.richfaces.model.UploadItem;
@@ -115,52 +115,53 @@
@Override
@SuppressWarnings("unchecked")
protected void doDecode(FacesContext context, UIComponent component) {
-
- new AjaxEvent(component).queue();
-
+ UIFileUpload fileUpload = (UIFileUpload) component;
+ String clientId = component.getClientId(context);
ExternalContext externalContext = context.getExternalContext();
Map<String, String> requestParameterMap = externalContext.getRequestParameterMap();
- String fileUploadIndicator = requestParameterMap.get(FileUploadConstants.FILE_UPLOAD_INDICATOR);
- if (fileUploadIndicator != null && Boolean.TRUE.toString().equals(fileUploadIndicator)) {
- UIFileUpload fileUpload = (UIFileUpload) component;
- String clientId = component.getClientId(context);
- String id = requestParameterMap.get(clientId);
+ if (requestParameterMap.get(clientId) != null) {
+ String actionString = requestParameterMap.get(FileUploadConstants.FILE_UPLOAD_ACTION);
+
+ String uid = requestParameterMap.get(FileUploadConstants.UPLOAD_FILES_ID);
+
+ if (actionString != null) {
+ new UploadAjaxActionEvent(component, actionString, uid).queue();
+ }
- if (id == null) {
- return; // Avoid listener calling for another fileUpload
- }
-
- String uid = requestParameterMap.get(FileUploadConstants.UPLOAD_FILES_ID);
- decreaseFileCounter(context, id);
-
- MultipartRequest multipartRequest = MultipartRequest.lookupRequest(context, uid);
-
- boolean isFlash = (requestParameterMap.get("_richfaces_send_http_error") != null);
-
- List<UploadItem> fileList = multipartRequest.getUploadItems();
-
- if (fileList == null || fileList.size() == 0) {
- return;
- }
-
- boolean formUpload = multipartRequest.isFormUpload();
-
- if (isFlash && !formUpload && fileList.size() > 0) {
- try {
- UploadItem item = fileList.get(0);
- int actualSize = item.getFileSize();
- int clientSize = Integer.parseInt(requestParameterMap.get("_richfaces_size"));
-
- if (actualSize != clientSize) {
- return; // File uploading has been stopped on the client side
- }
- }catch (Exception e) {
+ String fileUploadIndicator = requestParameterMap.get(FileUploadConstants.FILE_UPLOAD_INDICATOR);
+ if (fileUploadIndicator != null && Boolean.TRUE.toString().equals(fileUploadIndicator)) {
+ decreaseFileCounter(context, clientId);
+
+ MultipartRequest multipartRequest = MultipartRequest.lookupRequest(context, uid);
+
+ boolean isFlash = (requestParameterMap.get("_richfaces_send_http_error") != null);
+
+ List<UploadItem> fileList = multipartRequest.getUploadItems();
+
+ if (fileList == null || fileList.size() == 0) {
return;
}
+
+ boolean formUpload = multipartRequest.isFormUpload();
+
+ if (isFlash && !formUpload && fileList.size() > 0) {
+ try {
+ UploadItem item = fileList.get(0);
+ int actualSize = item.getFileSize();
+ int clientSize = Integer.parseInt(requestParameterMap.get("_richfaces_size"));
+
+ if (actualSize != clientSize) {
+ return; // File uploading has been stopped on the client side
+ }
+ }catch (Exception e) {
+ return;
+ }
+ }
+ onUploadComplete(context, fileList, fileUpload, formUpload);
}
- onUploadComplete(context, fileList, fileUpload, formUpload);
}
+
}
@@ -451,7 +452,7 @@
Map options = AjaxRendererUtils.buildEventOptions(context, component);
Map parameters = (Map) options.get("parameters");
- parameters.put("action", action);
+ parameters.put(FileUploadConstants.FILE_UPLOAD_ACTION, action);
parameters.put(FileUploadConstants.UPLOAD_FILES_ID, new JSReference("uid"));
parameters.put(clientId, clientId);
parameters.put(AjaxRendererUtils.AJAX_SINGLE_ATTR, clientId);
15 years, 5 months
JBoss Rich Faces SVN: r12946 - in trunk/ui/fileUpload/src/main: resources/org/richfaces/renderkit/html/js and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-03-12 15:57:38 -0400 (Thu, 12 Mar 2009)
New Revision: 12946
Modified:
trunk/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java
trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js
Log:
https://jira.jboss.org/jira/browse/RF-5960 + empty catch blocks removed
Modified: trunk/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java
===================================================================
--- trunk/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java 2009-03-12 19:38:26 UTC (rev 12945)
+++ trunk/ui/fileUpload/src/main/java/org/richfaces/renderkit/FileUploadRendererBase.java 2009-03-12 19:57:38 UTC (rev 12946)
@@ -125,9 +125,9 @@
if (fileUploadIndicator != null && Boolean.TRUE.toString().equals(fileUploadIndicator)) {
UIFileUpload fileUpload = (UIFileUpload) component;
String clientId = component.getClientId(context);
- String id = requestParameterMap.get("id");
+ String id = requestParameterMap.get(clientId);
- if (!clientId.equals(id)) {
+ if (id == null) {
return; // Avoid listener calling for another fileUpload
}
@@ -406,16 +406,12 @@
private void onUploadComplete(FacesContext context, List<UploadItem> fileList,
UIFileUpload fileUpload, boolean formUpload) {
storeData(context, fileUpload, fileList);
- try {
- AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
- if ((Boolean)fileUpload.getAttributes().get(AjaxRendererUtils.AJAX_SINGLE_ATTR)) {
- ajaxContext.setAjaxSingleClientId(fileUpload.getClientId(context));
- }
-
- ajaxContext.setAjaxRequest(!formUpload);
- } catch (Exception e) {
- e.getMessage();
+ AjaxContext ajaxContext = AjaxContext.getCurrentInstance(context);
+ if ((Boolean)fileUpload.getAttributes().get(AjaxRendererUtils.AJAX_SINGLE_ATTR)) {
+ ajaxContext.setAjaxSingleClientId(fileUpload.getClientId(context));
}
+
+ ajaxContext.setAjaxRequest(!formUpload);
}
/*
@@ -546,34 +542,30 @@
CountingOutputWriter customWriter = new CountingOutputWriter();
StringBuffer result = null;
UIComponent label = component.getFacet("label");
- try {
- if (label != null) {
+ if (label != null) {
- ResponseWriter writer = context.getResponseWriter();
+ ResponseWriter writer = context.getResponseWriter();
- String defaultRenderKitId = context.getApplication()
- .getDefaultRenderKitId();
- if (null == defaultRenderKitId) {
- defaultRenderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
- }
- RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder
- .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
- RenderKit renderKit = renderKitFactory.getRenderKit(context,
- defaultRenderKitId);
-
- ResponseWriter responseWriter = renderKit.createResponseWriter(
- customWriter, null, "UTF-8");
- context.setResponseWriter(responseWriter);
- writeScriptBody(context, label, false);
- if (writer != null) {
- context.setResponseWriter(writer);
- }
- result = customWriter.getContent();
+ String defaultRenderKitId = context.getApplication()
+ .getDefaultRenderKitId();
+ if (null == defaultRenderKitId) {
+ defaultRenderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
}
+ RenderKitFactory renderKitFactory = (RenderKitFactory) FactoryFinder
+ .getFactory(FactoryFinder.RENDER_KIT_FACTORY);
+ RenderKit renderKit = renderKitFactory.getRenderKit(context,
+ defaultRenderKitId);
- } catch (Exception e) {
- e.getMessage();
+ ResponseWriter responseWriter = renderKit.createResponseWriter(
+ customWriter, null, "UTF-8");
+ context.setResponseWriter(responseWriter);
+ writeScriptBody(context, label, false);
+ if (writer != null) {
+ context.setResponseWriter(writer);
+ }
+ result = customWriter.getContent();
}
+
return (result != null) ? new JSLiteral(result.toString())
: JSReference.NULL;
}
Modified: trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js
===================================================================
--- trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js 2009-03-12 19:38:26 UTC (rev 12945)
+++ trunk/ui/fileUpload/src/main/resources/org/richfaces/renderkit/html/js/FileUpload.js 2009-03-12 19:57:38 UTC (rev 12946)
@@ -1035,7 +1035,7 @@
Richfaces.writeAttribute(parentForm, "enctype", "multipart/form-data");
Richfaces.writeAttribute(parentForm, "action",
- this.actionUrl + (/\?/.test(this.actionUrl) ? '&_richfaces_upload_uid' : '?_richfaces_upload_uid') + '=' + encodeURI(entry.uid) + "&id=" + this.id + "&_richfaces_upload_file_indicator=true"+"&AJAXREQUEST="+this.progressBar.containerId);
+ this.actionUrl + (/\?/.test(this.actionUrl) ? '&_richfaces_upload_uid' : '?_richfaces_upload_uid') + '=' + encodeURI(entry.uid) + "&" + this.id + "=" + this.id + "&_richfaces_upload_file_indicator=true"+"&AJAXREQUEST="+this.progressBar.containerId);
Richfaces.writeAttribute(parentForm, "target", this.id + "_iframe");
@@ -1117,7 +1117,7 @@
Richfaces.writeAttribute(f, "encoding", "multipart/form-data");
Richfaces.writeAttribute(f, "enctype", "multipart/form-data");
Richfaces.writeAttribute(f, "action",
- this.actionUrl + (/\?/.test(this.actionUrl) ? '&_richfaces_upload_uid' : '?_richfaces_upload_uid') + '=_richfaces_form_upload' + "&id=" + this.id + "&_richfaces_upload_file_indicator=true");
+ this.actionUrl + (/\?/.test(this.actionUrl) ? '&_richfaces_upload_uid' : '?_richfaces_upload_uid') + '=_richfaces_form_upload' + "&" + this.id + "=" + this.id + "&_richfaces_upload_file_indicator=true");
this.currentInput.disabled = true;
this._enableEntries(false);
@@ -1237,7 +1237,7 @@
},
_flashGetActionUrl: function (url, entry) {
- var getParams = "_richfaces_upload_uid="+ encodeURI(entry.uid) + "&id=" + this.id + "&_richfaces_upload_file_indicator=true&_richfaces_size="+entry.size+"&_richfaces_send_http_error=true";
+ var getParams = "_richfaces_upload_uid="+ encodeURI(entry.uid) + "&" + this.id + "=" + this.id + "&_richfaces_upload_file_indicator=true&_richfaces_size="+entry.size+"&_richfaces_send_http_error=true";
if (/\?/.test(url)) {
var i = url.indexOf("?");
url = url.substring(0, i) + ";jsessionid=" + this.sessionId + url.substring(i) + "&" + getParams;
15 years, 5 months