Thanks, I now have a servlet working as expected. For anyone else here is some psuedo code:
@Inject private org.apache.deltaspike.core.spi.scope.window.WindowContext windowContext; protected void service(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException { windowContext.activateWindow( "abc123" ); TabInfo tabInfo = org.apache.deltaspike.core.api.provider.BeanProvider.getContextualReference( "tabInfo", false, TabInfo.class ); tabInfo.setImportantInfo( ii ); javax.servlet.RequestDispatcher dispatcher = getServletContext().getRequestDispatcher( "/detail.jsf?dswid=abc123" ); dispatcher.forward( request, response ); } -Thanks again On Mon, Feb 1, 2016 at 6:27 PM, Gerhard Petracek <gpetra...@apache.org> wrote: > hi stephen, > > in your special case (= an own servlet) you need to restore the window-id > on your own -> use the restored value for WindowContext#activateWindow. > (how you can restore it depends on the client-window-strategy you are > using. > with the default-strategy you can use HttpServletRequest#getParameter and > "dswid" as parameter-name.) > > if the window-id doesn't exist already (= first/initial get-request), you > can generate and use any random value. > (in this case please also have a look at deltaspike.window-id.max_length - > see JsfBaseConfig) > > regards, > gerhard > > > > 2016-02-01 23:49 GMT+01:00 Stephen More <stephen.m...@gmail.com>: > > > I am not able to get this to work - in my servlet I have tried: > > > > A. > > @Inject > > private org.apache.deltaspike.core.spi.scope.window.WindowContext > > windowContext; > > > > windowContext.getCurrentWindowId() is null; > > > > > > B. > > org.apache.deltaspike.core.api.provider.DependentProvider dp = > > org.apache.deltaspike.core.api.provider.BeanProvider.getDependent( > > "tabInfo" ); > > Object obj = dp.get(); > > log.info( "Object: " + obj ); > > > > org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active > > contexts for scope type org.apache.deltaspike.core.api.scope.WindowScoped > > > > C. > > TabInfo tabInfo = > > > org.apache.deltaspike.core.api.provider.BeanProvider.getContextualReference( > > "tabInfo", false, TabInfo.class ); > > tabInfo.setImportantInfo( ii ); > > > > > > org.jboss.weld.context.ContextNotActiveException: WELD-001303: No active > > contexts for scope type org.apache.deltaspike.core.api.scope.WindowScoped > > > > > > > > -- I am running this in Tomcat not a full blown J2EE AS - could that be > > the issue ? > > > > > > > > > > > > > > > > > > On Mon, Feb 1, 2016 at 4:04 PM, Gerhard Petracek <gpetra...@apache.org> > > wrote: > > > >> hi stephen, > >> > >> codi restores the window-id once it's needed and ds restores it e.g. at > >> the beginning of a faces-request. > >> -> > >> inject and use WindowContext (or use BeanProvider#getContextualReference > >> or even better in this case BeanProvider#getDependent). > >> (WindowContext allows you to manage the window-id manually.) > >> > >> regards, > >> gerhard > >> > >> > >> > >> 2016-02-01 21:32 GMT+01:00 Stephen More <stephen.m...@gmail.com>: > >> > >>> I have a MyFaces CODI application that utilizes WindowScoped beans. ( > >>> Session per tab - so thankful for that. ) > >>> > >>> I have been able to create url links that navigate to jsf pages using a > >>> servlet. ( > >>> > >>> > http://balusc.omnifaces.org/2006/06/communication-in-jsf.html#AccessingTheFacesContextInsideHttpServletOrFilter > >>> ) > >>> > >>> protected void service(HttpServletRequest request,HttpServletResponse > >>> response) throws ServletException, IOException > >>> { > >>> javax.faces.context.FacesContext context = FacesUtil.getFacesContext( > >>> request, response ); > >>> TabInfo tabInfo = context.getApplication().evaluateExpressionGet( > >>> context, > >>> "#{tabInfo}", TabInfo.class ); > >>> tabInfo.setImportantInfo( ii ); > >>> > >>> javax.servlet.RequestDispatcher dispatcher = > >>> getServletContext().getRequestDispatcher( "/detail.jsf" ); > >>> dispatcher.forward( request, response ); > >>> } > >>> > >>> Everything has been working flawlessly. > >>> > >>> When I try to achieve the exact same feature using DeltaSpike, tabInfo > >>> will > >>> come back null. > >>> > >>> When I try: > >>> TabInfo tabInfo = (TabInfo)application.createValueBinding( > >>> "#{tabInfo}" ).getValue( context ); > >>> the following will show up in error logs: > >>> "org.jboss.weld.context.ContextNotActiveException: WELD-001303: > No > >>> active contexts for scope type > >>> org.apache.deltaspike.core.api.scope.WindowScoped" > >>> > >>> > >>> I appreciate any help you can provide. > >>> -Thanks > >>> > >> > >> > > >