Re: RR loop confusion....
Re: RR loop confusion....
- Subject: Re: RR loop confusion....
- From: Helge Städtler <email@hidden>
- Date: Tue, 26 Jul 2005 08:48:19 +0200
Hi Florijan!
To have a little bit shorter answer:
You could also try to turn off auto-synchronization of the component in
question. Just overwrite the corresponding method by something like this
public boolean synchronizesVariablesWithBindings() {
return false;
}
>From now on, the "Magic" of how WebObjects gets/sets all the values
*BETWEEN* interrelated components via the bindings is deactivated, e.g. you
will have to pull out the values from the bindings of the component manually
and you need to push up values manually. E.g. pulling values using a method
like
public String myStringValue() {
if( valueForBinding( "myStringBindingName" ) == null ) return
"noString";
return (String)valueForBinding( "myStringBindingName" );
}
I made nearly all of my components in my applications non-synchronizing,
because this may become some real overhead for performance and at the same
time its more transparent to me what actually happens with the values.
Independent from that synchronization mechanism, WO will follow the RR-Loop
by still executing the already mentioned methods Jerry W. Walker wrote
about. So generally your value-providing-methods (Strings, NSArrays and so
on) should stay consistent/stable in what they deliver throughout the
complete RR-Loop. Especially keep the reference of NSArrays and the content
of them stable e.g. by creating a local copy which is valid throughout the
complete RR-Loop, otherwise the magic of WO is unable to e.g. pick
automatically the right objects from a dropdownlist or some checkboxes...
...this is by the way a very common error one makes.
regards,
Helge
Am 25.07.2005 19:57 Uhr schrieb "Florijan Stamenkovic" unter
<email@hidden> / On 25.07.2005 19:57 Uhr "Florijan Stamenkovic" wrote
using address <email@hidden>:
> Hi all...
>
> Bumped into something I really can not figure out. Any help would be
> greatly appreciated.
>
> I got a repetition that has a list binding to a method returning
> NSArray. Method is called resultsPerPage(). After logging the RR loop I
> saw that the resultsPerPage() method gets called in just about every
> stage of the loop. If I clicked on a submit within a form, it gets
> called in takeValuesFromRequest (the repetition the method is bound to
> is NOT within the form), in invokeAction, and finally in
> appendToResponse... Why??? Not to mention that the methods that are
> invoked (component actions) do not invoke it. The only binding /
> invocation is the repetition itself (checked).
>
> /*************
> Skippable details:
> The problem became visible when I started using NSRange within the
> resultsPerPage(). It throws exceptions because it's second argument is
> negative. The cause of that is that resultsPerPage() is using two
> variables: delimiter(how many results per page) and currentPage. The
> problem appears because delimiter can be changed during
> takeValuesForRequest as it is bound to a text field. The currentPage
> gets reset to 1 during invokeAction, a precaution taken not to end up
> with attempting to display a page that actually is no longer there (if
> the update delimiter is so big that there is no need for so many
> pages). The delimiter is in a form that has a single button that is
> bound to a method that resets the currentPage to 1. So, it is
> impossible to change the delimiter without invoking that particular
> method. However, as the resultsPerPage() method gets called before
> invokeAction(), the delimiter is updated to a different value, but the
> currentPage is still on the old value, what can result in gibberish
> values when determining the range of the array that should be returned
> as a subarray of the bigger, cached array..
> ********/
>
> So, how come that a key method gets invoked so many times during the RR
> loop?? Does anybody have a better solution to having a dynamically
> resolved subset of a search query?
>
> TIA
> Flor
>
>
> oh - just to note that I have used this a lot now, but not utilizing
> NSRange, but by copying manually records into a NSMutableArray, and
> checking that I am not out of bounds. Which of course resulted in an
> empty array in all the RR stages before the response were really
> generated, but that didn't throw any exceptions. The generated response
> had all the numbers right of cours...
>
> _______________________________________________
> 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