org.apache.wicket.AttributeModifier Java Examples
The following examples show how to use
org.apache.wicket.AttributeModifier.
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: GradebookPage.java From sakai with Educational Community License v2.0 | 6 votes |
@Override public void onBeforeRender() { super.onBeforeRender(); // add simple feedback nofication to sit above the table // which is reset every time the page renders this.liveGradingFeedback = new Label("liveGradingFeedback", getString("feedback.saved")); this.liveGradingFeedback.setVisible(this.hasGradebookItems && this.hasStudents); this.liveGradingFeedback.setOutputMarkupId(true); this.liveGradingFeedback.add(DISPLAY_NONE); // add the 'saving...' message to the DOM as the JavaScript will // need to be the one that displays this message (Wicket will handle // the 'saved' and 'error' messages when a grade is changed this.liveGradingFeedback.add(new AttributeModifier("data-saving-message", getString("feedback.saving"))); this.tableArea.addOrReplace(this.liveGradingFeedback); }
Example #2
Source File: SecureStringEditor.java From yes-cart with Apache License 2.0 | 6 votes |
/** * Construct simple text editor. * * @param id editor id. * @param markupProvider markup object. * @param model model. * @param labelModel label model * @param errorLabelModel error label model * @param attrValue {@link org.yes.cart.domain.entity.AttrValue} * @param readOnly if true this component is read only */ public SecureStringEditor(final String id, final MarkupContainer markupProvider, final IModel<String> model, final IModel<String> labelModel, final IModel<String> errorLabelModel, final AttrValueWithAttribute attrValue, final boolean readOnly) { super(id, "secureStringEditor", markupProvider); final PasswordTextField textField = new PasswordTextField(EDIT, model); textField.setLabel(labelModel); textField.setRequired(attrValue.getAttribute().isMandatory()); textField.setEnabled(!readOnly); if (StringUtils.isNotBlank(attrValue.getAttribute().getRegexp())) { textField.add(new CustomPatternValidator(attrValue.getAttribute().getRegexp(), errorLabelModel)); } textField.add(new AttributeModifier("placeholder", labelModel)); add(textField); }
Example #3
Source File: AjaxLazyLoadImage.java From sakai with Educational Community License v2.0 | 6 votes |
public Image renderImage(AjaxRequestTarget target, boolean fullRender) { if(returnPage != null || returnClass != null) { link.add(new AttributeModifier("title", new ResourceModel("click_to_max"))); link.setEnabled(true); } link.removeAll(); Image img = null; if(!autoDetermineChartSizeByAjax) { img = createImage("content", getImageData()); }else{ img = createImage("content", getImageData(selectedWidth, selectedHeight)); } img.add(AttributeModifier.replace("style", "display: none; margin: 0 auto;")); link.add(img); setState((byte) 1); if(fullRender) { if(target != null) { target.add(link); target.appendJavaScript("jQuery('#"+img.getMarkupId()+"').fadeIn();"); } setState((byte) 2); } return img; }
Example #4
Source File: ChainLayerTraitsEditor.java From webanno with Apache License 2.0 | 6 votes |
@Override protected void initializeForm(Form<ChainLayerTraits> aForm) { aForm.add(new ValidationModeSelect("validationMode", getLayerModel())); aForm.add(new AnchoringModeSelect("anchoringMode", getLayerModel())); aForm.add(new OverlapModeSelect("overlapMode", getLayerModel())); CheckBox linkedListBehavior = new CheckBox("linkedListBehavior"); linkedListBehavior.setModel(PropertyModel.of(getLayerModel(), "linkedListBehavior")); aForm.add(linkedListBehavior); CheckBox crossSentence = new CheckBox("crossSentence"); crossSentence.setOutputMarkupPlaceholderTag(true); crossSentence.setModel(PropertyModel.of(getLayerModel(), "crossSentence")); crossSentence.add(visibleWhen(() -> !isBlank(getLayerModelObject().getType()))); aForm.add(crossSentence); TextArea<String> onClickJavascriptAction = new TextArea<String>("onClickJavascriptAction"); onClickJavascriptAction.setModel(PropertyModel.of(getLayerModel(), "onClickJavascriptAction")); onClickJavascriptAction.add(new AttributeModifier("placeholder", "alert($PARAM.PID + ' ' + $PARAM.PNAME + ' ' + $PARAM.DOCID + ' ' + " + "$PARAM.DOCNAME + ' ' + $PARAM.fieldname);")); aForm.add(onClickJavascriptAction); }
Example #5
Source File: FieldInstanceImageField.java From ontopia with Apache License 2.0 | 6 votes |
public FieldInstanceImageField(String id, FieldValueModel _fieldValueModel, boolean readonly) { super(id); this.fieldValueModel = _fieldValueModel; image = new Image("image"); image.add(new AttributeModifier("src", true, new AbstractReadOnlyModel<String>() { @Override public final String getObject() { TopicMap topicMap = fieldValueModel.getFieldInstanceModel().getFieldInstance().getInstance().getTopicMap(); Object o = fieldValueModel.getFieldValue(); return getRequest().getRelativePathPrefixToContextRoot() + "occurrenceImages?topicMapId=" + topicMap.getId() + "&occurrenceId=" + ((o instanceof OccurrenceIF ? ((OccurrenceIF)o).getObjectId(): "unknown")); } })); upload = new UploadPanel("upload", this); add(image); add(upload); if (fieldValueModel.isExistingValue()) { upload.setVisible(false); } else { image.setVisible(false); if (readonly) upload.setVisible(false); } }
Example #6
Source File: ProductItemPanel.java From the-app with Apache License 2.0 | 6 votes |
private Component productDetailImageLink() { Link<Void> detailPageLink = new Link<Void>("productDetailLink") { @Override public void onClick() { PageParameters pageParameters = new PageParameters(); pageParameters.set("urlname", productUrlModel.getObject()); setResponsePage(new ProductDetailPage(pageParameters)); } }; WebMarkupContainer image = new WebMarkupContainer("image"); image.add(new AttributeModifier("src", new ImageLinkModel(productInfoModel, this))); image.add(new AttributeModifier("title", new PropertyModel<String>(productInfoModel, "description"))); image.add(new AttributeModifier("alt", new PropertyModel<String>(productInfoModel, "name"))); image.setOutputMarkupId(true); detailPageLink.add(image); return detailPageLink; }
Example #7
Source File: BasePage.java From sakai with Educational Community License v2.0 | 6 votes |
/** * Helper to build a notification flag with a Bootstrap popover */ public WebMarkupContainer buildFlagWithPopover(final String componentId, final String message) { final WebMarkupContainer flagWithPopover = new WebMarkupContainer(componentId); flagWithPopover.add(new AttributeModifier("title", message)); flagWithPopover.add(new AttributeModifier("aria-label", message)); flagWithPopover.add(new AttributeModifier("data-toggle", "popover")); flagWithPopover.add(new AttributeModifier("data-trigger", "manual")); flagWithPopover.add(new AttributeModifier("data-placement", "bottom")); flagWithPopover.add(new AttributeModifier("data-html", "true")); flagWithPopover.add(new AttributeModifier("data-container", "#gradebookGrades")); flagWithPopover.add(new AttributeModifier("data-template", "<div class=\"gb-popover popover\" role=\"tooltip\"><div class=\"arrow\"></div><div class=\"popover-content\"></div></div>")); flagWithPopover.add(new AttributeModifier("data-content", generatePopoverContent(message))); flagWithPopover.add(new AttributeModifier("tabindex", "0")); return flagWithPopover; }
Example #8
Source File: Tabbable.java From onedev with MIT License | 6 votes |
@Override protected void onInitialize() { super.onInitialize(); add(new ListView<Tab>("tabs", new LoadableDetachableModel<List<Tab>>() { @Override protected List<Tab> load() { return getTabs().stream().collect(Collectors.toList()); } }) { @Override protected void populateItem(ListItem<Tab> item) { Tab tab = item.getModelObject(); if (tab.isSelected()) item.add(AttributeModifier.append("class", "active")); item.add(tab.render("tab")); } }); }
Example #9
Source File: TextAreaFeatureEditor.java From webanno with Apache License 2.0 | 6 votes |
@Override protected AbstractTextComponent createInputField() { TextArea<String> textarea = new TextArea<>("value"); textarea.add(new AjaxPreventSubmitBehavior()); try { String traitsString = getModelObject().feature.getTraits(); StringFeatureTraits traits = JSONUtil.fromJsonString(StringFeatureTraits.class, traitsString); textarea.add(new AttributeModifier("rows", traits.getCollapsedRows())); textarea.add(new AttributeAppender("onfocus", "this.rows=" + traits.getExpandedRows() + ";")); textarea.add(new AttributeAppender("onblur", "this.rows=" + traits.getCollapsedRows() + ";")); } catch (IOException e) { e.printStackTrace(); } return textarea; }
Example #10
Source File: SortGradeItemsByGradeItemPanel.java From sakai with Educational Community License v2.0 | 6 votes |
@Override public void onInitialize() { super.onInitialize(); final List<Assignment> assignments = this.businessService.getGradebookAssignments(SortType.SORT_BY_SORTING); add(new ListView<Assignment>("gradeItemList", assignments) { @Override protected void populateItem(final ListItem<Assignment> assignmentItem) { final Assignment assignment = assignmentItem.getModelObject(); assignmentItem.add(new Label("name", assignment.getName())); assignmentItem.add(new HiddenField<Long>("id", Model.of(assignment.getId())).add( new AttributeModifier("name", String.format("id", assignment.getId())))); assignmentItem.add(new HiddenField<Integer>("order", Model.of(assignment.getSortOrder())).add( new AttributeModifier("name", String.format("item_%s[order]", assignment.getId())))); assignmentItem.add(new HiddenField<Integer>("current_order", Model.of(assignment.getSortOrder())).add( new AttributeModifier("name", String.format("item_%s[current_order]", assignment.getId())))); } }); }
Example #11
Source File: DatePropertyEditor.java From onedev with MIT License | 6 votes |
@Override protected void onInitialize() { super.onInitialize(); DateTextFieldConfig config = new DateTextFieldConfig(); config.autoClose(true).withFormat(DateEditSupport.DATE_INPUT_FORMAT) .highlightToday(true).showTodayButton(TodayButton.TRUE); input = new DateTextField("input", Model.of(getModelObject()), config); input.setType(getDescriptor().getPropertyClass()); Method propertyGetter = getDescriptor().getPropertyGetter(); if (propertyGetter.getAnnotation(OmitName.class) != null) input.add(AttributeModifier.replace("placeholder", EditableUtils.getDisplayName(propertyGetter))); input.setLabel(Model.of(getDescriptor().getDisplayName())); add(input); input.add(new OnTypingDoneBehavior() { @Override protected void onTypingDone(AjaxRequestTarget target) { onPropertyUpdating(target); } }); }
Example #12
Source File: URLPagingNavigator.java From yes-cart with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected AbstractLink newPagingNavigationLink(final String id, final IPageable pageable, int pageNumber) { final LinksSupport links = ((AbstractWebPage) getPage()).getWicketSupportFacade().links(); final PageParameters params = links.getFilteredCurrentParameters(pageParameters); final long pNum; if ("last".equals(id)) { pNum = getPageable().getPageCount() - 1; } else { pNum = pageNumber; } params.set(WebParametersKeys.PAGE, pNum); return (AbstractLink) links.newLink(id, params).add(new AttributeModifier("class", "nav-page-control " + id)); }
Example #13
Source File: SubclassCreationDialog.java From inception with Apache License 2.0 | 6 votes |
public ContentPanel(String aId, IModel<KBConcept> newSubclassConceptModel) { super(aId); // add components for input form RequiredTextField<String> name = new RequiredTextField<>("name"); name.add(AttributeModifier.append("placeholder", new ResourceModel("subclassNamePlaceholder"))); LambdaAjaxButton<KBConcept> createButton = new LambdaAjaxButton<KBConcept>( "createSubclass", SubclassCreationDialog.this::actionCreateSubclass); createButton.add(new Label("createLabel", new ResourceModel("create"))); // initialize input form and add it to the content panel Form<KBConcept> form = new Form<KBConcept>("form", CompoundPropertyModel.of(newSubclassConceptModel)); form.add(name); form.add(createButton); form.setDefaultButton(createButton); add(form); }
Example #14
Source File: ProductPerPageListView.java From yes-cart with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override protected void populateItem(ListItem<String> stringListItem) { final String pageSize = stringListItem.getModelObject(); final Label label = new Label(WebParametersKeys.QUANTITY, pageSize); final AbstractWebPage page = ((AbstractWebPage) getPage()); final PageParameters pageParameters = page.getPageParameters(); final LinksSupport links = page.getWicketSupportFacade().links(); final PaginationSupport pagination = page.getWicketSupportFacade().pagination(); final PageParameters params = links.getFilteredCurrentParameters(pageParameters); params.set(WebParametersKeys.QUANTITY, pageSize); final Link pageSizeLink = links.newLink(ITEMS_PER_PAGE, params); pageSizeLink.add(label); stringListItem.add(pageSizeLink); if (pagination.markSelectedPageSizeLink(pageSizeLink, pageParameters, getModelObject(), NumberUtils.toInt(pageSize))) { stringListItem.add(new AttributeModifier("class", "active")); } }
Example #15
Source File: MyNamePronunciationDisplay.java From sakai with Educational Community License v2.0 | 6 votes |
private void addNameRecord() { WebMarkupContainer nameRecordingContainer = new WebMarkupContainer("nameRecordingContainer"); nameRecordingContainer.add(new Label("nameRecordingLabel", new ResourceModel("profile.name.recording"))); WebMarkupContainer audioPlayer = new WebMarkupContainer("audioPlayer"); final String slash = Entity.SEPARATOR; final StringBuilder path = new StringBuilder(); path.append(slash); path.append("direct"); path.append(slash); path.append("profile"); path.append(slash); path.append(userProfile.getUserUuid()); path.append(slash); path.append("pronunciation"); path.append("?v="); path.append(RandomStringUtils.random(8, true, true)); audioPlayer.add(new AttributeModifier("src", path.toString())); nameRecordingContainer.add(audioPlayer); add(nameRecordingContainer); if (profileLogic.getUserNamePronunciation(userProfile.getUserUuid()) == null) nameRecordingContainer.setVisible(false); else visibleFieldCount++; }
Example #16
Source File: FeedbackLabel.java From sakai with Educational Community License v2.0 | 6 votes |
/** * Set the content of this FeedbackLabel, depending on if the component has a FeedbackMessage. * * The HTML class attribute will be filled with the error level of the feedback message. That way, you can easily * style different messages differently. Examples: * * class = "feedbacklabel INFO" * class = "feedbacklabel ERROR" * class = "feedbacklabel DEBUG" * class = "feedbacklabel FATAL" * * * @see Component */ @Override protected void onBeforeRender() { super.onBeforeRender(); this.setDefaultModel(null); if(component.hasFeedbackMessage()){ if(this.text!=null){ this.setDefaultModel(text); } else { this.setDefaultModel(new Model(component.getFeedbackMessages().first())); } this.add(new AttributeModifier("class", true, new Model("feedbackLabel " + component.getFeedbackMessages().first().getLevelAsString()))); } else { this.setDefaultModel(null); } }
Example #17
Source File: IconWithClueTip.java From sakai with Educational Community License v2.0 | 6 votes |
public IconWithClueTip(String id, String iconUrl, IModel textModel) { super(id); //link AjaxFallbackLink link = new AjaxFallbackLink("link") { public void onClick(AjaxRequestTarget target) { //nothing } }; link.add(new AttributeModifier("title", true, textModel)); //image ContextImage image = new ContextImage("icon",new Model(iconUrl)); image.add(new AttributeModifier("alt", true, new ResourceModel("accessibility.tooltip"))); link.add(image); add(link); }
Example #18
Source File: StartWidgetView.java From openmeetings with Apache License 2.0 | 6 votes |
@Override protected void onInitialize() { add(new WebMarkupContainer("step1").add(new PublicRoomsEventBehavior())); add(new WebMarkupContainer("step2").add(new PublicRoomsEventBehavior())); add(new WebMarkupContainer("step3").add(new WebMarkupContainer("avTest").add(AttributeModifier.append("href" , RequestCycle.get().urlFor(HashPage.class, new PageParameters().add(APP, APP_TYPE_SETTINGS)).toString())))); add(new WebMarkupContainer("step4").add(new PublicRoomsEventBehavior())); add(new Label("123msg", Application.getString("widget.start.desc")) //Application here is used to substitute {0} .setEscapeModelStrings(false)); add(new BootstrapButton("start", new ResourceModel("788"), Buttons.Type.Outline_Primary).add(new PublicRoomsEventBehavior())); add(new BootstrapButton("calendar", new ResourceModel("291"), Buttons.Type.Outline_Primary).add(new AjaxEventBehavior(EVT_CLICK) { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { ((MainPage)getPage()).updateContents(CALENDAR, target); } })); super.onInitialize(); }
Example #19
Source File: SelectOptionsGroup.java From sakai with Educational Community License v2.0 | 5 votes |
public SelectOptionsGroup(String id, IModel model) { super(id); WebMarkupContainer optgroup = new WebMarkupContainer("optgroup"); optgroup.add(new AttributeModifier("label", true, model)); add(optgroup); optgroup.add(getBodyContainer()); }
Example #20
Source File: MainPanel.java From openmeetings with Apache License 2.0 | 5 votes |
private void updateContents(BasePanel inPanel, IPartialPageRequestHandler handler) { if (inPanel != null) { BasePanel prev = getCurrentPanel(); if (prev != null) { prev.cleanup(handler); } handler.add(contents.replace(inPanel), this.add(AttributeModifier.replace(ATTR_CLASS, "main " + inPanel.getCssClass()))); inPanel.onMenuPanelLoad(handler); } }
Example #21
Source File: WidgetTabTemplate.java From sakai with Educational Community License v2.0 | 5 votes |
private void renderChart() { WebMarkupContainer chartTd = new WebMarkupContainer("chartTd"); chartTd.setOutputMarkupId(true); chart = new AjaxLazyLoadImage("chart", OverviewPage.class) { private static final long serialVersionUID = 1L; @Override public byte[] getImageData() { return getChartImage(chartWidth, 200); } @Override public byte[] getImageData(int width, int height) { return getChartImage(width, height); } private byte[] getChartImage(int width, int height) { PrefsData prefsData = Locator.getFacade().getStatsManager().getPreferences(siteId, false); int _width = (width <= 0) ? 350 : width; int _height = (height <= 0) ? 200: height; return Locator.getFacade().getChartService().generateChart( chartDataProvider.getReport(), _width, _height, prefsData.isChartIn3D(), prefsData.getChartTransparency(), prefsData.isItemLabelsVisible() ); } }; chart.setAutoDetermineChartSizeByAjax("#"+chartTd.getMarkupId()); chart.setOutputMarkupId(true); chartTd.add(chart); if(!renderChart) { chartTd.setVisible(false); }else if(renderChart && !renderTable) { chartTd.add(AttributeModifier.replace("colspan", "2")); } add(chartTd); }
Example #22
Source File: AjaxLazyLoadFragment.java From sakai with Educational Community License v2.0 | 5 votes |
/** * @param markupId The components markupid. * @return The component to show while the real component is being created. */ public Component getLoadingComponent(String markupId) { Label indicator = new Label(markupId, "<img src=\"" + RequestCycle.get().urlFor(AbstractDefaultAjaxBehavior.INDICATOR, null) + "\"/>"); indicator.setEscapeModelStrings(false); indicator.add(new AttributeModifier("title", new Model("..."))); return indicator; }
Example #23
Source File: LocaleAwareHtmlTag.java From sakai with Educational Community License v2.0 | 5 votes |
public LocaleAwareHtmlTag(String id) { super(id); String language = getSession().getLocale().getLanguage(); String orientation = ProfileUtils.getUserPreferredOrientation(); add(AttributeModifier.replace("lang", language)); add(AttributeModifier.replace("xml:lang", language)); add(AttributeModifier.replace("dir", orientation)); }
Example #24
Source File: FileTreePanel.java From openmeetings with Apache License 2.0 | 5 votes |
public void setReadOnly(boolean readOnly, IPartialPageRequestHandler handler) { if (this.readOnly != readOnly) { this.readOnly = readOnly; tree.refreshRoots(!readOnly); createDir.setEnabled(!readOnly); createDir.add(AttributeModifier.replace(ATTR_CLASS, CREATE_DIR_CLASS + (readOnly ? DISABLED_CLASS : ""))); upload.setEnabled(!readOnly); upload.add(AttributeModifier.replace(ATTR_CLASS, UPLOAD_CLASS + (readOnly ? DISABLED_CLASS : ""))); trashBorder.add(AttributeModifier.replace(ATTR_CLASS, TRASH_CLASS + (readOnly ? DISABLED_CLASS : ""))); if (handler != null) { handler.add(createDir, upload, trashBorder); update(handler); } } }
Example #25
Source File: ConvertingErrorsDialog.java From openmeetings with Apache License 2.0 | 5 votes |
@Override protected void populateItem(ListItem<FileItemLog> item) { FileItemLog l = item.getModelObject(); item.add(new Label("exitCode", l.getExitCode())); item.add(new Label("message", l.getMessage())); if (!l.isOk()) { item.add(AttributeModifier.append(ATTR_CLASS, "alert")); } if (l.isWarn()) { item.add(AttributeModifier.append(ATTR_CLASS, "warn")); } }
Example #26
Source File: BasePage.java From openmeetings with Apache License 2.0 | 5 votes |
@Override protected void onInitialize() { super.onInitialize(); String appName = getApplicationName(); String code = getLanguageCode(); add(new TransparentWebMarkupContainer("html") .add(AttributeModifier.replace("xml:lang", code)) .add(AttributeModifier.replace("lang", code)) .add(AttributeModifier.replace("dir", isRtl() ? "rtl" : "ltr"))); add(new Label("pageTitle", appName)); add(header = new HeaderPanel("header", appName)); add(loader.setVisible(isMainPage()).setOutputMarkupPlaceholderTag(true).setOutputMarkupId(true)); add(new HeaderResponseContainer("customCSS", CUSTOM_CSS_FILTER)); }
Example #27
Source File: ServerWidePage.java From sakai with Educational Community License v2.0 | 5 votes |
@SuppressWarnings("serial") private void makeSelectorLink(final String id, final String view) { IndicatingAjaxLink link = new IndicatingAjaxLink(id) { @Override public void onClick(AjaxRequestTarget target) { // select view report.setSelectedView(view); // make title, description & notes visible reportTitle.add(new AttributeModifier("style", new Model("display: block"))); reportDescription.add(new AttributeModifier("style", new Model("display: block"))); reportNotes.add(new AttributeModifier("style", new Model("display: block"))); reportChart.renderImage(target, true); // toggle selectors link state for(Component lbl : labels.values()) { lbl.setVisible(false); } for(Component lnk : links) { lnk.setVisible(true); } this.setVisible(false); labels.get(this).setVisible(true); // mark component for rendering target.add(selectors); target.add(reportTitle); target.add(reportDescription); target.add(reportNotes); target.appendJavaScript("setMainFrameHeightNoScroll( window.name, 650 )"); } }; link.setVisible(true); links.add(link); selectors.add(link); makeSelectorLabel(link, id + "Lbl"); }
Example #28
Source File: CalendarDialog.java From openmeetings with Apache License 2.0 | 5 votes |
private void setGCalVisibility(boolean isGoogleCalendar) { if (isGoogleCalendar) { gcal.setModelObject(true); pass.setVisible(false); passLabel.setVisible(false); //Google Calendar ID urlLabel.setDefaultModelObject(getString("calendar.googleID")); url.setEnabled(true); //Google API Key userLabel.setDefaultModelObject(getString("calendar.googleKey")); username.setEnabled(true); } else { gcal.setModelObject(false); pass.setVisible(true); passLabel.setVisible(true); userLabel.setDefaultModelObject(getString("114")); username.setModelObject(null); urlLabel.setDefaultModelObject(getString("calendar.url")); } url.setLabel(Model.of((String)urlLabel.getDefaultModelObject())); //Add new AttributeModifier to change the type of URLTextField, to text for //Google Calendar and to URL for a normal CalDAV calendar url.add(AttributeModifier.replace("type", gcal.getModelObject() ? "text" : "url")); }
Example #29
Source File: SakaiDateTimeField.java From sakai with Educational Community License v2.0 | 5 votes |
@Override protected void onInitialize() { super.onInitialize(); setOutputMarkupId(true); dateConverter = new SakaiIsoDateConverter(getMarkupId()); add(AttributeModifier.append("class", "sakai-datetimefield")); }
Example #30
Source File: GalleryImageRenderer.java From sakai with Educational Community License v2.0 | 5 votes |
/** * Creates a new instance of <code>GalleryImageRenderer</code>. */ public GalleryImageRenderer(String id, String imageResourceId) { super(id); if (imageResourceId == null) { add(new ContextImage("img",new Model(ProfileConstants.UNAVAILABLE_IMAGE))); return; } else if (sakaiProxy.getResource(imageResourceId) == null) { // may have been deleted in CHS add(new ContextImage("img",new Model(ProfileConstants.UNAVAILABLE_IMAGE))); return; } final byte[] imageBytes = sakaiProxy.getResource(imageResourceId).getBytes(); if (imageBytes != null && imageBytes.length > 0) { BufferedDynamicImageResource imageResource = new BufferedDynamicImageResource() { private static final long serialVersionUID = 1L; @Override protected byte[] getImageData(IResource.Attributes ignored) { return imageBytes; } }; Image myPic = new Image("img", new Model(imageResource)); myPic.add(new AttributeModifier("alt", new StringResourceModel("profile.gallery.image.alt",this,null).getString())); add(myPic); } else { add(new ContextImage("img",new Model(ProfileConstants.UNAVAILABLE_IMAGE))); } }