Пример #1
0
		protected override void restoreComponentState (FacesContext facesContext,
												  javax.faces.component.UIViewRoot uiViewRoot,
												  String renderKitId) {

			Trace.WriteLine ("Entering restoreComponentState");

			Object serializedComponentStates;
			if (isSavingStateInClient (facesContext)) {
				serializedComponentStates = GetStateFromClient (facesContext, uiViewRoot.getViewId(), renderKitId);
			}
			else {
				HttpSession session = (HttpSession) facesContext.getExternalContext ().getSession (false);
				if (session == null)
					serializedComponentStates = null;
				else {
					string key = ((IExtendedViewHandler) facesContext.getApplication ().getViewHandler ()).EncodeNamespace (facesContext, VIEWSTATE);
					SerializedView serializedView = session.getAttribute (key) as SerializedView;
					if (serializedView == null)
						serializedComponentStates = null;
					else
						serializedComponentStates = serializedView.getState ();
				}
			}
			((UIComponent) uiViewRoot.getChildren ().get (0)).processRestoreState (facesContext, serializedComponentStates);

			Trace.WriteLine ("Exiting restoreComponentState");
		}
		public override string getActionURL (FacesContext facesContext, string viewId) {
			if (viewId.Length > 0 && viewId [0] == '/') {
				return facesContext.getExternalContext ().getRequestContextPath () + viewId;
			}
			else {
				return viewId;
			}
		}
Пример #3
0
 public override string getActionURL(FacesContext facesContext, string viewId)
 {
     if (viewId.Length > 0 && viewId [0] == '/')
     {
         return(facesContext.getExternalContext().getRequestContextPath() + viewId);
     }
     else
     {
         return(viewId);
     }
 }
Пример #4
0
        public static ServletFacesContext GetFacesContext(FacesContextFactory facesContextFactory,
                                                          ServletContext servletContext,
                                                          ServletRequest servletRequest,
                                                          ServletResponse servletResponse,
                                                          Lifecycle lifecycle,
                                                          HttpContext httpContext,
                                                          string executionFilePath)
        {
            FacesContext        oldFacesContex     = FacesContext.getCurrentInstance();
            FacesContext        wrappedFacesContex = facesContextFactory.getFacesContext(servletContext, servletRequest, servletResponse, lifecycle);
            ExternalContext     externalContext    = new ServletExternalContext(wrappedFacesContex.getExternalContext(), httpContext, executionFilePath);
            ServletFacesContext context            = new ServletFacesContext(wrappedFacesContex, externalContext, httpContext, oldFacesContex);

            return(context);
        }
Пример #5
0
		public override void writeState (FacesContext facesContext, StateManager.SerializedView serializedView) {
			Trace.WriteLine ("Entering writeState");

			if (serializedView != null) {
				if (isSavingStateInClient (facesContext)) {
					SaveStateInClient (facesContext, serializedView);
				}
				else {
					HttpSession session = (HttpSession) facesContext.getExternalContext ().getSession (true);
					string key = ((IExtendedViewHandler) facesContext.getApplication ().getViewHandler ()).EncodeNamespace (facesContext, VIEWSTATE);
					session.setAttribute (key, serializedView);
				}
			}

			Trace.WriteLine ("Exiting writeState");
		}
Пример #6
0
		public override UIViewRoot createView (FacesContext facesContext, String viewId) {

			// create instance of Page by viewId
			StringBuilder sb = new StringBuilder ();
			sb.Append (facesContext.getExternalContext ().getRequestContextPath ());
			sb.Append (viewId);
			IHttpHandler page = PageParser.GetCompiledPageInstance (sb.ToString (), null, ((AspNetFacesContext) facesContext).Context);

			HttpContext context = ((AspNetFacesContext) facesContext).Context;
			page.ProcessRequest (context);
			
			UIViewRoot uiViewRoot = _viewHandler.createView (facesContext, viewId);
			uiViewRoot.getChildren ().add (0, (UIComponent) page);
			
			Trace.WriteLine ("Created view " + viewId);
			return uiViewRoot;
		}
Пример #7
0
        public override UIViewRoot createView(FacesContext facesContext, String viewId)
        {
            // create instance of Page by viewId
            StringBuilder sb = new StringBuilder();

            sb.Append(facesContext.getExternalContext().getRequestContextPath());
            sb.Append(viewId);
            IHttpHandler page = PageParser.GetCompiledPageInstance(sb.ToString(), null, ((AspNetFacesContext)facesContext).Context);

            HttpContext context = ((AspNetFacesContext)facesContext).Context;

            page.ProcessRequest(context);

            UIViewRoot uiViewRoot = _viewHandler.createView(facesContext, viewId);

            uiViewRoot.getChildren().add(0, (UIComponent)page);

            Trace.WriteLine("Created view " + viewId);
            return(uiViewRoot);
        }
Пример #8
0
        public override void writeState(FacesContext facesContext, StateManager.SerializedView serializedView)
        {
            Trace.WriteLine("Entering writeState");

            if (serializedView != null)
            {
                if (isSavingStateInClient(facesContext))
                {
                    SaveStateInClient(facesContext, serializedView);
                }
                else
                {
                    HttpSession session = (HttpSession)facesContext.getExternalContext().getSession(true);
                    string      key     = ((IExtendedViewHandler)facesContext.getApplication().getViewHandler()).EncodeNamespace(facesContext, VIEWSTATE);
                    session.setAttribute(key, serializedView);
                }
            }

            Trace.WriteLine("Exiting writeState");
        }
Пример #9
0
        protected object GetStateFromClient(FacesContext facesContext, String viewId, String renderKitId)
        {
            //RenderKit renderKit = RenderKitFactory.getRenderKit (facesContext, renderKitId);
            //ResponseStateManager responseStateManager = renderKit.getResponseStateManager ();
            //responseStateManager.getTreeStructureToRestore (facesContext, viewId); //ignore result. Must call for compatibility with sun implementation.
            //return responseStateManager.getComponentStateToRestore (facesContext);

            java.util.Map map = facesContext.getExternalContext().getRequestParameterMap();
            string        s1  = (string)map.get(VIEWSTATE);

            byte [] buffer = Convert.FromBase64String(s1);
            java.io.ByteArrayInputStream bytearrayinputstream = new java.io.ByteArrayInputStream(vmw.common.TypeUtils.ToSByteArray(buffer));
            java.io.ObjectInputStream    inputStream          = new java.io.ObjectInputStream(bytearrayinputstream);
            //ignore tree structure
            //inputStream.readObject ();
            object state = inputStream.readObject();

            inputStream.close();
            bytearrayinputstream.close();

            return(state);
        }
Пример #10
0
        protected override void restoreComponentState(FacesContext facesContext,
                                                      javax.faces.component.UIViewRoot uiViewRoot,
                                                      String renderKitId)
        {
            Trace.WriteLine("Entering restoreComponentState");

            Object serializedComponentStates;

            if (isSavingStateInClient(facesContext))
            {
                serializedComponentStates = GetStateFromClient(facesContext, uiViewRoot.getViewId(), renderKitId);
            }
            else
            {
                HttpSession session = (HttpSession)facesContext.getExternalContext().getSession(false);
                if (session == null)
                {
                    serializedComponentStates = null;
                }
                else
                {
                    string         key            = ((IExtendedViewHandler)facesContext.getApplication().getViewHandler()).EncodeNamespace(facesContext, VIEWSTATE);
                    SerializedView serializedView = session.getAttribute(key) as SerializedView;
                    if (serializedView == null)
                    {
                        serializedComponentStates = null;
                    }
                    else
                    {
                        serializedComponentStates = serializedView.getState();
                    }
                }
            }
            ((UIComponent)uiViewRoot.getChildren().get(0)).processRestoreState(facesContext, serializedComponentStates);

            Trace.WriteLine("Exiting restoreComponentState");
        }
Пример #11
0
		protected object GetStateFromClient (FacesContext facesContext, String viewId, String renderKitId) {
			//RenderKit renderKit = RenderKitFactory.getRenderKit (facesContext, renderKitId);
			//ResponseStateManager responseStateManager = renderKit.getResponseStateManager ();
			//responseStateManager.getTreeStructureToRestore (facesContext, viewId); //ignore result. Must call for compatibility with sun implementation.
			//return responseStateManager.getComponentStateToRestore (facesContext);

			java.util.Map map = facesContext.getExternalContext ().getRequestParameterMap ();
			string s1 = (string) map.get (VIEWSTATE);

			byte [] buffer = Convert.FromBase64String (s1);
			java.io.ByteArrayInputStream bytearrayinputstream = new java.io.ByteArrayInputStream (vmw.common.TypeUtils.ToSByteArray (buffer));
			java.io.ObjectInputStream inputStream = new java.io.ObjectInputStream (bytearrayinputstream);
			//ignore tree structure
			//inputStream.readObject ();
			object state = inputStream.readObject ();
			inputStream.close ();
			bytearrayinputstream.close ();

			return state;
		}