org.apache.wicket.markup.ComponentTag Java Examples

The following examples show how to use org.apache.wicket.markup.ComponentTag. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FormComponent.java    From onedev with MIT License 6 votes vote down vote up
/**
 * Processes the component tag.
 * 
 * @param tag
 *            Tag to modify
 * @see org.apache.wicket.Component#onComponentTag(ComponentTag)
 */
@Override
protected void onComponentTag(final ComponentTag tag)
{
	tag.put("name", getInputName());

	if (!isEnabledInHierarchy())
	{
		onDisabled(tag);
	}

	if (isRequired())
	{
		onRequired(tag);
	}

	super.onComponentTag(tag);
}
 
Example #2
Source File: EmailStatusIcon.java    From artifact-listener with Apache License 2.0 6 votes vote down vote up
@Override
public void onComponentTag(final ComponentTag tag) {
	EmailStatus value = getValue();
	
	if (value != null) {
		String iconClass = "";
		String tooltipKey = getString("profile.email.status." + value.toString());
		if (value == EmailStatus.PENDING_CONFIRM) {
			iconClass = BOOTSTRAP_PENDING_CONFIRM_ICON_CLASS;
		} else if (value == EmailStatus.PENDING_DELETE) {
			iconClass = BOOTSTRAP_PENDING_DELETE_ICON_CLASS;
		} else if (value == EmailStatus.VALIDATED) {
			iconClass = BOOTSTRAP_VALIDATED_ICON_CLASS;
		}
		tag.append(CLASS_ATTRIBUTE, iconClass, SEPARATOR);
		tag.append(TOOLTIP_ATTRIBUTE, tooltipKey, SEPARATOR);
	}
	super.onComponentTag(tag);
}
 
Example #3
Source File: UploadIFrame.java    From ontopia with Apache License 2.0 6 votes vote down vote up
public UploadIFrame(FieldValueModel fieldValueModel) {
  this.fieldValueModel = fieldValueModel;

  // add header contributor for stylesheet
  add(CSSPackageResource.getHeaderContribution(getStylesheet()));
  
  WebMarkupContainer container = new WebMarkupContainer("container");
  container.setOutputMarkupId(true);
  add(container);
  // add form
  container.add(new UploadForm("form", container));
  // add onUploaded method
  container.add(new WebComponent("onUploaded") {
    @Override
    protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
      if (uploaded) {
        replaceComponentTagBody(markupStream, openTag,
            "window.parent." + getOnUploadedCallback() + "('', '')");
        uploaded = false;
      }
    }            
  });
}
 
Example #4
Source File: AjaxExternalLink.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public AjaxExternalLink(String id, String url) {
	super(id, url);
	
	add(new AjaxEventBehavior("onclick")
	{
		private static final long serialVersionUID = 1L;

		@Override
		protected void onEvent(AjaxRequestTarget target)
		{
			onClick(target);
		}

		@Override
		protected void onComponentTag(ComponentTag tag)
		{
			// add the onclick handler only if link is enabled
			if (isLinkEnabled())
			{
				super.onComponentTag(tag);
			}
		}
	});
}
 
Example #5
Source File: FooterPanel.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
public FooterPanel(String id) {
	super(id);
	
	ExternalLink link = new ExternalLink("home", ReleaseInfo.getHome()) {
           protected void onComponentTag(ComponentTag componentTag) {
               super.onComponentTag(componentTag);
               componentTag.put("target", "_blank");
           }
       };
	link.add(new Label("company", ReleaseInfo.getCompany()));
	add(link);
	
	Label version = new Label("version", getVersion());
	version.add(new SimpleTooltipBehavior(getBuildDate()));
	add(version);		
}
 
Example #6
Source File: UploadPanel.java    From ontopia with Apache License 2.0 6 votes vote down vote up
public UploadPanel(String id, FieldInstanceImageField parentField) {
  super(id);
  this.parentField = parentField;

  // add onUploaded behavior
  final OnUploadedBehavior onUploadBehavior = new OnUploadedBehavior();
  add(onUploadBehavior);
  add(new WebComponent("onUploaded") {
    @Override
    protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
      // calling it through setTimeout we ensure that the callback is called
      // in the proper execution context, that is the parent frame
      replaceComponentTagBody(markupStream, openTag,
          "function onUpload_" + UploadPanel.this.getMarkupId() +
          "(uploadedFile, clientFileName) {  window.setTimeout(function() { " + // window.location.reload(true); " +
          onUploadBehavior.getCallback() + "; }, 0 )}");
      } 
  });        
}
 
Example #7
Source File: BooleanFeatureEditor.java    From webanno with Apache License 2.0 6 votes vote down vote up
public BooleanFeatureEditor(String aId, MarkupContainer aItem, IModel<FeatureState> aModel)
{
    super(aId, aItem, new CompoundPropertyModel<>(aModel));

    BootstrapCheckBoxPickerConfig config = new BootstrapCheckBoxPickerConfig();
    config.withReverse(true);
    field = new BootstrapCheckBoxPicker("value", config) {
        private static final long serialVersionUID = -3413189824637877732L;

        @Override
        protected void onComponentTag(ComponentTag aTag)
        {
            super.onComponentTag(aTag);
            
            aTag.put("data-group-cls", "btn-group-justified");
        }
    };
    
    add(field);
}
 
Example #8
Source File: ResourceWizardBuilder.java    From syncope with Apache License 2.0 6 votes vote down vote up
@Override
protected WizardModel buildModelSteps(final Serializable modelObject, final WizardModel wizardModel) {
    ResourceTO resourceTO = ResourceTO.class.cast(modelObject);
    wizardModel.add(new ResourceDetailsPanel(resourceTO, createFlag));
    wizardModel.add(new ResourceConnConfPanel(resourceTO, createFlag) {

        private static final long serialVersionUID = -1128269449868933504L;

        @Override
        protected Pair<Boolean, String> check(final AjaxRequestTarget target) {
            return ResourceRestClient.check(modelObject);
        }

        @Override
        protected void onComponentTag(final ComponentTag tag) {
            tag.append("class", "scrollable-tab-content", " ");
        }

    });
    wizardModel.add(new ResourceConnCapabilitiesPanel(
            resourceTO, ConnectorRestClient.read(resourceTO.getConnector()).getCapabilities()));

    wizardModel.add(new ResourceSecurityPanel(resourceTO));
    return wizardModel;
}
 
Example #9
Source File: MarkdownReportPage.java    From onedev with MIT License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	if (filePath != null) { 
		File file = new File(getBuild().getReportDir(JobMarkdownReport.DIR), 
				reportName + "/" + filePath);
		try {
			String markdown = FileUtils.readFileToString(file, StandardCharsets.UTF_8);
			add(new MarkdownViewer("markdownReport", Model.of(markdown), null));
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	} else {
		add(new Label("markdownReport", "No markdown report published") {

			@Override
			protected void onComponentTag(ComponentTag tag) {
				super.onComponentTag(tag);
				tag.setName("div");
			}
			
		}.add(AttributeAppender.append("class", "alert alert-warning")));
	}
}
 
Example #10
Source File: VizigatorLinkFunctionBoxPanel.java    From ontopia with Apache License 2.0 6 votes vote down vote up
@Override
protected Component getLink(String id) {
  PageParameters pageParameters = new PageParameters();
  pageParameters.put("topicMapId", getTopicMapId());
  pageParameters.put("topicId", getTopicId());
  
  return new BookmarkablePageLink<Page>(id, VizigatorPage.class, pageParameters) {
    @Override
    protected void onComponentTag(ComponentTag tag) {
      tag.setName("a");
      //tag.put("target", "_blank");
      super.onComponentTag(tag);
    }
    @Override
    protected void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
      replaceComponentTagBody(markupStream, openTag, new ResourceModel("vizigator.text2").getObject().toString());
    }
  };
}
 
Example #11
Source File: LoginForm.java    From JPPF with Apache License 2.0 6 votes vote down vote up
/**
 * .
 */
public LoginForm() {
  super(PREFIX + ".form");
  add(username = new TextField<>(PREFIX + ".username.field", Model.of("")));
  add(password = new PasswordTextField(PREFIX + ".password.field", Model.of("")));
  password.setRequired(false);
  add(error = new Label(PREFIX + ".error", Model.of("")) {
    @Override
    protected void onComponentTag(final ComponentTag tag) {
      if (hasError) tag.append("style", "margin-top: 15px", ";");
    }
  });
  final AjaxButton button = new AjaxButton(PREFIX + ".ok") {
    @Override
    protected void onSubmit(final AjaxRequestTarget target) {
      if (debugEnabled) log.debug("clicked on login.ok");
      doOK(target);
    }
  };
  add(button);
  setDefaultButton(button);
}
 
Example #12
Source File: AjaxButtonWithIcon.java    From JPPF with Apache License 2.0 6 votes vote down vote up
@Override
protected void onComponentTag(final ComponentTag tag) {
  super.onComponentTag(tag);
  final Pair<String, String> pair = FileUtils.getFileNameAndExtension(imageName);
  final StringBuilder style = new StringBuilder();

  final String contextPath = RequestCycle.get().getRequest().getContextPath();
  String imageKey = null;
  if ((action != null) && (!action.isEnabled() || !action.isAuthorized())) {
    tag.getAttributes().put("class", "button_link_disabled");
    if (pair != null) imageKey = pair.first() + "-disabled";
  } else {
    if (pair != null) imageKey = pair.first();
  }
  if (imageKey != null) {
    imageKey = "images/toolbar/" + imageKey + "." + pair.second();
    final String resourceURL = JPPFWebConsoleApplication.get().getSharedImageURL(imageKey);
    style.append("background-image: url(" + contextPath + resourceURL + ")");
  }
  tag.getAttributes().put("style", style.append(FIXED_STYLE).toString());
}
 
Example #13
Source File: AbstractActionLink.java    From JPPF with Apache License 2.0 6 votes vote down vote up
@Override
protected void onComponentTag(final ComponentTag tag) {
  super.onComponentTag(tag);
  final Pair<String, String> pair = FileUtils.getFileNameAndExtension(imageName);
  final String contextPath = RequestCycle.get().getRequest().getContextPath();
  String imageKey = null;
  if ((action != null) && (!action.isEnabled() || !action.isAuthorized())) {
    tag.getAttributes().put("class", "button_link_disabled");
    if (pair != null) imageKey = pair.first() + "-disabled";
  } else {
    if (pair != null) imageKey = pair.first();
  }
  if (imageKey != null) {
    imageKey = "images/toolbar/" + imageKey + "." + pair.second();
    final String resourceURL = JPPFWebConsoleApplication.get().getSharedImageURL(imageKey);
    final String html = "<img src='" + contextPath + resourceURL + "'/>";
    setBody(Model.of(html));
    if (debugEnabled) log.debug("image html for key = {}, contextPath = {}: {}", imageKey, contextPath, html);
  }
  setEscapeModelStrings(false);
}
 
Example #14
Source File: ExtendedPalette.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
/**
 * factory method for the remove component
 *
 * @return remove component
 */
protected Component newRemoveComponent() {
    return new PaletteButton("removeButton") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            tag.getAttributes().put("onclick", getRemoveOnClickJS());
        }
    };
}
 
Example #15
Source File: ContextMenuPanel.java    From ontopia with Apache License 2.0 5 votes vote down vote up
public ContextMenuPanel(String id, final String menuId) {
  super(id);
  WebMarkupContainer container = new WebMarkupContainer("contextMenu") {      
    @Override
    protected void onComponentTag(ComponentTag tag) {
      tag.put("id", "m" + menuId);
      super.onComponentTag(tag);
    }      
  };
  add(container);    
  container.add(createListView("menu", "menuitem"));
}
 
Example #16
Source File: OntopolyBookmarkablePageLink.java    From ontopia with Apache License 2.0 5 votes vote down vote up
@Override
public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
  if (label != null) {
    replaceComponentTagBody(markupStream, openTag, 
        "<span>" + Strings.escapeMarkup(label) + "</span>");
  }
}
 
Example #17
Source File: ButtonFunctionBoxPanel.java    From ontopia with Apache License 2.0 5 votes vote down vote up
protected Component getButton(String id) {

    AjaxLink<Object> button = new AjaxLink<Object>(id) {

      @Override
      protected void onComponentTag(ComponentTag tag) {
        tag.setName("input");
        tag.put("type", "button");
        tag.put("value", getButtonLabel().getObject().toString());
        super.onComponentTag(tag);
      }

      @Override
      public void onClick(AjaxRequestTarget target) {
        ButtonFunctionBoxPanel.this.onClick(target);
      }
    };

    List<IBehavior> behaviors = getButtonBehaviors();
    if (behaviors != null) {
      Iterator<IBehavior> it = behaviors.iterator();
      while (it.hasNext()) {
        button.add(it.next());
      }
    }
    return button;
  }
 
Example #18
Source File: ExtendedPalette.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
/**
 * factory method for the addcomponent
 *
 * @return add component
 */
protected Component newAddComponent() {
    return new PaletteButton("addButton") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            tag.getAttributes().put("onclick", getAddOnClickJS());
        }
    };
}
 
Example #19
Source File: TabsPanel.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
protected void onComponentTag(ComponentTag tag) {
	checkComponentTag(tag, "ul");
	super.onComponentTag(tag);
	tag.append("class", "nav nav-tabs", " ");
	tag.put("role", "tablist");
}
 
Example #20
Source File: FieldInstanceTextArea.java    From ontopia with Apache License 2.0 5 votes vote down vote up
@Override
protected void onComponentTag(ComponentTag tag) {
  tag.setName("textarea");
  tag.put("cols", cols);
  tag.put("rows", rows);
  super.onComponentTag(tag);
}
 
Example #21
Source File: ProfileThumbnail.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Override
protected void onComponentTag(final ComponentTag tag) {
    super.onComponentTag(tag);
    checkComponentTag(tag, "a");

    final String userUuid = this.getDefaultModelObjectAsString();

    // image url, cached for a minute
    final String imageUrl = "/direct/profile/" + userUuid + "/image/thumb" + "?t="
            + TimeUnit.MILLISECONDS.toMinutes(System.currentTimeMillis());

    // output image
    tag.put("style", "background-image:url(" + imageUrl + ")");
}
 
Example #22
Source File: ExtendedPalette.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
/**
 * factory method for the addAll component
 *
 * @return addAll component
 */
protected Component newAddAllComponent() {
    return new PaletteButton("addAllButton") {
        private static final long serialVersionUID = 1L;

        protected void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            tag.getAttributes().put("onclick", getAddAllOnClickJS());
        }
    };
}
 
Example #23
Source File: OntopolyImage.java    From ontopia with Apache License 2.0 5 votes vote down vote up
@Override
protected void onComponentTag(ComponentTag tag) {
  if (titleModel != null) {
    if (titleModel.getObject() != null) {
      tag.put("title", titleModel.getObject());
    }
  }
  super.onComponentTag(tag);
}
 
Example #24
Source File: FieldInstanceTextField.java    From ontopia with Apache License 2.0 5 votes vote down vote up
@Override
protected void onComponentTag(ComponentTag tag) {
  tag.setName("input");
  tag.put("type", "text");
  tag.put("size", cols);
  super.onComponentTag(tag);
}
 
Example #25
Source File: InfinitePagingDataTable.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Override
public void onComponentTag(final Component component, final ComponentTag tag)
{
	String className = getCssClass();
	if (!Strings.isEmpty(className))
	{
		tag.append("class", className, " ");
	}
}
 
Example #26
Source File: AdvancedFormComponentLabel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@Override
public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
	super.onComponentTagBody(markupStream, openTag);

	FormComponent<?> fc = getFormComponent();
	if (fc.isRequired()) {
		fc.getResponse().write(new ResourceModel("required.indicator").getObject().toString());
	}			
}
 
Example #27
Source File: StylableSelectOptions.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Override
protected void onComponentTag(ComponentTag tag) {
	if(style != null && !"null".equals(style)) {
		tag.put("style", style);
	}
	super.onComponentTag(tag);
}
 
Example #28
Source File: ProfileImage.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
protected void onComponentTag(ComponentTag tag) {
	super.onComponentTag(tag);
	checkComponentTag(tag, "img");
	
	String userUuid = this.getDefaultModelObjectAsString();
	
	//determine size
	String sizePart = "";
	switch (this.size) {
		case ProfileConstants.PROFILE_IMAGE_MAIN: {
			break;
		}
		case ProfileConstants.PROFILE_IMAGE_THUMBNAIL: {
			sizePart = "/thumb";
			break;
		}
		case ProfileConstants.PROFILE_IMAGE_AVATAR: {
			sizePart = "/avatar";
			break;
		}
	}
	
	//Force a reload
	String url = "/direct/profile/"+userUuid + "/image" + sizePart + "?v=" + RandomStringUtils.randomAlphabetic(10);
	
	tag.put("src", url);
	tag.put("alt", "User profile image");
}
 
Example #29
Source File: ExtendedPalette.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
/**
 * factory method for the removeAll component
 *
 * @return removeAll component
 */
protected Component newRemoveAllComponent() {
    return new PaletteButton("removeAllButton") {
        private static final long serialVersionUID = 1L;

        protected void onComponentTag(ComponentTag tag) {
            super.onComponentTag(tag);
            tag.getAttributes().put("onclick", getRemoveAllOnClickJS());
        }
    };
}
 
Example #30
Source File: ProfileThumbnail.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
@Override
protected void onComponentTag(final ComponentTag tag) {
    super.onComponentTag(tag);
    checkComponentTag(tag, "a");

    final String userUuid = this.getDefaultModelObjectAsString();

    // image url, cached for a minute
    final String imageUrl = "/direct/profile/" + userUuid + "/image/thumb" + "?t="
            + TimeUnit.MILLISECONDS.toMinutes(System.currentTimeMillis());

    // output image
    tag.put("style", "background-image:url(" + imageUrl + ")");
}