-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add list filter component that allows filtering on attributes specifi…
…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
Showing
9 changed files
with
438 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...ModernDirectToWeb/Components/Nonlocalized.lproj/ERMD2WListFilter.wo/ERMD2WListFilter.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
13 changes: 13 additions & 0 deletions
13
...RModernDirectToWeb/Components/Nonlocalized.lproj/ERMD2WListFilter.wo/ERMD2WListFilter.wod
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} |
4 changes: 4 additions & 0 deletions
4
...RModernDirectToWeb/Components/Nonlocalized.lproj/ERMD2WListFilter.wo/ERMD2WListFilter.woo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"WebObjects Release" = "WebObjects 5.0"; | ||
encoding = "UTF-8"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
78 changes: 78 additions & 0 deletions
78
.../ERModernDirectToWeb/Sources/er/modern/directtoweb/components/query/ERMD2WListFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} |
Oops, something went wrong.