I'm writing a auto-refresh component that refreshes the page using
javascript and resets the scroll position to the pre-refresh position.
 To do this, I have created a Refresher component.

Quick rundown:

The Refresher component is an extension of BaseComponent.  The
template contains a simple form with 2 hidden fields.  One is used to
track the x-offset of the horizontal scroll bar, and the other is used
to track the vertical offset of the scrollbar.  Their values are bound
to the xCoord and yCoord properties of the Refresher component.  The
template also injects a script.

The script records the x and y offsets into the aforementioned hidden
fields everytime the page moves or the user clicks or types.  It also
resets the x and y offsets during the onLoad method of the page.  at
the end of onLoad, it uses the javascript setTimeout method to submit
the form to a listener in the Refresher component.  The listener does
nothing, but exists just to have a place to submit the form to so that
the x and y coordinates get stored so they can be reset.

The properties that store the x and y coordinates are where I am
having huge problems.

I don't need access to them in the class, so I've just defined them
via property elements in the Refresher.jwc spec.  This works fine --
the page refreshes and all is well.  The problem is that the page(s)
that will use this component have several links/buttons that will
submit to the page and re-display the same page.  After this request
(which does not submit the x and y coordinates as it is part of a
different form) the page should redisplay with the correct scroll
state.  This doesn't happen because, as I mentioned, this other form
doesn't submit the scroll state.

My first attempt was to add persistence to the xCoord and yCoord
properties in the Refresher.jwc via persist="session" attributes on
the properties.  This causes the page to fail with an exception on the
second refresh.  The first refresh works and the scroll state is
correct, but on the second refresh I get an exception saying that the
Refresher component does not have an xCoord property.

Class $Refresher_51 does not contain a property named 'xCoord'.
org.apache.hivemind.util.ClassAdaptor.getPropertyAdaptor(ClassAdaptor.java:136)

Also, If I add abstract accessors to the Refresher class for the x and y coords:
    public abstract int getXCoord();
    public abstract int getYCoord();
I get errors saying that Refresher already has a getXCoord method:

Error at classpath:/package/refresh/Refresher.jwc, line 5, column 134:
Error adding property XCoord to class package.refresh.Refresher:
Unable to add method int getXCoord() to class $Refresher_18: duplicate
method: getXCoord

Can anyone shed some light on what I'm doing wrong?  Other components
use persistence (tableview, treeview) so I know it's possible, clearly
I'm just screwing up.

Any help would be great.

Thanks,
-Mike

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to