Issue Details (XML | Word | Printable)

Key: SHALE-220
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Craig McClanahan
Reporter: Craig McClanahan
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Shale

init() lifecycle method called twice

Created: 16/Jul/06 08:41 PM   Updated: 25/Sep/08 04:25 AM
Return to search
Component/s: View
Affects Version/s: 1.0.2, 1.0.3
Fix Version/s: 1.0.4


 Description  « Hide
From a user mailing list posting by Viswanath <v_ramineni AT hotmail.com>, following up on earlier mailing list conversations:

==========

Hi Craig,

Now that I have subscribed to Shale user group, I am posting this issue again.

Just to make sure that I am not using older version of Shale libraries, I have downloaded shale-framework-20060713.zip and tried, same problem. This is what I did, to reproduce the issue in usecases project. ( I am not able to post code from my project because of lot of dependencies on EJBs/Database)

I downloaded the latest usecases zip (07/14/2006). Unzipped the war file into a directory, created a project in eclipse, added the java source files, built and deployed it into JBOSS and it ran fine. Added the following code at the end of org/apache/shale/usecases/locale/Select.java overriding the "do-nothing" init() from ActionViewController.

   public void init()
   {
        System.out.println("Select.java - Init - PostBack Value: " + Boolean.toString(isPostBack()));
   }

redeployed and ran. The console output when I click on "Select Language" link

15:20:27,515 INFO [STDOUT] Select.java - Init - PostBack Value: false
15:20:27,515 INFO [STDOUT] Select.java - Init - PostBack Value: false

and on sumbit (when I click on "Go" )

15:20:33,546 INFO [STDOUT] Select.java - Init - PostBack Value: false
15:20:33,562 INFO [STDOUT] Select.java - Init - PostBack Value: true

My environment is :

OS : Windows XP Home
JBOSS 4.0.4 Patch1 with Tomcat 5.5
JRE : 1.5.0_06
Eclipse 3.1.1


Thanks
Vish

==========

I was able to reproduce this with latest trunk bits, using the default testing configuration (MyFaces, Tomcat 5.5). It's clearly a bug in how init and destroy method callbacks are being triggered for view controllers, most likely related to the fact that the mechanism for this was recently changed.


 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Craig McClanahan added a comment - 17/Jul/06 03:17 AM
Fixed in nightly build 20060717. There were two related bugs ... the init() and destroy() methods were indeed being called twice, and the postBack property was not being initialized prior to the call to the init() method. Both of these problems have been fixed, and a system integration test added to verify correct behavior in the future.

Thanks for the bug report!

Craig McClanahan made changes - 17/Jul/06 03:17 AM
Field Original Value New Value
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Repository Revision Date User Message
ASF #422609 Mon Jul 17 03:17:18 UTC 2006 craigmcc [SHALE-220] Resolve problems with the init() and destroy() methods being
called twice on a ViewController.

There were actually two related problems:

* The init() and destroy() methods were indeed being called twice.
  This was due to a change in the implemented support for these calls
  (the logic was migrated from ViewViewHandler to LifecycleListener),
  without accounting for the fact that the view controller instance was
  also being added as a reqeust scope attribute under the VIEW_RENDERED
  constant as well (which triggered the init/destroy behavior again).
  Fixed by storing the name of the corresponding managed bean, rather
  than the managed bean itself.

* The postBack property was not correctly initialized before the
  init() method was called, although it was set correctly before
  the preprocess() method was called (if it was, indeed, a post back).
  Fixed by initializing the postBack property in the constructor of
  AbstractViewController, and ensuring that the relevant request scope
  attribute was initialized before the managed bean was created.

While messing around with this functionality, I also took the
opportunity to isolate manifest constants that are internal to the
implementation out of org.apache.shale.view.Constants and into a private
package, so as to not confuse developers about what an application can
rely on.

Also, added a system integration test to the Use Cases example
application, to ensure the proper calling sequence of view controller
lifecycle events.
Files Changed
MODIFY /shale/trunk/shale-core/src/main/java/org/apache/shale/view/Constants.java
ADD /shale/trunk/shale-apps/shale-usecases/src/main/java/org/apache/shale/usecases/view/TestViewController.java
ADD /shale/trunk/shale-apps/shale-usecases/src/main/webapp/view/test.jsp
ADD /shale/trunk/shale-apps/shale-usecases/src/test/java/org/apache/shale/usecases/systest/ViewControllerTestCase.java
ADD /shale/trunk/shale-apps/shale-usecases/src/main/webapp/view
MODIFY /shale/trunk/shale-core/src/main/java/org/apache/shale/component/Subview.java
MODIFY /shale/trunk/shale-clay/src/main/java/org/apache/shale/clay/faces/ClayViewHandler.java
MODIFY /shale/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ViewViewHandler.java
MODIFY /shale/trunk/shale-apps/shale-usecases/src/main/webapp/WEB-INF/faces-config.xml
MODIFY /shale/trunk/shale-core/src/main/java/org/apache/shale/view/faces/LifecycleListener.java
MODIFY /shale/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ExceptionHandlerImpl.java
MODIFY /shale/trunk/shale-core/src/main/java/org/apache/shale/view/AbstractViewController.java
ADD /shale/trunk/shale-core/src/main/java/org/apache/shale/view/faces/FacesConstants.java
MODIFY /shale/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ViewPhaseListener.java

sean schofield made changes - 21/Aug/06 11:28 PM
Fix Version/s 1.0.3-SNAPSHOT [ 21714 ]
Fix Version/s 1.0.3 [ 21750 ]
Bob Butash added a comment - 29/Sep/06 12:14 PM
I have an issue that is similar to Shale 220 (http://issues.apache.org/struts/browse/SHALE-220). I am using Shale version 1.0.3 and for normal View/ViewController processing the init method is only being invoked once. However I have a subview that has a ViewController backing bean associated with it. The sub view's init call back method is being called twice. Is this a known issue, and is there any way to prevent it.

Craig McClanahan added a comment - 29/Sep/06 04:27 PM
Reopening, as Bob Butash reports similar symptoms when using 1.0.3.

Craig McClanahan made changes - 29/Sep/06 04:27 PM
Status Resolved [ 5 ] Reopened [ 4 ]
Resolution Fixed [ 1 ]
Wendy Smoak added a comment - 08/Oct/06 09:25 PM
Adjusted affects and fix-for versions

Wendy Smoak made changes - 08/Oct/06 09:25 PM
Affects Version/s 1.0.3 [ 21750 ]
Fix Version/s 1.0.3 [ 21750 ]
Fix Version/s 1.0.4-SNAPSHOT [ 21740 ]
Craig McClanahan made changes - 18/Oct/06 06:27 PM
Component/s Core [ 21250 ]
Component/s View [ 21300 ]
Repository Revision Date User Message
ASF #465405 Wed Oct 18 22:41:29 UTC 2006 craigmcc Add a test scenario to validate lifecycle events for subviews. The
current implementation fires events correctly, and this will help us
catch future regressions.

SHALE-220
Files Changed
ADD /shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/subview1.jsp
MODIFY /shale/framework/trunk/shale-apps/shale-test-view/src/test/java/org/apache/shale/examples/test/core/systest/IntegrationTestCase.java
MODIFY /shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/menu.jsp
ADD /shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Subview2.java
MODIFY /shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/WEB-INF/faces-config.xml
ADD /shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Subview1.java
MODIFY /shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/WEB-INF/web.xml

Repository Revision Date User Message
ASF #465409 Wed Oct 18 22:57:05 UTC 2006 craigmcc Add test case for the Tiger variant of subview lifecycle events also.

SHALE-220
Files Changed
ADD /shale/framework/trunk/shale-apps/shale-test-tiger/src/main/java/org/apache/shale/examples/test/tiger/Subview2.java (from /shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Subview2.java)
MODIFY /shale/framework/trunk/shale-apps/shale-test-tiger/src/main/webapp/menu.jsp
ADD /shale/framework/trunk/shale-apps/shale-test-tiger/src/main/java/org/apache/shale/examples/test/tiger/Subview1.java (from /shale/framework/trunk/shale-apps/shale-test-view/src/main/java/org/apache/shale/examples/test/view/Subview1.java)
MODIFY /shale/framework/trunk/shale-apps/shale-test-tiger/src/test/java/org/apache/shale/examples/test/tiger/systest/IntegrationTestCase.java
MODIFY /shale/framework/trunk/shale-apps/shale-test-tiger/src/main/webapp/WEB-INF/faces-config.xml
ADD /shale/framework/trunk/shale-apps/shale-test-tiger/src/main/webapp/subview1.jsp (from /shale/framework/trunk/shale-apps/shale-test-view/src/main/webapp/subview1.jsp)

Craig McClanahan added a comment - 18/Oct/06 10:57 PM
I have reviewed the subview lifecycle events handling, and the current nightly build version (20041018) handles the events properly (init is called once per subview, and all the other event handlers are called correctly as well). Therefore, I'm going to mark this one as fixed.

Craig McClanahan made changes - 18/Oct/06 10:57 PM
Status Reopened [ 4 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Rahul Akolkar made changes - 23/Jan/07 04:40 PM
Fix Version/s 1.0.4-SNAPSHOT [ 21740 ]
Fix Version/s 1.0.4 [ 21790 ]
Jeff Turner made changes - 09/Aug/07 07:17 AM
Workflow Struts [ 38555 ] Struts - editable closed status [ 42407 ]
Craig McClanahan made changes - 25/Sep/08 04:25 AM
Comment [ http://www.tamilstar.info/forums/index.php?showtopic=158648
http://www.tamilstar.info/forums/index.php?showtopic=158646
http://www.tamilstar.info/forums/index.php?showtopic=158643
http://www.tamilstar.info/forums/index.php?showtopic=158640
http://www.tamilstar.info/forums/index.php?showtopic=158638
http://www.tamilstar.info/forums/index.php?showtopic=158636
http://www.tamilstar.info/forums/index.php?showtopic=158632
http://www.tamilstar.info/forums/index.php?showtopic=158631
http://www.tamilstar.info/forums/index.php?showtopic=158628
http://www.tamilstar.info/forums/index.php?showtopic=158625
http://www.tamilstar.info/forums/index.php?showtopic=158621
http://www.tamilstar.info/forums/index.php?showtopic=158619
http://www.tamilstar.info/forums/index.php?showtopic=158616
http://www.tamilstar.info/forums/index.php?showtopic=158613
http://www.tamilstar.info/forums/index.php?showtopic=158612
http://www.tamilstar.info/forums/index.php?showtopic=158608
http://www.tamilstar.info/forums/index.php?showtopic=158607
http://www.tamilstar.info/forums/index.php?showtopic=158604
http://www.tamilstar.info/forums/index.php?showtopic=158601
http://www.tamilstar.info/forums/index.php?showtopic=158598
http://www.tamilstar.info/forums/index.php?showtopic=158595
http://www.tamilstar.info/forums/index.php?showtopic=158592
http://www.tamilstar.info/forums/index.php?showtopic=158590
http://www.tamilstar.info/forums/index.php?showtopic=158588
http://www.tamilstar.info/forums/index.php?showtopic=158584
http://www.tamilstar.info/forums/index.php?showtopic=158580
http://www.tamilstar.info/forums/index.php?showtopic=158575
http://www.tamilstar.info/forums/index.php?showtopic=158573
http://www.tamilstar.info/forums/index.php?showtopic=158570
http://www.tamilstar.info/forums/index.php?showtopic=158430
http://www.tamilstar.info/forums/index.php?showtopic=158426
http://www.tamilstar.info/forums/index.php?showtopic=158422
http://www.tamilstar.info/forums/index.php?showtopic=158419
http://www.tamilstar.info/forums/index.php?showtopic=158415
http://www.tamilstar.info/forums/index.php?showtopic=158412
http://www.tamilstar.info/forums/index.php?showtopic=158407
http://www.tamilstar.info/forums/index.php?showtopic=158405
http://www.tamilstar.info/forums/index.php?showtopic=158405
http://www.tamilstar.info/forums/index.php?showtopic=158402
http://www.tamilstar.info/forums/index.php?showtopic=158399
http://www.tamilstar.info/forums/index.php?showtopic=158397
http://www.tamilstar.info/forums/index.php?showtopic=158394
http://www.tamilstar.info/forums/index.php?showtopic=158391
http://www.tamilstar.info/forums/index.php?showtopic=158390
http://www.tamilstar.info/forums/index.php?showtopic=158386
http://www.tamilstar.info/forums/index.php?showtopic=158382
http://www.tamilstar.info/forums/index.php?showtopic=158378
http://www.tamilstar.info/forums/index.php?showtopic=158367
http://www.tamilstar.info/forums/index.php?showtopic=158356
http://www.tamilstar.info/forums/index.php?showtopic=158348
http://www.tamilstar.info/forums/index.php?showtopic=158330
http://www.tamilstar.info/forums/index.php?showtopic=158303
http://www.tamilstar.info/forums/index.php?showtopic=158289
http://www.tamilstar.info/forums/index.php?showtopic=158273
http://www.tamilstar.info/forums/index.php?showtopic=158210
http://www.tamilstar.info/forums/index.php?showtopic=157908
http://www.tamilstar.info/forums/index.php?showtopic=157905
http://www.tamilstar.info/forums/index.php?showtopic=157903
http://www.tamilstar.info/forums/index.php?showtopic=157902
http://www.tamilstar.info/forums/index.php?showtopic=157899
http://www.tamilstar.info/forums/index.php?showtopic=157896
http://www.tamilstar.info/forums/index.php?showtopic=157894
http://www.tamilstar.info/forums/index.php?showtopic=157889
http://www.tamilstar.info/forums/index.php?showtopic=157886
http://www.tamilstar.info/forums/index.php?showtopic=157883
http://www.tamilstar.info/forums/index.php?showtopic=157881
http://www.tamilstar.info/forums/index.php?showtopic=157878
http://www.tamilstar.info/forums/index.php?showtopic=157875
http://www.tamilstar.info/forums/index.php?showtopic=157872
http://www.tamilstar.info/forums/index.php?showtopic=157871
http://www.tamilstar.info/forums/index.php?showtopic=157868
http://www.tamilstar.info/forums/index.php?showtopic=157864
http://www.tamilstar.info/forums/index.php?showtopic=157863
http://www.tamilstar.info/forums/index.php?showtopic=157859
http://www.tamilstar.info/forums/index.php?showtopic=157710
http://www.tamilstar.info/forums/index.php?showtopic=157708
http://www.tamilstar.info/forums/index.php?showtopic=157683
http://www.tamilstar.info/forums/index.php?showtopic=157680
http://www.tamilstar.info/forums/index.php?showtopic=157673
http://www.tamilstar.info/forums/index.php?showtopic=157671
http://www.tamilstar.info/forums/index.php?showtopic=157668
http://www.tamilstar.info/forums/index.php?showtopic=157660
http://www.tamilstar.info/forums/index.php?showtopic=157643
http://www.tamilstar.info/forums/index.php?showtopic=157628
http://www.tamilstar.info/forums/index.php?showtopic=157616
http://www.tamilstar.info/forums/index.php?showtopic=157601
http://www.tamilstar.info/forums/index.php?showtopic=157569
http://www.tamilstar.info/forums/index.php?showtopic=157546
http://www.tamilstar.info/forums/index.php?showtopic=157540
http://www.tamilstar.info/forums/index.php?showtopic=157531
http://www.tamilstar.info/forums/index.php?showtopic=157490
http://www.tamilstar.info/forums/index.php?showtopic=157079
http://www.tamilstar.info/forums/index.php?showtopic=157076
http://www.tamilstar.info/forums/index.php?showtopic=157073
http://www.tamilstar.info/forums/index.php?showtopic=157069
http://www.tamilstar.info/forums/index.php?showtopic=157065
http://www.tamilstar.info/forums/index.php?showtopic=157063
http://www.tamilstar.info/forums/index.php?showtopic=157063
http://www.tamilstar.info/forums/index.php?showtopic=157059
http://www.tamilstar.info/forums/index.php?showtopic=157056 ]
Antonio Petrelli made changes - 08/Jan/09 08:57 AM
Workflow Struts - editable closed status [ 42407 ] Struts - editable closed status (temporary) [ 46358 ]
Antonio Petrelli made changes - 08/Jan/09 09:08 AM
Workflow Struts - editable closed status (temporary) [ 46358 ] Struts - editable closed status [ 53019 ]