package votorola.a.web; // Copyright 2008, Michael Allan. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE.
import java.net.*;
import java.util.*;
import votorola.a.locale.*;
import votorola.g.lang.*;
import org.apache.wicket.*;
import org.apache.wicket.protocol.http.*;
/** A request cycle in the Web-based voter interface.
*/
public final @ThreadRestricted("wicket") class VRequestCycle extends WebRequestCycle
{
/** Constructs a VRequestCycle.
*/
VRequestCycle( VApplication application, WebRequest request, Response response )
{
super( application, request, response );
}
// ------------------------------------------------------------------------------------
/** Returns the application (A) bundle formatter for the request.
* It uses bundle base name 'votorola.a.locale.A'.
*
* @see
* locale/A.properties
*/
public BundleFormatter bunA() { return bunA; }
private final BundleFormatter bunA = new BundleFormatter
( ResourceBundle.getBundle( "votorola.a.locale.A", getRequest().getLocale() ));
/** Returns the Web (W) bundle formatter for the request.
* It uses bundle base name 'votorola.a.locale.W'.
*
* @see
* locale/W.properties
*/
public BundleFormatter bunW() { return bunW; }
private final BundleFormatter bunW = new BundleFormatter
( ResourceBundle.getBundle( "votorola.a.locale.W", getRequest().getLocale() ));
// /** Constructs a bundle formatter for the component's locale.
// */
// public static BundleFormatter newBun( Component component )
// {
// return new BundleFormatter( component.getLocale(), "votorola.a.locale.W" );
// }
/** Returns a URI for a bookmarkable page.
*
* @return normalized URI
* @see #urlFor(IPageMap,Class,PageParameters)
*/
public URI uriFor( IPageMap pageMap, Class pageClass )
{
return uriFor( pageMap, pageClass, /*parameters*/null );
}
/** Returns a URI for a bookmarkable page.
*
* @return normalized URI
* @see #urlFor(IPageMap,Class,PageParameters)
*/
public URI uriFor( IPageMap pageMap, Class pageClass, PageParameters parameters )
{
CharSequence cS = urlFor( pageMap, pageClass, /*parameters*/null );
try
{
URI uri = new URI( RequestUtils.toAbsolutePath( cS.toString() ));
return uri.normalize(); // chop trailing dot segments, '././' - seen for Application.getHomePage()
}
catch( URISyntaxException x ) { throw new RuntimeException( x ); } // not expected
}
/** @see #getApplication()
*/
public VApplication vApplication() { return (VApplication)getApplication(); } // rather than override getApplication(), because some of these getX methods are final, so use vX for all
/** @see #getRequest()
*/
public WebRequest vRequest() { return getWebRequest(); } // vX not getX, per vApplication
/** @see #getResponse()
*/
public WebResponse vResponse() { return getWebResponse(); } // vX not getX, per vApplication
/** @see #getSession()
*/
public VSession vSession() { return (VSession)getSession(); } // vX not getX, per vApplication
// - R e q u e s t - C y c l e --------------------------------------------------------
public static VRequestCycle get() { return (VRequestCycle)RequestCycle.get(); }
}