Re: ERXDisplayGroup ---> ERXBatchingDisplayGroup
Re: ERXDisplayGroup ---> ERXBatchingDisplayGroup
- Subject: Re: ERXDisplayGroup ---> ERXBatchingDisplayGroup
- From: Pascal Robert <email@hidden>
- Date: Fri, 16 Mar 2012 08:16:01 -0400
Le 2012-03-16 à 08:08, Ron X a écrit :
> but how can i connect this component with datasource?
dgOrganizations is a ERXBatchingDisplayGroup, so you just need to setup that display group.
public Organizations(WOContext context) {
super(context);
EODatabaseDataSource ds = new EODatabaseDataSource(ec, OrganizationProfile.ENTITY_NAME);
dgOrganizations = new ERXBatchingDisplayGroup<OrganizationProfile>();
dgOrganizations.setNumberOfObjectsPerBatch(10);
dgOrganizations.setDataSource(ds);
dgOrganizations.setSortOrderings(new NSArray<EOSortOrdering>(lastUpdateSort));
}
@Override
public void awake() {
super.awake();
isServiceFilter = false;
dgOrganizations.fetch();
queryArgs = new NSMutableDictionary<Object, String>();
}
public void setBatchIndex(int batchIndex) {
dgOrganizations.setCurrentBatchIndex(batchIndex);
queryArgs.takeValueForKey(batchIndex, "batch");
}
The "organizations" direct action:
public WOActionResults organizationsAction() {
String strBatchIndex = this.request().stringFormValueForKey("batch");
Integer batchIndex = new Integer(1);
if (strBatchIndex != null) {
try {
batchIndex = new Integer(strBatchIndex);
} catch (Exception e) {
NSLog.out.appendln("Someone tried to access a batch index with this value : " + strBatchIndex);
}
}
Organizations nextPage = (Organizations)pageWithName(Organizations.class);
nextPage.setBatchIndex(batchIndex.intValue());
return nextPage;
}
> 2012/3/13 Pascal Robert <email@hidden>
> Use ERXDirectActionBatchNavigationBar
>
> <wo:ERXDirectActionBatchNavigationBar
> actionName = "organizations"
> containerCssClass = "paginator"
> batchSize = "$dgOrganizations.batchCount"
> currentBatchIndex = "$dgOrganizations.currentBatchIndex"
> showPageNumbers = true
> numberOfObjects = "$dgOrganizations.allObjects.@count"
> />
>
> Please note that it will use Direct Actions, so it won't work with REST routes. I'm planning to do a similar component for REST because I need it for wocommunity.org, but I won't work on this before end of this month.
>
> > sorry, maybe i explain bad.
> >
> > "so the workflow is so" - that is how it works NOW.
> > but i want to fetching objects at every click of the page and do not changing the url (or have control of changing).
> >
> > 2012/3/13 Pascal Robert <email@hidden>
> > EODatabaseDataSource dataSource = new EODatabaseDataSource(editingContext(), Category.ENTITY_NAME);
> > er.extensions.batching.ERXBatchingDisplayGroup dg = new ERXBatchingDisplayGroup<Category>();
> > dg.setNumberOfObjectsPerBatch(20);
> > dg.setDataSource(dataSource);
> > dg.setObjectArray(Category.fetchAllCategories(editingContext()));
> >
> > > hi everybody.
> > > i have some legasy code.
> > > in this code used ERXDisplayGroup:
> > >
> > > //code:
> > > import com.webobjects.appserver.WOContext;
> > > import com.webobjects.appserver.WODisplayGroup;
> > > import com.webobjects.directtoweb.ERD2WUtilities;
> > >
> > > import er.directtoweb.pages.ERD2WListPage;
> > > import er.extensions.batching.ERXBatchingDisplayGroup;
> > > import er.extensions.batching.ERXFlickrBatchNavigation;
> > >
> > > public class BatchNavigationBar extends ERXFlickrBatchNavigation {
> > > public BatchNavigationBar(WOContext context) {
> > > super(context);
> > > }
> > >
> > > private ERD2WListPage listPage() {
> > > return (ERD2WListPage) ERD2WUtilities.enclosingPageOfClass(this, ERD2WListPage.class);
> > > }
> > >
> > > @Override
> > > public WODisplayGroup displayGroup() {
> > > return listPage().displayGroup();
> > > }
> > >
> > > public void setCurrentBatchIndex(Integer batchIndex) {
> > > displayGroup().setCurrentBatchIndex(batchIndex);
> > > }
> > > }
> > > //end code
> > >
> > > so the workflow is so:
> > >
> > > 1. fetching ALL object of query in array.
> > > 2. and than give me a portion (size if batch) when i am clicking next/prev pages in this component.
> > > 3. but NO work with database per batch - it works with array
> > > 4. when i click next/prev - it adds to the urls of pagination some like this - 1.2.3.1.5.6.7 etc :-) and this brakes my statistics with SEO links.
> > >
> > > so i want to avoid this. and i want to use ERXBatchingDisplayGroup instead of WODisplayGroup (ERXDisplayGroup).
> > > Simple casting not works - falls with cast exception.
> > > the problem in that listPage().displayGroup() - has type WODisplayGroup.
> > >
> > > how can i use in this code ERXBatchingDisplayGroup?
> > >
> > > _______________________________________________
> > > Do not post admin requests to the list. They will be ignored.
> > > Webobjects-dev mailing list (email@hidden)
> > > Help/Unsubscribe/Update your Subscription:
> > >
> > > This email sent to email@hidden
> >
> >
>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden