[JBoss JIRA] Created: (RF-8262) Unnecessary filtering of fields in a Richfaces DataTable
by Sebastian Rueber (JIRA)
Unnecessary filtering of fields in a Richfaces DataTable
--------------------------------------------------------
Key: RF-8262
URL: https://jira.jboss.org/jira/browse/RF-8262
Project: RichFaces
Issue Type: Patch
Security Level: Public (Everyone can see)
Components: component, component-ScrollableDataTable, component-tables
Reporter: Sebastian Rueber
This patch is a solution for the DataTable problem, when using the internal filter.
e.g.:
<rich:dataTable value="${bean.listDataModel}" var="row">
<rich:column filterBy="row.name" />
reason for this problem is the class org.richfaces.model.ModifiableModel with its method filter(...)
the method filter(...) always calculates the filterBy value for all cells and rows in the table, which has the
filter expression.
example:
500 rows and 7 columns leads to 3500 calculations. it depends on how complex the expressions are, but it
may take a while.
in some cases the expressions are calculated unnecessary.
example 1: empty filter fields
if the user has not entered any filter expressions in fields with a filter attribute, for example if the table is rendered initialy.
calculated expressions 3500
needed expressions 0
example 2: shortcut evaluation
the filter fields are linked by an AND logical operator. that means, if you have 7 fields and the first does not match,
the remaining 6 field should not be evaluated.
calculated expressions 3500
needed expressions 3500 - x
in our application we are using our own table model, but i would like to contribute some code, which may give you
an idea, how to fix this quickly.
solution code for filter method
@Override
protected List<Object> filter(List<FilterField> aFilterFields) {
List<Object> filteredCollection = new ArrayList<Object>();
ExpressionFactory tempFactory = new ExpressionFactory(FacesContext.getCurrentInstance(), var, aFilterFields);
for (Object temp : rowKeys) {
Integer tempKey = (Integer) temp;
Sample tempSample = data.get(tempKey);
if (accept(tempSample, aFilterFields, tempFactory)) {
filteredCollection.add(tempKey);
}
}
rowKeys = filteredCollection;
return rowKeys;
}
public boolean accept(Sample aSample, List<FilterField> aFilterList, ExpressionFactory aFactory) {
for (FilterField filterField : aFilterList) {
if (filterField instanceof ExtendedFilterField) {
String filterValue = ((ExtendedFilterField) filterField).getFilterValue();
if (filterValue != null) {
filterValue = filterValue.trim().toUpperCase(locale);
if (filterValue.length() > 0) {
// delayed until here, were it is really needed
Object property = aFactory.eval(filterField.getExpression(), aSample);
if (property == null || !property.toString().trim().toUpperCase(locale).startsWith(filterValue)) {
return false;
}
}
}
} else {
Object property = aFactory.eval(filterField.getExpression(), aSample);
if (!((Boolean) property).booleanValue()) {
return false;
}
}
}
return true;
}
solution code for the ExpressionFactory
package org.richfaces.model.impl.expressive;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.el.ELContext;
import javax.el.ELResolver;
import javax.el.MethodExpression;
import javax.el.ValueExpression;
import javax.faces.application.Application;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import org.richfaces.model.Field;
public class ExpressionFactory {
private Map<javax.el.Expression, Expression> expressionMap;
public ExpressionFactory(FacesContext context, final String var, List<? extends Field> sortOrder) {
Application application = context.getApplication();
ELResolver resolver = application.getELResolver();
ELContext elContext = context.getELContext();
expressionMap = new HashMap<javax.el.Expression, Expression>();
for (Field field : sortOrder) {
javax.el.Expression elExpression = field.getExpression();
Expression expression;
if (elExpression instanceof ValueExpression) {
ValueExpression valueExpression = (ValueExpression) elExpression;
if (valueExpression.isLiteralText()) {
String expressionString = valueExpression.getExpressionString();
if (expressionString.startsWith(UIViewRoot.UNIQUE_ID_PREFIX)) {
expression = new NullExpression(expressionString);
} else {
expression = new SimplePropertyExpression(expressionString, elContext, resolver);
}
} else {
expression = new ValueBindingExpression(context, valueExpression, var);
}
} else if (elExpression instanceof MethodExpression) {
expression = new MethodBindingExpression(context, (MethodExpression) elExpression);
} else {
throw new IllegalArgumentException();
}
expressionMap.put(elExpression, expression);
}
}
public Object eval(javax.el.Expression anExpression, Object anObject) {
return expressionMap.get(anExpression).evaluate(anObject);
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 9 months
[JBoss JIRA] Created: (RF-7916) Javascript error when having non escaped apostrophe in rich:calendar labels
by Julien Kronegg (JIRA)
Javascript error when having non escaped apostrophe in rich:calendar labels
---------------------------------------------------------------------------
Key: RF-7916
URL: https://jira.jboss.org/jira/browse/RF-7916
Project: RichFaces
Issue Type: Bug
Components: component-output
Affects Versions: 3.3.0
Environment: Seam 2.1.2, Richfaces 3.3.0
Reporter: Julien Kronegg
Priority: Minor
Richfaces Calendar labels can be translated/i18n by adding the following properties in the resource bundle (e.g. messages.properties):
RICH_CALENDAR_TODAY_LABEL
RICH_CALENDAR_CLEAN_LABEL
RICH_CALENDAR_APPLY_LABEL
RICH_CALENDAR_CLOSE_LABEL
RICH_CALENDAR_OK_LABEL
RICH_CALENDAR_CANCEL_LABEL
The problem is that a Javascript error occurs when the property value contain a non escaped apostrophe ('), for example with RICH_CALENDAR_TODAY_LABEL=Aujourd'hui (french label for today):
Error: missing } after property list
Source Code: labels:{apply:'Appliquer', today:'Aujourd'hui', clean:'Effacer', cancel:'Annuler', ok:'Ok', close:'X'},
Richfaces should escape automatically unescaped apostrophes.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 9 months
[JBoss JIRA] Created: (RF-7709) realworld/ui: Albums tooltips are present shelves names in My shelves tree
by Inna Shchibrya (JIRA)
realworld/ui: Albums tooltips are present shelves names in My shelves tree
--------------------------------------------------------------------------
Key: RF-7709
URL: https://jira.jboss.org/jira/browse/RF-7709
Project: RichFaces
Issue Type: Bug
Components: examples
Affects Versions: 3.3.2.CR1
Environment: All browsers
Local
Reporter: Inna Shchibrya
Assignee: Andrey Markhel
Priority: Minor
Attachments: tooltip_albums.png
Precondition: Login to the application as a user with shelves and albums.
1. Move the mouse over a shelf name in My shelves tree. --> Tooltip with the shelf name has appeared. It's ok.
2. Open the shelf in My shelves tree. --> Albums of this shelf are present in My shelves tree. It's ok.
3. Move the mouse over an album name. --> Tooltip with the shelf name has appeared. See attachment.
Expected result: Tooltip with the album name should appear.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 9 months
[JBoss JIRA] Created: (RF-7710) realworld/ui: Sometimes the pop-up window with confirmation message is not visible
by Inna Shchibrya (JIRA)
realworld/ui: Sometimes the pop-up window with confirmation message is not visible
----------------------------------------------------------------------------------
Key: RF-7710
URL: https://jira.jboss.org/jira/browse/RF-7710
Project: RichFaces
Issue Type: Bug
Components: examples
Affects Versions: 3.3.2.CR1
Environment: All browsers
Local
Reporter: Inna Shchibrya
Assignee: Andrey Markhel
Priority: Minor
Precondition: Login to the application as a user with shelves, albums and images.
1. Click on the image from My shelves tree.
2. Scroll down the page and click on Delete button. --> The page is disabled but the pop-up window with confirmation message is not visible.
3. Scroll up the page. --> The pop-up window with confirmation message is visible.
Expected result: The pop-up window with confirmation message should be visible on that part of the page where the user is.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 9 months
[JBoss JIRA] Created: (RF-7715) realworld/ui: Long name of the image is cut on the page
by Inna Shchibrya (JIRA)
realworld/ui: Long name of the image is cut on the page
-------------------------------------------------------
Key: RF-7715
URL: https://jira.jboss.org/jira/browse/RF-7715
Project: RichFaces
Issue Type: Bug
Components: examples
Affects Versions: 3.3.2.CR1
Environment: All browsers
Local
Reporter: Inna Shchibrya
Assignee: Andrey Markhel
Priority: Minor
Attachments: long_image_name.png
Precondition: Login as a user with shelves, albums and images.
1. Click on some image from My shelves tree.
2. Click on the image name on the page.
3. Change it on the name with more than 100 symbols and press Enter. --> The name of the image is cut. See attachment.
Expected result: Long name of the image shouldn't be cut or should has a tooltip with the whole name.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 9 months