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 org.apache.wicket.markup.html.basic.*; import org.apache.wicket.markup.html.panel.*; import votorola.a.locale.*; import votorola.a.register.*; import votorola.a.voter.*; import votorola.a.web.authen.*; import votorola.g.lang.*; import votorola.g.servlet.*; /** A super-bar of navigation links and session controls, for the page top. * At present, it is nothing but a login control. * * @see * WC_NavigationControls.html */ public @ThreadRestricted("wicket") final class WC_NavigationControls extends Panel { /** Constructs a WC_NavigationControls. * * @param page in which the controls will appear */ public WC_NavigationControls( String id, final VPage page, final VRequestCycle cycle ) { super( id ); setRenderBodyOnly( true ); // User and login/logout link. // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { final Registration user = cycle.vSession().getUser(); if( user == null ) add( VPage.newNullComponent( "userLink" )); else add( newVoterLink( "userLink", user.voterEmail(), page )); } add( WC_LoginLink.newInOut( "linkLoginLogout", cycle )); } //// P r i v a t e /////////////////////////////////////////////////////////////////////// private Fragment newVoterLink( final String id, final String voterEmail, final VPage page ) { final Fragment frag = new Fragment( id, "frag-voterLink", WC_NavigationControls.this ); final LinkX link = new WP_Voter.VoterLink( "link", voterEmail, /*body*/VPage.shortened( voterEmail )); frag.add( link ); return frag; } }