Skip to content

Commit

Permalink
Add list filter component that allows filtering on attributes specifi…
Browse files Browse the repository at this point in the history
…ed via the "searchKey" D2W key. Can handle strings, numbers, dates and (localized) enums. Specifying e.g. "(ID, name, dateCreated)" as "searchKey", would result in an ORed qualifier over those three attributes. The filtered list is updated via ajax. To enable, just specify a searchKey for the pageConfiguration.
  • Loading branch information
fbarthez authored and darkv committed Jan 14, 2016
1 parent 9323cf6 commit 03582e2
Show file tree
Hide file tree
Showing 9 changed files with 438 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,23 @@ div.RtActionCell li {
padding:0;
}

/* LIST FILTER */

.ListFilter {
position: relative;
top: 22px;
width: 40%;
padding: 0 100px;
margin: auto;
z-index: 100;
}

.ListFilter input {
font-size: 16px;
padding: 1px 3px;
width: 70%;
}

/* ATTACHMENT */

.AjaxFlexibleFileUpload {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class = "ListFilter">
<webobject name = "form">
<webobject name = "observeField"> <webobject name = "SearchField" /> </webobject>
</webobject>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
form : WOForm {
}

observeField : AjaxObserveField {
updateContainerID = d2wContext.idForMainContainer;
observeFieldFrequency = 1;
action = search;
}

SearchField: WOTextField {
value = searchValue;
type = "search";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"WebObjects Release" = "WebObjects 5.0";
encoding = "UTF-8";
}
3 changes: 3 additions & 0 deletions Frameworks/D2W/ERModernDirectToWeb/Resources/Properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Properies Info
er.extensions.load.Properties.framework.ERModernDirectToWeb=load
er.extensions.ERModernDirectToWeb.hasLocalization=true

# uncomment the following line to use European-style formats in ERMD2WListFilter
#er.modern.directtoweb.delegates.ERMD2WAttributeQueryDelegate.datePatterns=(dd.MM,dd.MM.,dd.MM.yy,dd.MM.yyyy,yyyy)
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package er.modern.directtoweb.components.query;

import com.webobjects.appserver.WOActionResults;
import com.webobjects.appserver.WOContext;
import com.webobjects.appserver.WOResponse;
import com.webobjects.eoaccess.EODatabaseDataSource;
import com.webobjects.eocontrol.EODataSource;
import com.webobjects.eocontrol.EOQualifier;

import er.ajax.AjaxUtils;
import er.directtoweb.components.ERDCustomQueryComponent;
import er.modern.directtoweb.delegates.ERMD2WAttributeQueryDelegate;
import er.modern.directtoweb.delegates.ERMD2WAttributeQueryDelegate.ERMD2WQueryComponent;

/**
* An ajax search field for ad-hoc filtering of lists. Similar to
* ERDAjaxSearchDisplayGroup, but enables filtering over multiple attributes.
*
* Gets displayed when the searchKey D2W key is not null.
*
* @d2wKey searchKey
* @d2wKey minimumCharacterCount
*
*/
public class ERMD2WListFilter extends ERDCustomQueryComponent implements
ERMD2WQueryComponent {

private static final long serialVersionUID = 1L;

public interface Keys extends ERDCustomQueryComponent.Keys {
public static final String searchKey = "searchKey";
public static final String typeAheadMinimumCharacterCount = "typeAheadMinimumCharacterCount";
}

private String _searchValue;

public ERMD2WListFilter(WOContext context) {
super(context);
}

@Override
public boolean synchronizesVariablesWithBindings() {
return false;
}

// actions
public WOActionResults search() {
EODataSource dataSource = displayGroup().dataSource();
EOQualifier _qualifier = ERMD2WAttributeQueryDelegate.instance
.buildQualifier(this);
((EODatabaseDataSource) dataSource).setAuxiliaryQualifier(_qualifier);
((EODatabaseDataSource) displayGroup().dataSource()).fetchSpecification()
.setUsesDistinct(true);
displayGroup().fetch();
displayGroup().setCurrentBatchIndex(1);
return null;
}

public void appendToResponse(WOResponse response, WOContext context) {
AjaxUtils.addScriptResourceInHead(context, response, "prototype.js");
super.appendToResponse(response, context);
}

public void setSearchValue(String searchValue) {
_searchValue = searchValue;
}

@Override
public String searchValue() {
return _searchValue;
}

@Override
public EODataSource dataSource() {
return displayGroup().dataSource();
}

}
Loading

0 comments on commit 03582e2

Please sign in to comment.