I usually add a method to my entity to return distinct
public static NSArray<Grid> fetchDistinctGrids(EOEditingContext editingContext,
EOQualifier qualifier, NSArray<EOSortOrdering> sortOrderings) {
ERXFetchSpecification<Grid> fetchSpec = new
ERXFetchSpecification<Grid>(_Grid.ENTITY_NAME, qualifier, sortOrderings);
fetchSpec.setIsDeep(true);
fetchSpec.setUsesDistinct(true);
NSArray<Grid> eoObjects = fetchSpec.fetchObjects(editingContext);
return eoObjects;
}
now my entity knows how to return a distinct NSArray and I don't have to create
a fetch spec on the entity. I always seemed to have problems when I created
them in Entity Modeler.
Ted
On Nov 3, 2013, at 8:50 PM, Thomas Peters <[email protected]> wrote:
>
> Hi All,
> I created a Fetch Specification named 'DistinctCategories' in my Movie EO,
> and have select the Distinct rows option. I also have it set to return
> Specific Attributes as raw rows and have only the category attribute
> selected. I am linking that to my NewCategoryPop WOPopUpButton through the
> class property distinctCategories. I need this drop down to represent the
> newcategory property in my form below. It seems that the NSArray is
> configuring it with the option value set to the index of the array and the
> displayString set to the Movie object, not the value of the category. The
> page displays the same value no pater if I have the item & displayString
> values set in my Dynamic Component. What am I doing wrong?
>
> Thomas
>
>
> // Main.java
>
> private Movie acategory; // Stores the value of the Category search
> field.
> private NSArray<Movie> distinctCategories; // Stores the results of a
> search.
> ...
> public NSArray<Movie> getDistinctCategories() {
> return this.distinctCategories;
> }
>
> public void setDistinctCategories() {
> EOEditingContext ec = session().defaultEditingContext();
> NSArray<Movie> distinctCategories =
> EOUtilities.objectsWithFetchSpecificationAndBindings(ec, "Movie",
> "DistinctCategories", null);
> this.distinctCategories = distinctCategories;
> }
> ...
>
> // Main.wo
> NewCategoryPop : WOPopUpButton {
> list = distinctCategories;
> item = acategory.category;
> displayString = acategory.category;
> selectedValue = newcategory;
> }
>
> My Fetch Specification is set to return a distinct on the category property.
> That seems to be returning the right number of rows, but I am getting an
> Object in the WOPopupButton option list.
>
> <form method="post" enctype="multipart/form-data"
> action="/cgi-bin/WebObjects/Hello.woa/wo/8v9GksUm8D3deHrl4b0VAw/3.5.3">
> <table class="simple">
> <tr><td>Title:</td><td><input type="text" name="5.3.1"
> /></td></tr>
> <tr><td>Category:</td><td><select name="5.3.3"><option
> value="0">{category = "Comedy"; }</option><option
> value="1">{category = "Drama"; }</option><option
> value="2">{category = "SiFy"; }</option><option value="3">{category
> = "Test"; }</option><option value="4">{category = "War";
> }</option></select></td></tr>
> <tr><td>Date Released:</td><td><input type="text" name="5.3.5"
> /></td></tr>
> <tr><td colspan=2 ><input type="submit" value="Insert"
> name="5.3.7" /></td></tr>
> </table>
> <input type="hidden" name="wosid" value="8v9GksUm8D3deHrl4b0VAw"
> /></form>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list ([email protected])
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/tedpet5%40yahoo.com
>
> This email sent to [email protected]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]