Java Code Examples for org.apache.wicket.markup.ComponentTag

The following examples show how to use org.apache.wicket.markup.ComponentTag. These examples are extracted from open source projects. 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 Project: JPPF   Author: jppf-grid   File: AbstractActionLink.java    License: 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 #2
Source Project: JPPF   Author: jppf-grid   File: AjaxButtonWithIcon.java    License: 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 #3
Source Project: JPPF   Author: jppf-grid   File: LoginForm.java    License: 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 #4
Source Project: onedev   Author: theonedev   File: MarkdownReportPage.java    License: 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 #5
Source Project: syncope   Author: apache   File: ResourceWizardBuilder.java    License: 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 #6
Source Project: onedev   Author: theonedev   File: FormComponent.java    License: 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 #7
Source Project: artifact-listener   Author: openwide-java   File: EmailStatusIcon.java    License: 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 #8
Source Project: nextreports-server   Author: nextreports   File: FooterPanel.java    License: 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 #9
Source Project: webanno   Author: webanno   File: BooleanFeatureEditor.java    License: 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 #10
Source Project: sakai   Author: sakaiproject   File: AjaxExternalLink.java    License: 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 #11
Source Project: ontopia   Author: ontopia   File: UploadIFrame.java    License: 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 #12
Source Project: ontopia   Author: ontopia   File: UploadPanel.java    License: 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 #13
Source Project: ontopia   Author: ontopia   File: VizigatorLinkFunctionBoxPanel.java    License: 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 #14
Source Project: Orienteer   Author: OrienteerBAP   File: BooleanViewPanel.java    License: Apache License 2.0 5 votes vote down vote up
protected void initialize()
{
	add(new WebMarkupContainer("icon", getModel())
	{
		boolean effectiveValue;
		
		@Override
		protected void onComponentTag(ComponentTag tag) {
			super.onComponentTag(tag);
			tag.append("class", effectiveValue?"fa-check-circle text-success":"fa-times-circle text-danger", " ");
		}

		@Override
		protected void onConfigure() {
			super.onConfigure();
			Boolean value = getModelObject();
			if(value==null) value = defaultValue;
			boolean visibility = false;
			if(value!=null)
			{
				effectiveValue = value;
				visibility = effectiveValue?!hideIfTrue:!hideIfFalse;
			}
			setVisible(visibility);
		}
	});
}
 
Example #15
Source Project: pm-wicket-utils   Author: premium-minds   File: BootstrapDateTimePickerBehaviour.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onComponentTag(Component component, ComponentTag tag) 
{
	super.onComponentTag(component, tag);
	
	if(component.isEnabledInHierarchy()) {
		
		tag.put("data-date-language", component.getLocale().getLanguage());
	}
}
 
Example #16
Source Project: onedev   Author: theonedev   File: ProjectAvatar.java    License: MIT License 5 votes vote down vote up
@Override
protected void onComponentTag(ComponentTag tag) {
	super.onComponentTag(tag);
	
	tag.setName("img");
	tag.append("class", "project-avatar", " ");
	tag.put("src", url);
}
 
Example #17
Source Project: onedev   Author: theonedev   File: SubscriptionStatusLink.java    License: MIT License 5 votes vote down vote up
@Override
protected void onComponentTag(ComponentTag tag) {
	super.onComponentTag(tag);
	String classes = tag.getAttribute("class");
	if (classes == null)
		classes = "";
	if (isSubscribed()) {
		tag.put("class", classes + " subscription-status subscribed");
		tag.put("title", "Subscribed. Click to unsubscribe");
	} else {
		tag.put("class", classes + " subscription-status unsubscribed");
		tag.put("title", "Unsubscribed. Click to subscribe");
	}
}
 
Example #18
Source Project: syncope   Author: apache   File: DerAttrs.java    License: Apache License 2.0 5 votes vote down vote up
public DerSchemas(
        final String id,
        final Map<String, DerSchemaTO> schemas,
        final IModel<List<Attr>> attrTOs) {
    super(id);

    add(new ListView<Attr>("schemas", attrTOs) {

        private static final long serialVersionUID = 9101744072914090143L;

        @Override
        public void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) {
            super.onComponentTagBody(markupStream, openTag);
            openTag.put("class", "empty");
        }

        @Override
        protected void populateItem(final ListItem<Attr> item) {
            Attr attrTO = item.getModelObject();

            IModel<String> model;
            List<String> values = attrTO.getValues();
            if (values == null || values.isEmpty()) {
                model = new ResourceModel("derived.emptyvalue.message", StringUtils.EMPTY);
            } else {
                model = new Model<>(values.get(0));
            }

            AjaxTextFieldPanel panel = new AjaxTextFieldPanel(
                    "panel",
                    schemas.get(attrTO.getSchema()).getLabel(SyncopeConsoleSession.get().getLocale()),
                    model,
                    false);
            panel.setEnabled(false);
            panel.setRequired(true);
            panel.setOutputMarkupId(true);
            item.add(panel);
        }
    });
}
 
Example #19
Source Project: syncope   Author: apache   File: Navbar.java    License: Apache License 2.0 5 votes vote down vote up
public void setActiveNavItem(final String id) {
    navbarItems.stream().
            filter(containingLI -> containingLI.getMarkupId().equals(id)).findFirst().
            ifPresent(found -> found.add(new Behavior() {

        private static final long serialVersionUID = -5775607340182293596L;

        @Override
        public void onComponentTag(final Component component, final ComponentTag tag) {
            tag.put("class", "active");
        }
    }));
}
 
Example #20
Source Project: onedev   Author: theonedev   File: UserAvatar.java    License: MIT License 5 votes vote down vote up
@Override
protected void onComponentTag(ComponentTag tag) {
	super.onComponentTag(tag);
	
	tag.setName("img");
	tag.put("src", url);
}
 
Example #21
Source Project: onedev   Author: theonedev   File: StateStatsBar.java    License: MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	int totalCount = getModelObject().values().stream().collect(Collectors.summingInt(it->it));
	if (totalCount != 0) {
		RepeatingView statesView = new RepeatingView("states");
		for (StateSpec state: OneDev.getInstance(SettingManager.class).getIssueSetting().getStateSpecs()) {
			Integer count = getModelObject().get(state.getName());
			if (count != null) { 
				Link<Void> link = newStateLink(statesView.newChildId(), state.getName());
				link.add(AttributeAppender.append("title", count + " " + state.getName().toLowerCase() + " issues"));
				link.add(AttributeAppender.append("data-percent", count*1.0/totalCount));
				link.add(AttributeAppender.append("style", "background-color: " + state.getColor()));
				statesView.add(link);
			}
		}
		add(statesView);
	} else {
		add(new Label("states", "&nbsp;") {

			@Override
			protected void onComponentTag(ComponentTag tag) {
				super.onComponentTag(tag);
				tag.setName("span");
			}
			
		}.setEscapeModelStrings(false));
		add(AttributeAppender.append("title", "No issues in milestone"));
	}
	
	setOutputMarkupId(true);
}
 
Example #22
Source Project: onedev   Author: theonedev   File: AvatarUploadField.java    License: MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	add(dataField = new TextField<String>("data", Model.of(getModelObject())));
	
	WebComponent fileInput = new WebComponent("fileInput");
	fileInput.setOutputMarkupId(true);
	add(fileInput);
	
	add(new WebMarkupContainer("fileLabel") {

		@Override
		protected void onComponentTag(ComponentTag tag) {
			super.onComponentTag(tag);
			tag.put("for", fileInput.getMarkupId());
		}
		
	});
	
	add(behavior = new AbstractPostAjaxBehavior() {
		
		@Override
		protected void respond(AjaxRequestTarget target) {
			send(AvatarUploadField.this, Broadcast.BUBBLE, new AvatarFileSelected(target));	
		}
		
	});
}
 
Example #23
Source Project: Orienteer   Author: OrienteerBAP   File: OrienteerDataTable.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected Item<IColumn<T, S>> newCellItem(String id, int index, final IModel<IColumn<T, S>> model) {
	return new Item<IColumn<T, S>>(id, index, model) {
		@Override
		protected void onComponentTag(ComponentTag tag) {
			super.onComponentTag(tag);
			headersToolbar.changeColorForFilteredColumn(tag, model.getObject());
		}
	};
}
 
Example #24
Source Project: openmeetings   Author: apache   File: OmTextLabel.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) {
	final String vis = openTag.getAttribute(markupStream.getWicketNamespace() + WICKET_VISIBLE);
	if (vis != null && Boolean.FALSE.equals(Boolean.valueOf(vis))) {
		//skip the body
		return;
	}
	super.onComponentTagBody(markupStream, openTag);
}
 
Example #25
Source Project: projectforge-webapp   Author: micromata   File: PFAutoCompleteTextField.java    License: GNU General Public License v3.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
protected void onComponentTag(final ComponentTag tag)
{
  super.onComponentTag(tag);
  // disable browser's autocomplete
  tag.put("autocomplete", "off");
}
 
Example #26
Source Project: webanno   Author: webanno   File: CurationPage.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onComponentTag(ComponentTag tag)
{
    // add onclick handler to the browser
    // if clicked in the browser, the function
    // click.response(AjaxRequestTarget target) is called on the server side
    tag.put("ondblclick", "Wicket.Ajax.get({'u':'" + click.getCallbackUrl() + "'})");
    tag.put("onclick", "Wicket.Ajax.get({'u':'" + click.getCallbackUrl() + "'})");
}
 
Example #27
Source Project: nextreports-server   Author: nextreports   File: ExtendedPalette.java    License: 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 #28
Source Project: nextreports-server   Author: nextreports   File: ExtendedPalette.java    License: 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 #29
Source Project: sakai   Author: sakaiproject   File: ProfileThumbnail.java    License: 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 #30
Source Project: sakai   Author: sakaiproject   File: ProfileImage.java    License: 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");
}