You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

IconAjaxLink.java 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright 2014 gitblit.com.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.gitblit.wicket.panels;
  17. import java.text.MessageFormat;
  18. import org.apache.wicket.Component;
  19. import org.apache.wicket.ajax.markup.html.AjaxLink;
  20. import org.apache.wicket.behavior.SimpleAttributeModifier;
  21. import org.apache.wicket.markup.ComponentTag;
  22. import org.apache.wicket.markup.MarkupStream;
  23. import org.apache.wicket.model.IModel;
  24. public abstract class IconAjaxLink<T> extends AjaxLink<T> {
  25. private static final long serialVersionUID = 1L;
  26. private final String iconClass;
  27. public IconAjaxLink(String wicketId, String iconClass, IModel<T> model) {
  28. super(wicketId, model);
  29. this.iconClass = iconClass;
  30. }
  31. @Override
  32. protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
  33. replaceComponentTagBody(markupStream, openTag, MessageFormat.format("<i class=\"{0}\"></i> {1}", iconClass, getModelObject().toString()));
  34. }
  35. public void setNoFollow() {
  36. Component c = get("link");
  37. c.add(new SimpleAttributeModifier("rel", "nofollow"));
  38. }
  39. }