⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 page.java

📁 Wicket一个开发Java Web应用程序框架。它使得开发web应用程序变得容易而轻松。 Wicket利用一个POJO data beans组件使得它可以与任何持久层技术相结合。
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
							{								buffer.append(metadata);							}							metadata = (String)component.getMetaData(Component.ADDED_AT_KEY);							if (metadata != null)							{								buffer.append(metadata);							}						}						else						{							// if the component is not visible in hierarchy we							// should not visit its children since they are also							// not visible							return CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;						}					}					return CONTINUE_TRAVERSAL;				}			});			// Throw exception if any errors were found			if (unrenderedComponents.size() > 0)			{				// Get rid of set				renderedComponents = null;				Iterator iterator = unrenderedComponents.iterator();				while (iterator.hasNext())				{					Component component = (Component)iterator.next();					// Now first test if the component has a sibling that is a transparent resolver.					Iterator iterator2 = component.getParent().iterator();					while (iterator2.hasNext())					{						Component sibling = (Component)iterator2.next();						if (!sibling.isVisible())						{							boolean isTransparentMarkupContainer = sibling instanceof MarkupContainer &&								((MarkupContainer)sibling).isTransparentResolver();							boolean isComponentResolver = sibling instanceof IComponentResolver;							if (isTransparentMarkupContainer || isComponentResolver)							{								// we found a transparent container that isn't visible								// then ignore this component and only do a debug statement here.								log.warn("Component " +									component +									" wasn't rendered but most likely it has a transparent parent: " +									sibling);								iterator.remove();								break;							}						}					}				}				// if still > 0				if (unrenderedComponents.size() > 0)				{					// Throw exception					throw new WicketRuntimeException(						"The component(s) below failed to render. A common problem is that you have added a component in code but forgot to reference it in the markup (thus the component will never be rendered).\n\n" +							buffer.toString());				}			}		}		// Get rid of set		renderedComponents = null;	}	/**	 * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL OR OVERRIDE.	 * 	 */	private final void endVersion()	{		// Any changes to the page after this point will be tracked by the		// page's version manager. Since trackChanges is never set to false,		// this effectively means that change tracking begins after the		// first request to a page completes.		setFlag(FLAG_TRACK_CHANGES, true);		// If a new version was created		if (getFlag(FLAG_NEW_VERSION))		{			// Reset boolean for next request			setFlag(FLAG_NEW_VERSION, false);			// We're done with this version			if (versionManager != null)			{				versionManager.endVersion(getRequest().mergeVersion());			}			// Evict any page version(s) as need be			getApplication().getSessionSettings().getPageMapEvictionStrategy().evict(getPageMap());		}	}	/**	 * Initializes Page by adding it to the Session and initializing it.	 */	private final void init()	{		final RequestCycle cycle = getRequestCycle();		String pageMapName = null;		if (cycle != null)		{			RequestParameters parameters = getRequest().getRequestParameters();			pageMapName = parameters.getPageMapName();		}		final IPageMap pageMap = PageMap.forName(pageMapName);		init(pageMap);	}	/**	 * Initializes Page by adding it to the Session and initializing it.	 * 	 * @param pageMap	 *            The page map to put this page in.	 */	private final void init(final IPageMap pageMap)	{		// Set the page map		if (pageMap != null)		{			setPageMap(pageMap);		}		else		{			throw new IllegalStateException("PageMap cannot be null");		}		setNextAvailableId();		// Set versioning of page based on default		setVersioned(Application.get().getPageSettings().getVersionPagesByDefault());		// All Pages are born dirty so they get clustered right away		dirty();	}	private void setNextAvailableId()	{		if (getApplication().getSessionSettings().isPageIdUniquePerSession())		{			setNumericId(getSession().nextPageId());		}		else		{			// Set the numeric id on this page			setNumericId(getPageMap().nextId());		}	}	/**	 * For the given component, whether we may record changes.	 * 	 * @param component	 *            The component which is affected	 * @param parent	 * @return True if the change is okay to report	 */	private final boolean mayTrackChangesFor(final Component component, MarkupContainer parent)	{		// first call the method so that people can track dirty components		componentChanged(component, parent);		// Auto components do not participate in versioning since they are		// added during the rendering phase (which is normally illegal).		if (component.isAuto() || (parent == null && !component.isVersioned()) ||			(parent != null && !parent.isVersioned()))		{			return false;		}		else		{			// the component is versioned... are we tracking changes at all?			if (getFlag(FLAG_TRACK_CHANGES))			{				// we are tracking changes... do we need to start new version?				if (!getFlag(FLAG_NEW_VERSION))				{					// if we have no version manager					if (versionManager == null)					{						// then install a new version manager						versionManager = getSession().getSessionStore().newVersionManager(this);					}					// start a new version					versionManager.beginVersion(getRequest().mergeVersion());					setFlag(FLAG_NEW_VERSION, true);				}				// return true as we are ready for versioning				return true;			}			// we are not tracking changes or the component not versioned			return false;		}	}	/**	 * This method will be called for all components that are changed on the page So also auto	 * components or components that are not versioned.	 * 	 * If the parent is given that it was a remove or add from that parent of the given component.	 * else it was just a internal property change of that component.	 * 	 * @param component	 * @param parent	 */	protected void componentChanged(Component component, MarkupContainer parent)	{	}	private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException	{		int id = s.readShort();		String name = (String)s.readObject();		IPageSerializer ps = (IPageSerializer)serializer.get();		if (ps != null)		{			pageToResolve = ps.deserializePage(id, name, this, s);		}		else		{			s.defaultReadObject();		}	}	// called after readObject	/**	 * @return	 * @throws ObjectStreamException	 */	public Object readResolve() throws ObjectStreamException	{		if (pageToResolve == null)		{			return this;		}		else		{			Page page = pageToResolve;			pageToResolve = null;			return page;		}	}	private void writeObject(java.io.ObjectOutputStream s) throws IOException	{		s.writeShort(numericId);		s.writeObject(pageMapName);		IPageSerializer ps = (IPageSerializer)serializer.get();		if (ps != null)		{			ps.serializePage(this, s);		}		else		{			s.defaultWriteObject();		}	}	/**	 * Set-up response with appropriate content type, locale and encoding. The locale is set equal	 * to the session's locale. The content type header contains information about the markup type	 * (@see #getMarkupType()) and the encoding. The response (and request) encoding is determined	 * by an application setting (@see ApplicationSettings#getResponseRequestEncoding()). In	 * addition, if the page's markup contains a xml declaration like &lt?xml ... ?&gt; an xml	 * declaration with proper encoding information is written to the output as well, provided it is	 * not disabled by an application setting (@see	 * ApplicationSettings#getStripXmlDeclarationFromOutput()).	 * <p>	 * Note: Prior to Wicket 1.1 the output encoding was determined by the page's markup encoding.	 * Because this caused uncertainties about the /request/ encoding, it has been changed in favor	 * of the new, much safer, approach. Please see the Wiki for more details.	 */	protected void configureResponse()	{		// Get the response and application		final RequestCycle cycle = getRequestCycle();		final Application application = cycle.getApplication();		final Response response = cycle.getResponse();		// Determine encoding		final String encoding = application.getRequestCycleSettings().getResponseRequestEncoding();		// Set content type based on markup type for page		response.setContentType("text/" + getMarkupType() + "; charset=" + encoding);		// Write out an xml declaration if the markup stream and settings allow		final MarkupStream markupStream = findMarkupStream();		if ((markupStream != null) && (markupStream.getXmlDeclaration() != null) &&			(application.getMarkupSettings().getStripXmlDeclarationFromOutput() == false))		{			response.write("<?xml version='1.0' encoding='");			response.write(encoding);			response.write("'?>");		}		// Set response locale from session locale		response.setLocale(getSession().getLocale());	}	/**	 * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL OR OVERRIDE.	 * 	 * @see org.apache.wicket.Component#internalOnModelChanged()	 */	protected final void internalOnModelChanged()	{		visitChildren(new Component.IVisitor()		{			public Object component(final Component component)			{				// If form component is using form model				if (component.sameInnermostModel(Page.this))				{					component.modelChanged();				}				return IVisitor.CONTINUE_TRAVERSAL;			}		});	}	/**	 * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL OR OVERRIDE.	 * 	 * @param map	 */	protected final void moveToPageMap(IPageMap map)	{		// TODO post 1.2 shouldn't we remove this page from the pagemap/session		// if it would be in there?		// This should be done if the page was not cloned first, but shouldn't		// be done if it was cloned..		setPageMap(map);		setNextAvailableId();	}	/**	 * @return Factory method that creates a version manager for this Page	 * @deprecated TODO Remove in 1.4	 */	protected final IPageVersionManager newVersionManager()	{		return null;	}	protected void onBeforeRender()	{		super.onBeforeRender();		// If any of the components on page is not stateless, we need to bind the session		// before we start rendering components, as then jsessionid won't be appended		// for links rendered before first stateful component		if (getSession().isTemporary() && !isPageStateless())		{			getSession().bind();		}	}	/**	 * @see org.apache.wicket.Component#onDetach()	 */	protected void onDetach()	{		if (log.isDebugEnabled())		{			log.debug("ending request for page " + this + ", request " + getRequest());		}		endVersion();		dirty();		super.onDetach();	}	/**	 * Renders this container to the given response object.	 * 	 * @param markupStream	 */	protected void onRender(final MarkupStream markupStream)	{		// Set page's associated markup stream		final MarkupStream associatedMarkupStream = getAssociatedMarkupStream(true);		setMarkupStream(associatedMarkupStream);		// Configure response object with locale and content type		configureResponse();		// Render markup		renderAll(associatedMarkupStream);	}	/**	 * A component was added.	 * 	 * @param component	 *            The component that was added	 */	final void componentAdded(final Component component)	{		dirty();		if (mayTrackChangesFor(component, component.getParent()))		{			versionManager.componentAdded(component);		}	}	/**	 * A component's model changed.	 * 	 * @param component	 *            The component whose model is about to change	 */	final void componentModelChanging(final Component component)	{		dirty();		if (mayTrackChangesFor(component, null))		{			// If it is an inhertiable model then don't call model changing			// on the version manager.			if (!component.getFlag(FLAG_INHERITABLE_MODEL))			{				versionManager.componentModelChanging(component);			}		}	}	/**	 * A component was removed.	 * 	 * @param component	 *            The component that was removed	 */	final void componentRemoved(final Component component)	{		dirty();		if (mayTrackChangesFor(component, component.getParent()))		{			versionManager.componentRemoved(component);		}	}	final void componentStateChanging(final Component component, Change change)	{		dirty();		if (mayTrackChangesFor(component, null))		{			versionManager.componentStateChanging(change);		}	}	/**	 * Sets values for form components based on cookie values in the request.	 * 	 */	final void setFormComponentValuesFromCookies()	{		// Visit all Forms contained in the page		visitChildren(Form.class, new Component.IVisitor()		{			// For each FormComponent found on the Page (not Form)			public Object component(final Component component)			{				((Form)component).loadPersistentFormComponentValues();				return CONTINUE_TRAVERSAL;			}		});	}	/**	 * @param pageMap	 *            Sets this page into the page map with the given name. If the page map does not yet	 *            exist, it is automatically created.	 */	final void setPageMap(final IPageMap pageMap)	{		// Save transient reference to pagemap		this.pageMap = pageMap;		// Save name for restoring transient		pageMapName = pageMap.getName();	}	/**	 * Set page stateless	 * 	 * @param stateless	 */	void setPageStateless(Boolean stateless)	{		this.stateless = stateless;	}	/**	 * Called when the page is retrieved from Session.	 */	public void onPageAttached()	{	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -