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
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

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)