Hi Geert,

Yeah, I tried it with an empty bean; no luck.

Upon further inspection (read it's no longer 2:30AM :) the clonable errors seem to be happening independent of the instance of the Venue object but inside the template processing somewhere due to the List<> I am passing to selectListHelper. The cookbook page(s) don't state anywhere that you need to implement a cloneable list or Iterator... so I guess it could be that something changed between the time the cookbook entry was written and now (I'm using the Rife-1.5.1 jar)...

Is there a better way to implements dynamic SELECTs coming say in 1.6 (hint, hint :) as its really a useful feature and quite common in forms (wink, wink, nudge, nudge :) ..?


Anyway, here's what I get:

com.uwyn.rife.engine.exceptions.EngineException

com.uwyn.rife.engine.exceptions.ElementLocalVariableUncloneableException : The implementation 'com.zeitgeist.nela.implementations.AddVenue' of element uses a local method variable of type 'java.util.AbstractList $Itr' which is not cloneable.

at com.uwyn.rife.engine.RequestState getContinuationContext ( RequestState.java : 151 ) at com.uwyn.rife.engine.RequestState getElementContext ( RequestState.java : 228 ) at com.uwyn.rife.engine.RequestState service ( RequestState.java : 335 )
at  com.uwyn.rife.engine.Gate      handleRequest        ( Gate.java : 421 )
at  sun.reflect.GeneratedMethodAccessor10          invoke       ( <unknown> )
at sun.reflect.DelegatingMethodAccessorImpl invoke ( DelegatingMethodAccessorImpl.java : 25 )
at  java.lang.reflect.Method       invoke       ( Method.java : 585 )
at com.uwyn.rife.servlet.RifeFilter doFilter ( RifeFilter.java : 142 ) at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain doFilter ( WebApplicationHandler.java : 823 ) at org.mortbay.jetty.servlet.WebApplicationHandler dispatch ( WebApplicationHandler.java : 473 ) at org.mortbay.jetty.servlet.ServletHandler handle ( ServletHandler.java : 567 ) at org.mortbay.http.HttpContext handle ( HttpContext.java : 1565 ) at org.mortbay.jetty.servlet.WebApplicationContext handle ( WebApplicationContext.java : 635 ) at org.mortbay.http.HttpContext handle ( HttpContext.java : 1517 )
at  org.mortbay.http.HttpServer            service      ( HttpServer.java : 954 
)
at org.mortbay.http.HttpConnection service ( HttpConnection.java : 814 ) at org.mortbay.http.HttpConnection handleNext ( HttpConnection.java : 981 )
4 more ...

com.uwyn.rife.engine.exceptions.ElementLocalVariableUncloneableException

The implementation 'com.zeitgeist.nela.implementations.AddVenue' of element uses a local method variable of type 'java.util.AbstractList $Itr' which is not cloneable.

at com.uwyn.rife.engine.ContinuationContext clone ( ContinuationContext.java : 408 ) at com.uwyn.rife.engine.ContinuationManager cloneContext ( ContinuationManager.java : 221 ) at com.uwyn.rife.engine.ContinuationManager createNewContext ( ContinuationManager.java : 161 ) at com.uwyn.rife.engine.RequestState getContinuationContext ( RequestState.java : 147 ) at com.uwyn.rife.engine.RequestState getElementContext ( RequestState.java : 228 ) at com.uwyn.rife.engine.RequestState service ( RequestState.java : 335 )
at  com.uwyn.rife.engine.Gate      handleRequest        ( Gate.java : 421 )
at  sun.reflect.GeneratedMethodAccessor10          invoke       ( <unknown> )
at sun.reflect.DelegatingMethodAccessorImpl invoke ( DelegatingMethodAccessorImpl.java : 25 )
at  java.lang.reflect.Method       invoke       ( Method.java : 585 )
at com.uwyn.rife.servlet.RifeFilter doFilter ( RifeFilter.java : 142 ) at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain doFilter ( WebApplicationHandler.java : 823 ) at org.mortbay.jetty.servlet.WebApplicationHandler dispatch ( WebApplicationHandler.java : 473 ) at org.mortbay.jetty.servlet.ServletHandler handle ( ServletHandler.java : 567 ) at org.mortbay.http.HttpContext handle ( HttpContext.java : 1565 ) at org.mortbay.jetty.servlet.WebApplicationContext handle ( WebApplicationContext.java : 635 ) at org.mortbay.http.HttpContext handle ( HttpContext.java : 1517 )
7 more ...

java.lang.CloneNotSupportedException

java.util.AbstractList$Itr

at com.uwyn.rife.tools.ObjectUtils deepClone ( ObjectUtils.java : 233 ) at com.uwyn.rife.engine.ContinuationStack clone ( ContinuationStack.java : 365 ) at com.uwyn.rife.engine.ContinuationContext clone ( ContinuationContext.java : 403 ) at com.uwyn.rife.engine.ContinuationManager cloneContext ( ContinuationManager.java : 221 ) at com.uwyn.rife.engine.ContinuationManager createNewContext ( ContinuationManager.java : 161 ) at com.uwyn.rife.engine.RequestState getContinuationContext ( RequestState.java : 147 ) at com.uwyn.rife.engine.RequestState getElementContext ( RequestState.java : 228 ) at com.uwyn.rife.engine.RequestState service ( RequestState.java : 335 )
at  com.uwyn.rife.engine.Gate      handleRequest        ( Gate.java : 421 )
at  sun.reflect.GeneratedMethodAccessor10          invoke       ( <unknown> )
at sun.reflect.DelegatingMethodAccessorImpl invoke ( DelegatingMethodAccessorImpl.java : 25 )
at  java.lang.reflect.Method       invoke       ( Method.java : 585 )
at com.uwyn.rife.servlet.RifeFilter doFilter ( RifeFilter.java : 142 ) at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain doFilter ( WebApplicationHandler.java : 823 ) at org.mortbay.jetty.servlet.WebApplicationHandler dispatch ( WebApplicationHandler.java : 473 ) at org.mortbay.jetty.servlet.ServletHandler handle ( ServletHandler.java : 567 ) at org.mortbay.http.HttpContext handle ( HttpContext.java : 1565 )
9 more ...






On Jan 4, 2007, at 4:35 AM, Geert Bevin wrote:

Hi David,

I never used this helper class, but it seems to me that you can create a new Venue object when the element is instantiated (private Venue mVenue = new Venue();). This will be your 'starting state', ie. an empty bean instance.

Also, I'm wondering which errors you get exactly about non-clonable objects. I suppose it's for the Venue instances. When using continuations, RIFE has to be able to clone your state for each continuation step for the back button to work correctly.

You have several options here:

* you don't care about the back button snapping back to previous state

Then you can just use setCloneContinuations(false) in your element, or override the cloneContinuations() method to return false.

* you want to carry around some state in between continuation steps (for example the venue data that they're filling in)

You can then implement the clone() method of your element and preserve the current venue instance for each clone, you can find an example of this here: http://rifers.org/08_advanced_continuations/ src/==%20syntax%20highlighted%20==/Order.java.html Note that you'll then probably use fillSubmissionBean when the data of each step comes in and not getSubmissionBean. This goes together well with the empty bean instance suggestion I made at the start of this message. It's also perfect to use with stepBack continuations.

* you want to clone each individual venue instance for the corresponding continuations

You'll have to implement the clone method of the Venue class. Chances are though that you can use the standard Object clone method that the JDK provides which creates a shallow copy and is perfect for the immutable basic Java types.
protected Object clone() throws CloneNotSupportedException {
    Venue new_venue = (Venue)super.clone();
    return new_venue;
}


When you have more complex data structures (collections, maps, arrays, ...), the ObjectUtils.deepClone method will allow you to create deep copies of most of the typical types that you use as bean properties.

Hope this helps.

Geert


I've been trying to follow the recipe for creating the dynamic select elements (http://tinyurl.com/y4ssym) but there's something I'm not understanding... the selectListHelper method wants the bean with the item to be the select target ("item" in the example) as part of its argument list ... which would need to be already populated ... which would mean that the form would already be posted so that getSubmissionBean() would have to have been called already so as to have a non-null bean to pass to selectListHelper().

--
Geert Bevin
Uwyn "Use what you need" - http://uwyn.com
RIFE Java application framework - http://rifers.org
Music and words - http://gbevin.com


_______________________________________________
Rife-users mailing list
[email protected]
http://lists.uwyn.com/mailman/listinfo/rife-users

------------------------------------------------------------------------ -------------------
                                          David HM Spector
spector (at) zeitgeist.com http://www.zeitgeist.com/ voice: +1 631.261.5013 fax: +1 212.656.1443
                                                    ~ ~ ~
"New and stirring things are belittled because if they are not belittled, the humiliating question arises, 'Why then are you not taking part in them?'" --H. G. Wells

_______________________________________________
Rife-users mailing list
[email protected]
http://lists.uwyn.com/mailman/listinfo/rife-users

Reply via email to