You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Pieter Martin <pi...@gmail.com> on 2011/06/23 22:26:12 UTC

RE: @ViewAccessScoped PreDestroy

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


Re: @ViewAccessScoped PreDestroy

Posted by Gerhard Petracek <ge...@gmail.com>.
+1 - i also mentioned it in the wiki.

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/24 Mark Struberg <st...@yahoo.de>

> Just for making this clear: we do _not_ suggest to use a plain <a href...>!
> Please use <h:outputLink> instead (since JSF-2>.
> This will render a <a href> for you but will also manage all the view
> params if you like, etc. You can also add <f:param> children to pass
> parameters without having to do some string juggling.
>
> LieGrue,
> strub
>
> --- On Fri, 6/24/11, Gerhard Petracek <ge...@gmail.com> wrote:
>
> > From: Gerhard Petracek <ge...@gmail.com>
> > Subject: Re: @ViewAccessScoped PreDestroy
> > To: "MyFaces Discussion" <us...@myfaces.apache.org>
> > Date: Friday, June 24, 2011, 5:46 PM
> > hi pieter,
> >
> > to avoid side-effects you should always use such jsf
> > components.
> > if you really have to use a plain link - the solution would
> > be:
> >    <a
> >
> href="#{facesContext.externalContext.request.contextPath}/myPage.xhtml?windowId=#{currentWindow.id}">My
> > Page</a>
> > that's for sure more verbose than the version with h:link:
> >    <h:link value="My Page"
> > outcome="myPage"/>
> >
> > @ViewScoped:
> > besides some other disadvantages, that's the behaviour
> > specified by jsf2.
> > codi doesn't implement this scope itself. it just provides
> > an adapter for
> > cdi which delegates to the default implementation of jsf2.
> > so it's better to use one of the scopes which are
> > completely implemented by
> > codi itself.
> >
> > 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/24 Pieter Martin <pi...@gmail.com>
> >
> > > 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://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<pieter.martin@gmail.com**>
> > >>
> > >>  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<pieter.martin@gmail.com****>
> > >>>>
> > >>>>  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
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>>
> > >
> >
>

Re: @ViewAccessScoped PreDestroy

Posted by Gerhard Petracek <ge...@gmail.com>.
hi pieter,

yes - what you tried doesn't work due to restrictions by the browser. if the
server doesn't get the appropriate information, it waits for the timeout to
destroy the beans.

and thx for your question! i also added the answer to the wiki.

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/24 Pieter Martin <pi...@gmail.com>

> Hi
>
> I was typing in the url in the browser but without the "?windowId=e77"
>
> I suppose it is fine as the browser will remember the parameter if the user
> uses the back button, otherwise the bean will just have to wait for the
> timeout.
>
> Thanks
> Pieter
>
>
> On 24/06/2011 19:54, Gerhard Petracek wrote:
>
>> short addition to your last question:
>>
>> h:link triggers a get-request.
>> for post requests you need h:commandLink
>>
>> 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/24 Gerhard Petracek<ge...@gmail.com>
>> >
>>
>>  hi pieter,
>>>
>>> to avoid side-effects you should always use such jsf components.
>>> if you really have to use a plain link - the solution would be:
>>>    <a
>>> href="#{facesContext.**externalContext.request.**
>>> contextPath}/myPage.xhtml?**windowId=#{currentWindow.id}">**My
>>> Page</a>
>>> that's for sure more verbose than the version with h:link:
>>>    <h:link value="My Page" outcome="myPage"/>
>>>
>>> @ViewScoped:
>>> besides some other disadvantages, that's the behaviour specified by jsf2.
>>> codi doesn't implement this scope itself. it just provides an adapter for
>>> cdi which delegates to the default implementation of jsf2.
>>> so it's better to use one of the scopes which are completely implemented
>>> by
>>> codi itself.
>>>
>>> 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/24 Pieter Martin<pieter.martin@gmail.com**>
>>>
>>>  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/****<http://people.apache.org/~**gpetracek/myfaces/codi/demos/**>
>>>>> view-access-scope-demo.zip<htt**p://people.apache.org/~**
>>>>> gpetracek/myfaces/codi/demos/**view-access-scope-demo.zip<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<pieter.martin@gmail.com****>
>>>>>
>>>>>  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<pieter.martin@gmail.com******>
>>>>>>>
>>>>>>>  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
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>

Re: @ViewAccessScoped PreDestroy

Posted by Pieter Martin <pi...@gmail.com>.
Hi

I was typing in the url in the browser but without the "?windowId=e77"

I suppose it is fine as the browser will remember the parameter if the 
user uses the back button, otherwise the bean will just have to wait for 
the timeout.

Thanks
Pieter

On 24/06/2011 19:54, Gerhard Petracek wrote:
> short addition to your last question:
>
> h:link triggers a get-request.
> for post requests you need h:commandLink
>
> 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/24 Gerhard Petracek<ge...@gmail.com>
>
>> hi pieter,
>>
>> to avoid side-effects you should always use such jsf components.
>> if you really have to use a plain link - the solution would be:
>>     <a
>> href="#{facesContext.externalContext.request.contextPath}/myPage.xhtml?windowId=#{currentWindow.id}">My
>> Page</a>
>> that's for sure more verbose than the version with h:link:
>>     <h:link value="My Page" outcome="myPage"/>
>>
>> @ViewScoped:
>> besides some other disadvantages, that's the behaviour specified by jsf2.
>> codi doesn't implement this scope itself. it just provides an adapter for
>> cdi which delegates to the default implementation of jsf2.
>> so it's better to use one of the scopes which are completely implemented by
>> codi itself.
>>
>> 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/24 Pieter Martin<pi...@gmail.com>
>>
>>> 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://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<pieter.martin@gmail.com**>
>>>>
>>>>   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<pieter.martin@gmail.com****>
>>>>>>
>>>>>>   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
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>


Re: @ViewAccessScoped PreDestroy

Posted by Gerhard Petracek <ge...@gmail.com>.
short addition to your last question:

h:link triggers a get-request.
for post requests you need h:commandLink

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/24 Gerhard Petracek <ge...@gmail.com>

> hi pieter,
>
> to avoid side-effects you should always use such jsf components.
> if you really have to use a plain link - the solution would be:
>    <a
> href="#{facesContext.externalContext.request.contextPath}/myPage.xhtml?windowId=#{currentWindow.id}">My
> Page</a>
> that's for sure more verbose than the version with h:link:
>    <h:link value="My Page" outcome="myPage"/>
>
> @ViewScoped:
> besides some other disadvantages, that's the behaviour specified by jsf2.
> codi doesn't implement this scope itself. it just provides an adapter for
> cdi which delegates to the default implementation of jsf2.
> so it's better to use one of the scopes which are completely implemented by
> codi itself.
>
> 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/24 Pieter Martin <pi...@gmail.com>
>
>> 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://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<pieter.martin@gmail.com**>
>>>
>>>  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<pieter.martin@gmail.com****>
>>>>>
>>>>>  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
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>
>

Re: @ViewAccessScoped PreDestroy

Posted by Mark Struberg <st...@yahoo.de>.
Just for making this clear: we do _not_ suggest to use a plain <a href...>! Please use <h:outputLink> instead (since JSF-2>.
This will render a <a href> for you but will also manage all the view params if you like, etc. You can also add <f:param> children to pass parameters without having to do some string juggling.

LieGrue,
strub

--- On Fri, 6/24/11, Gerhard Petracek <ge...@gmail.com> wrote:

> From: Gerhard Petracek <ge...@gmail.com>
> Subject: Re: @ViewAccessScoped PreDestroy
> To: "MyFaces Discussion" <us...@myfaces.apache.org>
> Date: Friday, June 24, 2011, 5:46 PM
> hi pieter,
> 
> to avoid side-effects you should always use such jsf
> components.
> if you really have to use a plain link - the solution would
> be:
>    <a
> href="#{facesContext.externalContext.request.contextPath}/myPage.xhtml?windowId=#{currentWindow.id}">My
> Page</a>
> that's for sure more verbose than the version with h:link:
>    <h:link value="My Page"
> outcome="myPage"/>
> 
> @ViewScoped:
> besides some other disadvantages, that's the behaviour
> specified by jsf2.
> codi doesn't implement this scope itself. it just provides
> an adapter for
> cdi which delegates to the default implementation of jsf2.
> so it's better to use one of the scopes which are
> completely implemented by
> codi itself.
> 
> 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/24 Pieter Martin <pi...@gmail.com>
> 
> > 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://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<pieter.martin@gmail.com**>
> >>
> >>  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<pieter.martin@gmail.com****>
> >>>>
> >>>>  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
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >
> 

Re: @ViewAccessScoped PreDestroy

Posted by Gerhard Petracek <ge...@gmail.com>.
hi pieter,

to avoid side-effects you should always use such jsf components.
if you really have to use a plain link - the solution would be:
   <a
href="#{facesContext.externalContext.request.contextPath}/myPage.xhtml?windowId=#{currentWindow.id}">My
Page</a>
that's for sure more verbose than the version with h:link:
   <h:link value="My Page" outcome="myPage"/>

@ViewScoped:
besides some other disadvantages, that's the behaviour specified by jsf2.
codi doesn't implement this scope itself. it just provides an adapter for
cdi which delegates to the default implementation of jsf2.
so it's better to use one of the scopes which are completely implemented by
codi itself.

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/24 Pieter Martin <pi...@gmail.com>

> 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://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<pieter.martin@gmail.com**>
>>
>>  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<pieter.martin@gmail.com****>
>>>>
>>>>  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
>>>>>
>>>>>
>>>>>
>>>>>
>

Re: @ViewAccessScoped PreDestroy

Posted by Pieter Martin <pi...@gmail.com>.
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<pi...@gmail.com>
>
>> 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<pieter.martin@gmail.com**>
>>>
>>>   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
>>>>
>>>>
>>>>


Re: @ViewAccessScoped PreDestroy

Posted by Gerhard Petracek <ge...@gmail.com>.
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 <pi...@gmail.com>

> 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<pieter.martin@gmail.com**>
>>
>>  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
>>>
>>>
>>>
>

Re: @ViewAccessScoped PreDestroy

Posted by Pieter Martin <pi...@gmail.com>.
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<pi...@gmail.com>
>
>> 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
>>
>>


Re: @ViewAccessScoped PreDestroy

Posted by Gerhard Petracek <ge...@gmail.com>.
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 <pi...@gmail.com>

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

Re: @ViewAccessScoped PreDestroy

Posted by Pieter Martin <pi...@gmail.com>.
Thanks, I'll give it a both scenarios a test/try tonight.
Pieter

On 24/06/2011 08:55, Marcus Büttner wrote:
> Hi Pieter,
>
> the behavior which you describe is provided by ViewScope. If you navigate to
> a different view the old bean is destroyed.
>
> Regards
> Marcus
>
> 2011/6/23 Pieter Martin<pi...@gmail.com>
>
>> 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
>>
>>


Re: @ViewAccessScoped PreDestroy

Posted by Marcus Büttner <bu...@gmail.com>.
Hi Pieter,

the behavior which you describe is provided by ViewScope. If you navigate to
a different view the old bean is destroyed.

Regards
Marcus

2011/6/23 Pieter Martin <pi...@gmail.com>

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