Hi,
Thanks for the reply and demo.
I see the difference is that I have been navigating to the new pages via
a browser url get request.
I tried it now with a <h:link /> and then the @PreDestroy gets called.
Is it suppose to work via get request?
Thanks
Pieter
On 24/06/2011 19:01, Gerhard Petracek wrote:
hi pieter,
based on the archetype i created a demo [1].
i just added a view-access-scoped bean and accessed it on the second page.
in the @PostConstruct callback a message gets added which you can see on the
page.
the @PreDestroy callback writes the message to the console because the bean
gets destroyed>after< the rendering process (if it wasn't accessed by the
new page) - so you won't see a message on the page (if you would add one
like in the @PostConstruct callback).
you can start the demo e.g. with:
mvn clean jetty:run-exploded -PjettyConfig
regards,
gerhard
[1]
http://people.apache.org/~gpetracek/myfaces/codi/demos/view-access-scope-demo.zip
http://www.irian.at
Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German
Professional Support for Apache MyFaces
2011/6/24 Pieter Martin<[email protected]>
Hi,
I have tested as you mentioned but the @PreDestroy still does not get
called.
I am using the jsf application as generated with the maven archetype.
I am however running it in embedded jetty mode, i.e. view a main method.
I have a META-INF/beans.xml in the src/main/resources dir.
page1 = helloWorld.xhtml which references the WindowScoped
HelloWorldController
page2 = testViewAccessScoped.xhtml which references a ViewAccessScoped bean
- PostConstruct called
page1 = helloWorld.xhtml, ViewAccessScoped - PreDestroy not called, as
expected
page1, again = helloWorld.xhtml, ViewAccessScoped - PreDestroy not called,
expected it to be called
page3 = helloWorld2.xhtml which references the WindowScoped
HelloWorldController - PreDestroy not called, expected it to be called
page4 = testViewAccessScoped2.xhtml which references a different
ViewAccessScoped bean - PostConstruct called, PreDestroy not called
page2 = testViewAccessScoped.xhtml which references a ViewAccessScoped bean
- PostConstruct called and PreDestroy called on page4's ViewAccessScoped
bean
I can only get PreDestroy called if I navigate from a ViewAccessScoped
directly to another ViewAccessScoped page.
Using @ViewScoped I can not get PreDestroyed to be called at all.
Using @ViewScoped if I F5 on the page @PostConstruct is called everytime
and @PreDestroy never
Thanks
Pieter
On 23/06/2011 23:11, Gerhard Petracek wrote:
hi pieter,
first of all welcome @ myfaces!
as long as the bean is referenced by a page - the bean will be available
for
the next page. after rendering the first page which doesn't use the
view-access scoped bean it will be destroyed (that's independent of other
beans).
regards,
gerhard
http://www.irian.at
Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German
Professional Support for Apache MyFaces
2011/6/23 Pieter Martin<[email protected]**>
Hi,
I trying to use @ViewAccessScoped beans but am not getting the expected
behavior.
I notice that @PreDestroy only gets called when I navigate from a page
using a particular ViewAccessScoped bean to another page using a
different ViewAccessScoped bean.
I expected @PreDestroy to be called whenever I navigate to a different
view. i.e. if a navigate from a page with a ViewAccessScoped bean to a
page with a ApplicationScoped or WindowScoped backing bean @PreDestroy
does not get called.
Is this a bug?
I am using CODI version 0.9.5 and MYFACES 2.1.1
Thanks
Pieter