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

📄 page.java

📁 Wicket一个开发Java Web应用程序框架。它使得开发web应用程序变得容易而轻松。 Wicket利用一个POJO data beans组件使得它可以与任何持久层技术相结合。
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		{			// Look the page map up in the session			pageMap = PageMap.forName(pageMapName);		}		return pageMap;	}	/**	 * @return Get a page map entry for this page. By default, this is the page itself. But if you	 *         know of some way to compress the state for the page, you can return a custom	 *         implementation that produces the page on-the-fly.	 */	public IPageMapEntry getPageMapEntry()	{		return this;	}	/**	 * @return String The PageMap name	 */	public final String getPageMapName()	{		return pageMapName;	}	/**	 * @return Size of this page in bytes	 */	public final long getSizeInBytes()	{		pageMap = null;		return Objects.sizeof(this);	}	/**	 * Returns whether the page should try to be stateless. To be stateless, getStatelessHint() of	 * every component on page (and it's behavior) must return true and the page must be	 * bookmarkable.	 * 	 * @see org.apache.wicket.Component#getStatelessHint()	 */	public final boolean getStatelessHint()	{		return getFlag(FLAG_STATELESS_HINT);	}	/**	 * Override this method to implement a custom way of producing a version of a Page when it	 * cannot be found in the Session.	 * 	 * @param versionNumber	 *            The version desired	 * @return A Page object with the component/model hierarchy that was attached to this page at	 *         the time represented by the requested version.	 */	public Page getVersion(final int versionNumber)	{		// If we're still the original Page and that's what's desired		if (versionManager == null)		{			if (versionNumber == 0 || versionNumber == LATEST_VERSION)			{				return this;			}			else			{				log.info("No version manager available to retrieve requested versionNumber " +					versionNumber);				return null;			}		}		else		{			// Save original change tracking state			final boolean originalTrackChanges = getFlag(FLAG_TRACK_CHANGES);			try			{				// While the version manager is potentially playing around with				// the Page, it may change the page in order to undo changes and				// we don't want change tracking going on while its doing this.				setFlag(FLAG_TRACK_CHANGES, false);				// Get page of desired version				final Page page;				if (versionNumber != LATEST_VERSION)				{					page = versionManager.getVersion(versionNumber);				}				else				{					page = versionManager.getVersion(getCurrentVersionNumber());				}				// If we went all the way back to the original page				if (page != null && page.getCurrentVersionNumber() == 0 &&					page.getAjaxVersionNumber() == 0)				{					// remove version info					page.versionManager = null;				}				return page;			}			finally			{				// Restore change tracking state				setFlag(FLAG_TRACK_CHANGES, originalTrackChanges);			}		}	}	/**	 * @return Number of versions of this page	 */	public final int getVersions()	{		return versionManager == null ? 1 : versionManager.getVersions() + 1;	}	/**	 * @return This page's component hierarchy as a string	 */	public final String hierarchyAsString()	{		final StringBuffer buffer = new StringBuffer();		buffer.append("Page " + getId() + " (version " + getCurrentVersionNumber() + ")");		visitChildren(new IVisitor()		{			public Object component(Component component)			{				int levels = 0;				for (Component current = component; current != null; current = current.getParent())				{					levels++;				}				buffer.append(StringValue.repeat(levels, "	") + component.getPageRelativePath() +					":" + Classes.simpleName(component.getClass()));				return null;			}		});		return buffer.toString();	}	/**	 * Call this method when the current (ajax) request shouldn't merge the changes that are	 * happening to the page with the previous version.	 * 	 * This is for example needed when you want to redirect to this page in an ajax request and then	 * you do want to version normally..	 * 	 * This method doesn't do anything if the getRequest().mergeVersion doesn't return true.	 */	public final void ignoreVersionMerge()	{		if (getRequest().mergeVersion())		{			mayTrackChangesFor(this, null);			if (versionManager != null)			{				versionManager.ignoreVersionMerge();			}		}	}	/**	 * Bookmarkable page can be instantiated using a bookmarkable URL.	 * 	 * @return Returns true if the page is bookmarkable.	 */	public boolean isBookmarkable()	{		Boolean bookmarkable = (Boolean)pageClassToBookmarkableCache.get(getClass().getName());		if (bookmarkable == null)		{			try			{				if (getClass().getConstructor(new Class[] {}) != null)				{					bookmarkable = Boolean.TRUE;				}			}			catch (Exception ignore)			{				try				{					if (getClass().getConstructor(new Class[] { PageParameters.class }) != null)					{						bookmarkable = Boolean.TRUE;					}				}				catch (Exception ignore2)				{				}			}			if (bookmarkable == null)			{				bookmarkable = Boolean.FALSE;			}			pageClassToBookmarkableCache.put(getClass().getName(), bookmarkable);		}		return bookmarkable.booleanValue();	}	/**	 * Override this method and return true if your page is used to display Wicket errors. This can	 * help the framework prevent infinite failure loops.	 * 	 * @return True if this page is intended to display an error to the end user.	 */	public boolean isErrorPage()	{		return false;	}	/**	 * Gets whether the page is stateless. Components on stateless page must not render any	 * statefull urls, and components on statefull page must not render any stateless urls.	 * Statefull urls are urls, which refer to a certain (current) page instance.	 * 	 * @return Whether this page is stateless	 */	public final boolean isPageStateless()	{		if (isBookmarkable() == false)		{			stateless = Boolean.FALSE;			if (getStatelessHint())			{				log.warn("Page '" + this + "' is not stateless because it is not bookmarkable, " +					"but the stateless hint is set to true!");			}		}		if (stateless == null)		{			final Object[] returnArray = new Object[1];			Object returnValue = visitChildren(Component.class, new IVisitor()			{				public Object component(Component component)				{					if (!component.isStateless())					{						returnArray[0] = component;						return Boolean.FALSE;					}					return CONTINUE_TRAVERSAL;				}			});			if (returnValue == null)			{				stateless = Boolean.TRUE;			}			else if (returnValue instanceof Boolean)			{				stateless = (Boolean)returnValue;			}			if (!stateless.booleanValue() && getStatelessHint())			{				log.warn("Page '" + this + "' is not stateless because of '" + returnArray[0] +					"' but the stateless hint is set to true!");			}		}		return stateless.booleanValue();	}	/**	 * Redirect to this page.	 * 	 * @see org.apache.wicket.IRedirectListener#onRedirect()	 */	public final void onRedirect()	{	}	/**	 * Convenience method. Search for children of type fromClass and invoke their respective	 * removePersistedFormData() methods.	 * 	 * @see Form#removePersistentFormComponentValues(boolean)	 * 	 * @param formClass	 *            Form to be selected. Pages may have more than one Form.	 * @param disablePersistence	 *            if true, disable persistence for all FormComponents on that page. If false, it	 *            will remain unchanged.	 */	public final void removePersistedFormData(final Class formClass,		final boolean disablePersistence)	{		// Check that formClass is an instanceof Form		if (!Form.class.isAssignableFrom(formClass))		{			throw new WicketRuntimeException("Form class " + formClass.getName() +				" is not a subclass of Form");		}		// Visit all children which are an instance of formClass		visitChildren(formClass, new IVisitor()		{			public Object component(final Component component)			{				// They must be of type Form as well				if (component instanceof Form)				{					// Delete persistent FormComponent data and disable					// persistence					((Form)component).removePersistentFormComponentValues(disablePersistence);				}				return CONTINUE_TRAVERSAL;			}		});	}	/**	 * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL IT.	 */	public final void renderPage()	{		// first try to check if the page can be rendered:		if (!isActionAuthorized(RENDER))		{			if (log.isDebugEnabled())			{				log.debug("Page not allowed to render: " + this);			}			throw new UnauthorizedActionException(this, Component.RENDER);		}		// Make sure it is really empty		renderedComponents = null;		// if the page is stateless, reset the flag so that it is tested again		if (Boolean.TRUE.equals(stateless))		{			stateless = null;		}		// Set form component values from cookies		setFormComponentValuesFromCookies();		try		{			prepareForRender();		}		catch (RuntimeException e)		{			// if an exception is thrown then we have to call after render			// else the components could be in a wrong state (rendering)			try			{				afterRender();			}			catch (RuntimeException e2)			{				// ignore this one could be a result off.			}			throw e;		}		// Handle request by rendering page		try		{			render(null);		}		finally		{			afterRender();		}		// Check rendering if it happened fully		checkRendering(this);		// clean up debug meta data if component check is on		if (Application.get().getDebugSettings().getComponentUseCheck())		{			visitChildren(new IVisitor()			{				public Object component(Component component)				{					component.setMetaData(Component.CONSTRUCTED_AT_KEY, null);					component.setMetaData(Component.ADDED_AT_KEY, null);					return CONTINUE_TRAVERSAL;				}			});		}		if (!isPageStateless())		{			// trigger creation of the actual session in case it was deferred			Session.get().getSessionStore().getSessionId(RequestCycle.get().getRequest(), true);			// Add/touch the response page in the session (its pagemap).			getSession().touch(this);		}	}	/**	 * This returns a page instance that is rollbacked the number of versions that is specified	 * compared to the current page.	 * 	 * This is a rollback including ajax versions.	 * 	 * @param numberOfVersions	 *            to rollback	 * @return rollbacked page instance	 */	public final Page rollbackPage(int numberOfVersions)	{		Page page = versionManager == null ? this : versionManager.rollbackPage(numberOfVersions);		getSession().touch(page);		return page;	}	/**	 * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL.	 * 	 * Set the id for this Page. This method is called by PageMap when a Page is added because the	 * id, which is assigned by PageMap, is not known until this time.	 * 	 * @param id	 *            The id	 */	public final void setNumericId(final int id)	{		numericId = id;	}	/**	 * Sets whether the page should try to be stateless. To be stateless, getStatelessHint() of	 * every component on page (and it's behavior) must return true and the page must be	 * bookmarkable.	 * 	 * @param value	 *            whether the page should try to be stateless	 */	public final void setStatelessHint(boolean value)	{		if (value && !isBookmarkable())		{			throw new WicketRuntimeException(				"Can't set stateless hint to true on a page when the page is not bookmarkable, page: " +					this);		}		setFlag(FLAG_STATELESS_HINT, value);	}	/**	 * THIS METHOD IS NOT PART OF THE WICKET PUBLIC API. DO NOT CALL.	 * 	 * This method is called when a component will be rendered standalone.	 * 	 * @param component	 * 	 */	public final void startComponentRender(Component component)	{		renderedComponents = null;	}	/**	 * Get the string representation of this container.	 * 	 * @return String representation of this container	 */	public String toString()	{		if (versionManager != null)		{			return "[Page class = " + getClass().getName() + ", id = " + getId() + ", version = " +				versionManager.getCurrentVersionNumber() + ", ajax = " +				versionManager.getAjaxVersionNumber() + "]";		}		else		{			return "[Page class = " + getClass().getName() + ", id = " + getId() + ", version = " +				0 + "]";		}	}	/**	 * Throw an exception if not all components rendered.	 * 	 * @param renderedContainer	 *            The page itself if it was a full page render or the container that was rendered	 *            standalone	 */	private final void checkRendering(final MarkupContainer renderedContainer)	{		// If the application wants component uses checked and		// the response is not a redirect		final IDebugSettings debugSettings = Application.get().getDebugSettings();		if (debugSettings.getComponentUseCheck() && !getResponse().isRedirect())		{			final List unrenderedComponents = new ArrayList();			final StringBuffer buffer = new StringBuffer();			renderedContainer.visitChildren(new IVisitor()			{				public Object component(final Component component)				{					// If component never rendered					if (renderedComponents == null || !renderedComponents.contains(component))					{						// If auto component ...						if (!component.isAuto() && component.isVisibleInHierarchy())						{							// Increase number of unrendered components							unrenderedComponents.add(component);							// Add to explanatory string to buffer							buffer.append(Integer.toString(unrenderedComponents.size()) + ". " +								component + "\n");							String metadata = (String)component.getMetaData(Component.CONSTRUCTED_AT_KEY);							if (metadata != null)

⌨️ 快捷键说明

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