package votorola.g.servlet; // 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.*; import org.apache.wicket.markup.*; import org.apache.wicket.markup.html.form.*; import org.apache.wicket.model.*; import votorola.g.lang.*; /** An extended implementation of a submit link. */ public @ThreadRestricted("wicket") class SubmitLinkX extends SubmitLink { // Cf. BookmarkablePageLinkX /** Constructs a SubmitLinkX. * * @see SubmitLink#SubmitLink(String) */ public SubmitLinkX( String id ) { super( id ); } // ------------------------------------------------------------------------------------ /** The model for the visible content of the link. If no model is set, then the * body is taken from the template (as usual for a link). * * @see #setBodyModel(IModel) * @see #setBodyModel(String) */ public IModel getBodyModel() { return bodyModel; } private IModel bodyModel; /** Sets the model for the link body. * * @see #getBodyModel() */ public @ThreadRestricted("constructor") void setBodyModel( IModel bodyModel ) { this.bodyModel = bodyModel; } /** Sets a constant string as the model for the link body. * * @see #getBodyModel() */ public @ThreadRestricted("constructor") void setBodyModel( String bodyString ) { setBodyModel( new Model( bodyString )); } // - C o m p o n e n t ---------------------------------------------------------------- protected void onComponentTagBody( final MarkupStream markupStream, final ComponentTag tag ) { final IModel mB = bodyModel; // snapshot copy, for atomic test/use if( mB == null ) { super.onComponentTagBody( markupStream, tag ); return; } if( !isLinkEnabled() && getBeforeDisabledLink() != null ) // per AbstractLink { getResponse().write( getBeforeDisabledLink() ); } // renderComponentTagBody( markupStream, tag ); replaceComponentTagBody( markupStream, tag, getModelObjectAsString( mB.getObject() )); if( !isLinkEnabled() && getAfterDisabledLink() != null ) // " { getResponse().write( getAfterDisabledLink() ); } } }