+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 <strub...@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 <gerhard.petra...@gmail.com> wrote: > > > From: Gerhard Petracek <gerhard.petra...@gmail.com> > > Subject: Re: @ViewAccessScoped PreDestroy > > To: "MyFaces Discussion" <users@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 <pieter.mar...@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.mar...@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.mar...@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 > > >>>>> > > >>>>> > > >>>>> > > >>>>> > > > > > >