List of usage examples for org.apache.wicket.markup.html.basic Label setOutputMarkupPlaceholderTag
public final Component setOutputMarkupPlaceholderTag(final boolean outputTag)
From source file:au.org.theark.lims.web.component.button.PrinterListPanel.java
License:Open Source License
private void initPanel() { DropDownChoice<String> printerListDdc = new DropDownChoice<String>("printerList", new PropertyModel<String>(this, "selected"), PRINTERLIST); printerListDdc.add(new AttributeModifier("name", "printerList")); printerListDdc.add(new AttributeModifier("onchange", "changeHiddenInput(this)")); printerListDdc.setOutputMarkupPlaceholderTag(true); this.add(printerListDdc); selectedPrinter = new HiddenField<String>("selectedPrinter", new PropertyModel<String>(this, "selected")); selectedPrinter.setOutputMarkupPlaceholderTag(true); selectedPrinter.add(new AttributeModifier("name", "selectedPrinter")); selectedPrinter.add(new AbstractDefaultAjaxBehavior() { private static final long serialVersionUID = 1L; @Override/*w ww . jav a 2s . c o m*/ protected void respond(AjaxRequestTarget arg0) { StringValue selectedPrinter = RequestCycle.get().getRequest().getQueryParameters() .getParameterValue("selectedPrinter"); selected = selectedPrinter.toString(); } }); this.add(selectedPrinter); StringBuilder javaScript = new StringBuilder(); javaScript.append("function findPrinters() {"); javaScript.append("\n"); javaScript.append(" var applet = document.jZebra;"); javaScript.append("\n"); javaScript.append(" if (applet != null) {"); javaScript.append("\n"); javaScript.append(" document.getElementById('"); javaScript.append(printerListDdc.getMarkupId()); javaScript.append("').disabled = false;"); javaScript.append("\n"); javaScript.append(" var listing = applet.getPrinters();"); javaScript.append("\n"); javaScript.append(" var printers = listing.split(',');\n"); javaScript.append(" var objHidden = document.getElementById('"); javaScript.append(selectedPrinter.getMarkupId()); javaScript.append("');\n"); javaScript.append("\n"); javaScript.append(" for ( var i in printers) {"); javaScript.append("\n"); javaScript.append(" if(objHidden.value == printers[i]) {\n"); javaScript.append(" document.getElementById('"); javaScript.append(printerListDdc.getMarkupId()); javaScript.append("').options[i] = new Option(printers[i], printers[i], true, true);\n"); javaScript.append(" } else {\n"); javaScript.append(" document.getElementById('"); javaScript.append(printerListDdc.getMarkupId()); javaScript.append("').options[i] = new Option(printers[i], printers[i], false, false);\n"); javaScript.append(" }\n"); javaScript.append(" }"); javaScript.append("\n"); javaScript.append(" } else {"); javaScript.append("\n"); javaScript.append(" document.getElementById('"); javaScript.append(printerListDdc.getMarkupId()); javaScript.append("').options[i] = new Option('N/A');"); javaScript.append("\n"); javaScript.append(" document.getElementById('"); javaScript.append(printerListDdc.getMarkupId()); javaScript.append("').disabled = true;"); javaScript.append("\n"); javaScript.append(" }"); javaScript.append("\n"); javaScript.append("}"); javaScript.append("\n"); javaScript.append("\n"); javaScript.append("function changeHiddenInput (objDropDown) {"); javaScript.append("\n"); javaScript.append(" var objHidden = document.getElementById('"); javaScript.append(selectedPrinter.getMarkupId()); javaScript.append("');\n"); javaScript.append(" objHidden.value = objDropDown.value;"); javaScript.append("\n"); javaScript.append(" callWicket(objDropDown.value);"); javaScript.append("}"); final Label script = new Label("script", javaScript.toString()); script.setOutputMarkupPlaceholderTag(true); script.add(new AttributeModifier("onload", "findPrinters()")); script.setEscapeModelStrings(false); // do not HTML escape JavaScript code this.add(script); }
From source file:com.evolveum.midpoint.gui.impl.component.form.TriStateFormGroup.java
License:Apache License
private void initLayout(IModel<String> label, final String tooltipKey, boolean isTooltipInModal, String labelCssClass, String textCssClass, boolean required, boolean isSimilarAsPropertyPanel) { WebMarkupContainer labelContainer = new WebMarkupContainer(ID_LABEL_CONTAINER); add(labelContainer);// w ww .j a v a 2 s. c o m Label l = new Label(ID_LABEL, label); if (StringUtils.isNotEmpty(labelCssClass)) { labelContainer.add(AttributeAppender.prepend("class", labelCssClass)); } if (isSimilarAsPropertyPanel) { labelContainer.add(AttributeAppender.prepend("class", " col-xs-2 prism-property-label ")); } else { labelContainer.add(AttributeAppender.prepend("class", " control-label ")); } labelContainer.add(l); Label tooltipLabel = new Label(ID_TOOLTIP, new Model<>()); tooltipLabel.add(new AttributeAppender("data-original-title", new IModel<String>() { @Override public String getObject() { return getString(tooltipKey); } })); tooltipLabel.add(new InfoTooltipBehavior(isTooltipInModal)); tooltipLabel.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return tooltipKey != null; } }); tooltipLabel.setOutputMarkupId(true); tooltipLabel.setOutputMarkupPlaceholderTag(true); labelContainer.add(tooltipLabel); WebMarkupContainer requiredContainer = new WebMarkupContainer(ID_REQUIRED); requiredContainer.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return required; } }); labelContainer.add(requiredContainer); WebMarkupContainer propertyLabel = new WebMarkupContainer(ID_PROPERTY_LABEL); WebMarkupContainer rowLabel = new WebMarkupContainer(ID_ROW); WebMarkupContainer valueWrapper = new WebMarkupContainer(ID_VALUE_WRAPPER); if (StringUtils.isNotEmpty(textCssClass)) { valueWrapper.add(AttributeAppender.prepend("class", textCssClass)); } if (isSimilarAsPropertyPanel) { propertyLabel.add(AttributeAppender.prepend("class", " col-md-10 prism-property-value ")); rowLabel.add(AttributeAppender.prepend("class", " row ")); } propertyLabel.add(rowLabel); rowLabel.add(valueWrapper); add(propertyLabel); TriStateComboPanel triStateCombo = new TriStateComboPanel(ID_VALUE, getModel()); ; valueWrapper.add(triStateCombo); FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(triStateCombo.getBaseFormComponent())); feedback.setOutputMarkupId(true); valueWrapper.add(feedback); }
From source file:com.evolveum.midpoint.web.component.form.AceEditorFormGroup.java
License:Apache License
private void initLayout(IModel<String> label, final String tooltipKey, boolean isTooltipInModal, String labelSize, String textSize, boolean required, int rowNumber) { WebMarkupContainer labelContainer = new WebMarkupContainer(ID_LABEL_CONTAINER); add(labelContainer);//from w w w . ja va 2 s . c o m Label l = new Label(ID_LABEL, label); if (StringUtils.isNotEmpty(labelSize)) { labelContainer.add(AttributeAppender.prepend("class", labelSize)); } labelContainer.add(l); Label tooltipLabel = new Label(ID_TOOLTIP, new Model<>()); tooltipLabel.add(new AttributeAppender("data-original-title", new AbstractReadOnlyModel<String>() { @Override public String getObject() { return getString(tooltipKey); } })); tooltipLabel.add(new InfoTooltipBehavior(isTooltipInModal)); tooltipLabel.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return tooltipKey != null; } }); tooltipLabel.setOutputMarkupId(true); tooltipLabel.setOutputMarkupPlaceholderTag(true); labelContainer.add(tooltipLabel); WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER); if (StringUtils.isNotEmpty(textSize)) { textWrapper.add(AttributeAppender.prepend("class", textSize)); } add(textWrapper); AceEditor text = new AceEditor(ID_TEXT, getModel()); text.add(new AttributeModifier("rows", rowNumber)); text.setOutputMarkupId(true); text.setRequired(required); text.setLabel(label); text.add(AttributeAppender.replace("placeholder", label)); textWrapper.add(text); }
From source file:com.evolveum.midpoint.web.component.input.QNameEditorPanel.java
License:Apache License
protected void initLayout(String localPartLabelKey, String localPartTooltipKey, String namespaceLabelKey, String namespaceTooltipKey) { Label localPartLabel = new Label(ID_LOCAL_PART_LABEL, getString(localPartLabelKey)); localPartLabel.setOutputMarkupId(true); localPartLabel.setOutputMarkupPlaceholderTag(true); add(localPartLabel);//from www . ja v a 2 s. co m Label namespaceLabel = new Label(ID_NAMESPACE_LABEL, getString(namespaceLabelKey)); namespaceLabel.setOutputMarkupId(true); namespaceLabel.setOutputMarkupPlaceholderTag(true); add(namespaceLabel); TextField localPart = new TextField<>(ID_LOCAL_PART, new PropertyModel<String>(getModel(), "itemPath")); localPart.setOutputMarkupId(true); localPart.setOutputMarkupPlaceholderTag(true); localPart.setRequired(isLocalPartRequired()); add(localPart); DropDownChoice namespace = new DropDownChoice<>(ID_NAMESPACE, new PropertyModel<String>(this, "namespace"), prepareNamespaceList()); namespace.setOutputMarkupId(true); namespace.setOutputMarkupPlaceholderTag(true); namespace.setNullValid(false); namespace.setRequired(true); add(namespace); Label localPartTooltip = new Label(ID_T_LOCAL_PART); localPartTooltip.add(new AttributeAppender("data-original-title", getString(localPartTooltipKey))); localPartTooltip.add(new InfoTooltipBehavior()); localPartTooltip.setOutputMarkupPlaceholderTag(true); add(localPartTooltip); Label namespaceTooltip = new Label(ID_T_NAMESPACE); namespaceTooltip.add(new AttributeAppender("data-original-title", getString(namespaceTooltipKey))); namespaceTooltip.add(new InfoTooltipBehavior()); namespaceTooltip.setOutputMarkupPlaceholderTag(true); add(namespaceTooltip); }
From source file:com.hubeleon.wicketlist.HomePage.java
License:Open Source License
public HomePage() { final WebMarkupContainer divList = new WebMarkupContainer("ochConfirmCDRsTable"); divList.setOutputMarkupId(true);// w w w . j a v a 2 s . c o m divList.setOutputMarkupPlaceholderTag(true); setVersioned(false); final List<CDRInfo> cdrInfoArray = new ArrayList(); if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Development) { try (Closeable closeable = ObjectifyService.begin()) { System.out.println(" ####### get all cdr list"); List<CDRInfo> ths = ofy().load().type(CDRInfo.class).list(); cdrInfoArray.addAll(ths); } } final ListView list = new ListView<CDRInfo>("listview", cdrInfoArray) { protected void populateItem(final ListItem<CDRInfo> listItem) { final CDRInfo cdr = (CDRInfo) listItem.getModelObject(); System.out.println("Populating List for " + cdr.getCdrId() + " with status " + cdr.getCdrStatusType() + " retrieved from database "); listItem.setOutputMarkupId(true); listItem.setOutputMarkupPlaceholderTag(true); listItem.add(new Label("cdr", (cdr.getCdrId() != null ? cdr.getCdrId() : ""))); listItem.add(new Label("evseId", (cdr.getEvseId() != null ? cdr.getEvseId() : ""))); final Label lblStatus = new Label("status", new PropertyModel<String>(cdr, "cdrStatusType")); lblStatus.setOutputMarkupId(true); lblStatus.setOutputMarkupPlaceholderTag(true); listItem.add(lblStatus); listItem.add(new Label("startDateTime", (cdr.getStartDateTime().toString() != null ? cdr.getStartDateTime().toString() : ""))); listItem.add(new Label("endDateTime", (cdr.getEndDateTime().toString() != null ? cdr.getEndDateTime().toString() : ""))); listItem.add(new Label("duration", (cdr.getDuration() != null ? cdr.getDuration() : ""))); listItem.add(new Label("instance", cdr.getInstance() != null ? cdr.getInstance() : "")); listItem.add(new Label("tokenType", cdr.getTokenType() != null ? cdr.getTokenType() : "")); listItem.add(new Label("tokenSubType", cdr.getTokenSubType() != null ? cdr.getTokenSubType() : "")); listItem.add(new Label("contractId", cdr.getContractId() != null ? cdr.getContractId() : "")); listItem.add(new Label("liveAuthId", cdr.getLiveAuthId() != null ? cdr.getLiveAuthId() : "")); final Form<CDRInfo> form = new Form<CDRInfo>("myForm", new Model(cdr)) { /** * */ private static final long serialVersionUID = 1L; protected void onSubmit(AjaxRequestTarget target, Form<CDRInfo> form) { CDRInfo c = (CDRInfo) this.getModelObject(); System.err.println("######## STATUS:" + c.getCdrStatusType()); //this.setResponsePage(new MovieDisplayPage(movie)); }; }; form.setOutputMarkupId(true); form.setOutputMarkupPlaceholderTag(true); final HiddenField currentState = new HiddenField("currentState", new PropertyModel<String>(cdr, "cdrStatusType")); currentState.setOutputMarkupId(true); form.add(currentState); final HiddenField hcdr = new HiddenField("cdrId", new PropertyModel<String>(cdr, "cdrId")); hcdr.setOutputMarkupId(true); form.add(hcdr); final Model<String> btnStyle = new Model<String>("btn-warning"); AjaxButton btn = new AjaxButton("stateAcceptButton", new PropertyModel<String>(cdr, "cdrStatusType"), form) { protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setWicketAjaxResponse(false); } protected void onClick(AjaxRequestTarget target, Form form) { } protected void onSubmit(AjaxRequestTarget target, Form form) { System.out.println(" ####### " + hcdr.getDefaultModelObjectAsString() + " - " + currentState.getDefaultModelObjectAsString()); if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Development) { try (Closeable closeable = ObjectifyService.begin()) { CDRInfo result = (CDRInfo) ofy().load().type(CDRInfo.class) .id(hcdr.getDefaultModelObjectAsString()).now(); result.setCdrStatusType("Accepted"); System.out.println("Persisting to database " + result.getCdrId() + " - " + result.getCdrStatusType() + " ::: " + target.getLastFocusedElementId()); ofy().save().entity(result).now(); setReuseItems(true); addStateChange(); modelChanging(); // Remove item and invalidate listView List<CDRInfo> currentList = (List<CDRInfo>) getList(); for (CDRInfo i : currentList) { if (i.getCdrId().equalsIgnoreCase(result.getCdrId())) { System.out.println("#### Found entry and updating state to : " + result.getCdrStatusType()); currentList.remove(i); i.setCdrStatusType(result.getCdrStatusType()); System.out.println("#### set list " + currentList); setList(currentList); target.appendJavaScript(" document.getElementById('" + lblStatus.getId() + "').value='" + result.getCdrStatusType() + "';"); System.out.println("#### model changed "); modelChanged(); System.out.println("#### remove all "); removeAll(); break; } else { System.out.println("#### NOT FOUND as charge record " + i.getCdrId() + ", while we are looking for " + result.getCdrId()); } } } } target.add(lblStatus); setResponsePage(HomePage.class); } }; btn.add(AttributeModifier.append("class", btnStyle)); btn.add(new AttributeModifier("cdrStatusType", cdr) { protected String newValue(final String currentValue, final String replacementValue) { System.out .println("######## New Value 1:" + replacementValue + " old value " + currentValue); return currentValue + replacementValue; } }); form.add(btn); AjaxButton btnReject = new AjaxButton("stateRejectButton", new PropertyModel<String>(cdr, "cdrStatusType"), form) { protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setWicketAjaxResponse(false); System.out.println("########updateAjaxAttributes"); } protected void onSubmit(AjaxRequestTarget target, Form form) { System.out.println(" ####### " + hcdr.getDefaultModelObjectAsString() + " - " + currentState.getDefaultModelObjectAsString()); if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Development) { try (Closeable closeable = ObjectifyService.begin()) { CDRInfo result = (CDRInfo) ofy().load().type(CDRInfo.class) .id(hcdr.getDefaultModelObjectAsString()).now(); result.setCdrStatusType("Rejected"); System.out.println("Persisting to database " + result.getCdrId() + " - " + result.getCdrStatusType() + " ::: " + target.getLastFocusedElementId()); ofy().save().entity(result).now(); getList().remove(result); } } target.add(divList); } }; btnReject.add(AttributeModifier.append("class", btnStyle)); btnReject.add(new AttributeModifier("cdrStatusType", cdr) { protected String newValue(final String currentValue, final String replacementValue) { System.out.println("######## New Value Reject Button:" + replacementValue + " old value " + currentValue); return currentValue + replacementValue; } }); form.add(btnReject); listItem.add(form); } }; list.setOutputMarkupId(true); list.setOutputMarkupPlaceholderTag(true); divList.setOutputMarkupId(true); divList.setOutputMarkupPlaceholderTag(true); divList.add(list); add(divList); }
From source file:com.tysanclan.site.projectewok.components.CalendarPanelNavigator.java
License:Open Source License
public Label createMonthLabel(Date date) { SimpleDateFormat format = new SimpleDateFormat("MMMM yyyy", Locale.US); format.setTimeZone(DateUtil.NEW_YORK); Label label = new Label("month", format.format(date)); label.setOutputMarkupId(true);// ww w . ja v a 2 s .co m label.setOutputMarkupPlaceholderTag(true); return label; }
From source file:com.tysanclan.site.projectewok.components.ProfilePanel.java
License:Open Source License
/** * // w w w .j ava 2 s .c o m */ public ProfilePanel(String id, User user) { super(id); PageParameters params = new PageParameters(); params.add("userid", user.getId().toString()); add(new BookmarkablePageLink<User>("profilelink", MemberPage.class, params)); Form<User> profileForm = new Form<User>("profile", ModelMaker.wrap(user)) { /** * */ private static final long serialVersionUID = 1L; @SpringBean private ProfileService profileService; /** * @see org.apache.wicket.markup.html.form.Form#onSubmit() */ @SuppressWarnings("unchecked") @Override protected void onSubmit() { User u = getModelObject(); Profile profile = u.getProfile(); TextField<String> realnameField = (TextField<String>) get("realname"); TextField<String> photoURLField = (TextField<String>) get("photoURL"); TextField<String> skypeField = (TextField<String>) get("skypename"); TextField<String> twitterField = (TextField<String>) get("twitter"); CheckBox photoPublicCheckbox = (CheckBox) get("public"); CheckBox skypePublicBox = (CheckBox) get("skypepublic"); TextArea<String> publicdescField = (TextArea<String>) get("publicdesc"); TextArea<String> privatedescField = (TextArea<String>) get("privatedesc"); String realname = realnameField.getModelObject(); Date birthDate = getSelectedDate(); String photoURL = photoURLField.getModelObject(); Boolean photoPublic = photoPublicCheckbox.getModelObject(); Boolean skypePublic = skypePublicBox.getModelObject(); String publicdesc = publicdescField.getModelObject(); String privatedesc = privatedescField.getModelObject(); String aimName = skypeField.getModelObject(); String twitter = twitterField.getModelObject(); if (profile == null) { profile = profileService.createProfile(u); } if (!isBothNullOrEquals(realname, profile.getRealName())) { profileService.setRealname(profile, realname); } if (!isBothNullOrEquals(birthDate, profile.getBirthDate())) { profileService.setBirthDate(profile, birthDate); } if (!isBothNullOrEquals(twitter, profile.getTwitterUID())) { profileService.setTwitterUID(profile, twitter); } if (!isBothNullOrEquals(aimName, profile.getInstantMessengerAddress()) || !isBothNullOrEquals(skypePublic, profile.isInstantMessengerPublic())) { profileService.setAIMAddress(profile, aimName, skypePublic); } if (!isBothNullOrEquals(photoURL, profile.getPhotoURL()) || !isBothNullOrEquals(photoPublic, profile.isPhotoPublic())) { profileService.setPhotoURL(profile, photoURL, photoPublic); } if (!isBothNullOrEquals(publicdesc, profile.getPublicDescription())) { profileService.setPublicDescription(profile, publicdesc); } if (!isBothNullOrEquals(privatedesc, profile.getPrivateDescription())) { profileService.setPrivateDescription(profile, privatedesc); } ProfilePanel.this.onUpdated(); } public <T> boolean isBothNullOrEquals(T value1, T value2) { if (value1 == null && value2 == null) { return true; } if (value1 == null) return false; if (value2 == null) return false; return value1.equals(value2); } }; Profile profile = user.getProfile(); profileForm.add( new TextField<String>("realname", new Model<String>(profile != null ? profile.getRealName() : ""))); Calendar cal = DateUtil.getCalendarInstance(); cal.add(Calendar.YEAR, -13); int year = cal.get(Calendar.YEAR); if (profile != null) { setSelectedDate(profile.getBirthDate()); } profileForm.add(new InlineDatePicker("birthdate", profile != null ? profile.getBirthDate() : null) { private static final long serialVersionUID = 1L; @Override protected void onDateSelected(Date date, AjaxRequestTarget target) { Label oldAge = getAge(); Label newAge = new Label("age", getAgeModel(date)); newAge.setOutputMarkupId(true); newAge.setOutputMarkupPlaceholderTag(true); oldAge.replaceWith(newAge); setAge(newAge); setSelectedDate(date); if (target != null) { target.add(newAge); } } }.setChangeMonth(true).setChangeYear(true).setYearRange("'1900:" + year + "'")); profileForm.add(new TextField<String>("twitter", new Model<String>(profile != null ? profile.getTwitterUID() : ""))); TextField<String> photoURLField = new TextField<String>("photoURL", new Model<String>(profile != null ? profile.getPhotoURL() : "")); photoURLField.setOutputMarkupId(true); photoURLField.setOutputMarkupPlaceholderTag(true); photoURLField.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = 1L; /** * @see org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior#onUpdate(org.apache.wicket.ajax.AjaxRequestTarget) */ @SuppressWarnings("unchecked") @Override protected void onUpdate(AjaxRequestTarget target) { TextField<String> urlComponent = (TextField<String>) getComponent(); String newURL = urlComponent.getModelObject(); WebMarkupContainer container = getImage(); if (newURL == null || newURL.isEmpty()) { container.setVisible(false); } else { container.add(AttributeModifier.replace("src", newURL)); container.setVisible(true); } if (target != null) { target.add(getImage()); } } }); String currentPhotoURL = profile != null ? profile.getPhotoURL() : null; image = new WebMarkupContainer("preview"); if (currentPhotoURL == null || currentPhotoURL.isEmpty()) { image.setVisible(false); } else { image.add(AttributeModifier.replace("src", currentPhotoURL)); } image.setOutputMarkupId(true); image.setOutputMarkupPlaceholderTag(true); age = new Label("age", getAgeModel(profile)); age.setOutputMarkupId(true); age.setOutputMarkupPlaceholderTag(true); profileForm.add(age); profileForm.add(image); profileForm .add(new CheckBox("public", new Model<Boolean>(profile != null ? profile.isPhotoPublic() : false))); profileForm.add(new ContextImage("skypeicon", "images/skype-icon.gif")); profileForm.add(new CheckBox("skypepublic", new Model<Boolean>(profile != null ? profile.isInstantMessengerPublic() : false))); profileForm.add(new TextField<String>("skypename", new Model<String>(profile != null ? profile.getInstantMessengerAddress() : ""))); profileForm.add(new BBCodeTextArea("publicdesc", profile != null ? profile.getPublicDescription() : "")); profileForm.add(new BBCodeTextArea("privatedesc", profile != null ? profile.getPrivateDescription() : "")); profileForm.add(photoURLField); add(profileForm); }
From source file:de.tudarmstadt.ukp.csniper.webapp.support.wicket.ExpandableList.java
License:Apache License
private void initialize() { expandableList = new RepeatingView("expandableList"); AbstractItem item;//from w ww . jav a2s . c om for (Entry<String, String> entry : items.entrySet()) { item = new AbstractItem(expandableList.newChildId()); final Label body = new Label("body", entry.getValue()); body.setOutputMarkupPlaceholderTag(true).setVisible(false).setEscapeModelStrings(false); item.add(body); item.add(new AjaxLink<String>("caption", new Model<String>(entry.getKey())) { private static final long serialVersionUID = 1L; @Override public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) { replaceComponentTagBody(markupStream, openTag, getModelObject()); } @Override public void onClick(AjaxRequestTarget aTarget) { body.setVisible(!body.isVisible()); aTarget.add(body); } }.add(new AttributeModifier("class", new Model<String>("clickableElement")))); expandableList.add(item); } add(expandableList); }
From source file:io.ucoin.ucoinj.web.pages.home.HomePage.java
License:Open Source License
public HomePage(final PageParameters parameters) { super(parameters); setUseGlobalFeedback(false);/*from ww w . j ava 2 s .c o m*/ form = new Form<HomePage>("searchForm"); form.setOutputMarkupId(true); add(form); // FeedbackPanel final FeedbackPanel feedback = new JQueryFeedbackPanel("feedback"); feedback.setOutputMarkupId(true); form.add(feedback); IAutoCompleteRenderer autoCompleteRenderer = new IAutoCompleteRenderer<String>() { private static final long serialVersionUID = 1L; public void renderHeader(Response response) { response.write("<ul>"); } public void render(String choice, Response response, String criteria) { response.write("<li textvalue=\"" + choice + "\""); response.write(">"); // Put the substring after the criteria in bold if (choice.startsWith(criteria) && choice.length() > criteria.length()) { choice = criteria + "<b>" + choice.substring(criteria.length()) + "</b>"; } response.write(choice); response.write("</li>"); } public void renderFooter(Response response, int count) { response.write("</ul>"); } }; // Search text searchTextField = new AutoCompleteTextField<String>("searchText", new PropertyModel<String>(this, "searchQuery"), autoCompleteRenderer) { private static final long serialVersionUID = 1L; @Override protected Iterator<String> getChoices(String input) { return doSuggestions(input).iterator(); } }; searchTextField.add(new AjaxFormComponentUpdatingBehavior("keyup") { @Override protected void onUpdate(AjaxRequestTarget target) { // do search searchTextField.updateModel(); } @Override protected void onError(AjaxRequestTarget target, RuntimeException e) { // Here the Component's model object will remain unchanged, // so that it doesn't hold invalid input } }); searchTextField.setRequired(true); form.add(searchTextField); // Submit button { Button searchButton = new AjaxButton("searchButton") { @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { // do search doSearch(target, searchQuery); // Force to hide autocomplete choices target.appendJavaScript("$('div.wicket-aa-container').hide();" + "$('#" + searchTextField.getMarkupId() + "').attr('autocomplete', 'off');"); } }; searchButton.setDefaultFormProcessing(false); searchButton.setOutputMarkupId(true); form.add(searchButton); form.setDefaultButton(searchButton); } //form.add(new AjaxFormValidatingBehavior("keyup", Duration.ONE_SECOND)); // Search result { // Parent container resultParent = new WebMarkupContainer("resultParent"); resultParent.setOutputMarkupId(true); resultParent.setOutputMarkupPlaceholderTag(true); resultParent.setVisible(false); add(resultParent); // History items { resultListView = new ListView<SearchResult>("resultItems", new ListModel<SearchResult>()) { protected void populateItem(ListItem<SearchResult> item) { SearchResult result = item.getModelObject(); // link PageParameters pageParameters = new PageParameters(); pageParameters.add(CurrencyPage.CURRENCY_PARAMETER, result.getId()); BookmarkablePageLink link = new BookmarkablePageLink("openCurrencyLink", CurrencyPage.class, pageParameters); item.add(link); // Currency name Label label = new Label("currencyName", result.getValue()); label.setEscapeModelStrings(false); label.setOutputMarkupPlaceholderTag(false); link.add(label); } }; resultListView.setReuseItems(true); resultListView.setOutputMarkupId(true); resultParent.add(resultListView); } } }
From source file:it.av.eatt.web.page.FriendsPage.java
License:Apache License
/** * Constructor that is invoked when page is invoked without a session. * //from ww w . j a va 2s . c o m * @throws JackWicketException */ public FriendsPage() throws JackWicketException { super(); allRelations = userRelationService.getAllRelations(getLoggedInUser()); final Label noYetFriends = new Label("noYetFriends", getString("noYetFriends")) { @Override protected void onBeforeRender() { super.onBeforeRender(); setVisible(allRelations.size() == 0); } }; noYetFriends.setOutputMarkupId(true); noYetFriends.setOutputMarkupPlaceholderTag(true); add(noYetFriends); final WebMarkupContainer friendsListContainer = new WebMarkupContainer("friendsListContainer"); friendsListContainer.setOutputMarkupId(true); add(friendsListContainer); friendsList = new PropertyListView<EaterRelation>("friendsList", allRelations) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<EaterRelation> item) { boolean isPendingFriendRequest = item.getModelObject().getStatus() .equals(EaterRelation.STATUS_PENDING) && item.getModelObject().getToUser().equals(getLoggedInUser()); item.add(new Label(EaterRelation.TO_USER + ".firstname")); item.add(new Label(EaterRelation.TO_USER + ".lastname")); item.add(new Label(EaterRelation.TYPE)); item.add(new Label(EaterRelation.STATUS)); // item.add(new Label(EaterRelation.TO_USER + ".userRelation")); item.add(new AjaxLink<EaterRelation>("remove", new Model<EaterRelation>(item.getModelObject())) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { try { ((FriendsPage) getPage()).userRelationService.remove(getModelObject()); allRelations = userRelationService.getAllRelations(getLoggedInUser()); ((FriendsPage) target.getPage()).friendsList.setModelObject(allRelations); noYetFriends.setVisible(allRelations.size() == 0); target.addComponent((noYetFriends)); target.addComponent((friendsListContainer)); // info(new StringResourceModel("info.userRelationRemoved", this, null).getString()); } catch (JackWicketException e) { error(new StringResourceModel("genericErrorMessage", this, null).getString()); } target.addComponent(((FriendsPage) target.getPage()).getFeedbackPanel()); } }); item.add(new AjaxLink<EaterRelation>("acceptFriend", new Model<EaterRelation>(item.getModelObject())) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { try { ((FriendsPage) getPage()).userRelationService .performFriendRequestConfirm(getModelObject()); allRelations = userRelationService.getAllRelations(getLoggedInUser()); ((FriendsPage) target.getPage()).friendsList.setModelObject(allRelations); noYetFriends.setVisible(allRelations.size() == 0); target.addComponent((noYetFriends)); target.addComponent((friendsListContainer)); // info(new StringResourceModel("info.userRelationRemoved", this, null).getString()); } catch (JackWicketException e) { error(new StringResourceModel("genericErrorMessage", this, null).getString()); } target.addComponent(((FriendsPage) target.getPage()).getFeedbackPanel()); } }.setVisible(isPendingFriendRequest)); item.add(new AjaxLink<EaterRelation>("ignoreFriendRequest", new Model<EaterRelation>(item.getModelObject())) { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { try { ((FriendsPage) getPage()).userRelationService .performFriendRequestIgnore(getModelObject()); allRelations = userRelationService.getAllRelations(getLoggedInUser()); ((FriendsPage) target.getPage()).friendsList.setModelObject(allRelations); noYetFriends.setVisible(allRelations.size() == 0); target.addComponent((noYetFriends)); target.addComponent((friendsListContainer)); // info(new StringResourceModel("info.userRelationRemoved", this, null).getString()); } catch (JackWicketException e) { error(new StringResourceModel("genericErrorMessage", this, null).getString()); } target.addComponent(((FriendsPage) target.getPage()).getFeedbackPanel()); } }.setVisible(isPendingFriendRequest)); } }; friendsListContainer.add(friendsList); }