List of usage examples for org.apache.wicket.util.string AppendingStringBuffer AppendingStringBuffer
public AppendingStringBuffer()
From source file:au.org.theark.core.web.component.wizard.AjaxWizardButtonBar.java
License:Open Source License
private void addAjax(final WizardButton button) { button.add(new AjaxFormSubmitBehavior("onclick") { private static final long serialVersionUID = 1L; @Override// w ww . ja v a2 s . c om protected CharSequence getEventHandler() { AppendingStringBuffer handler = new AppendingStringBuffer(); handler.append(super.getEventHandler()); handler.append("; return false;"); return handler; } @Override protected IAjaxCallDecorator getAjaxCallDecorator() { return AjaxWizardButtonBar.this.getAjaxCallDecorator(); } @Override protected void onSubmit(AjaxRequestTarget target) { target.add(wizard); } @Override protected void onError(AjaxRequestTarget target) { target.add(wizard); } }); add(button); }
From source file:au.org.theark.core.web.component.wizard.AjaxWizardButtonBar.java
License:Open Source License
private void addAjaxCancel(final WizardButton button) { button.add(new AjaxFormSubmitBehavior("onclick") { private static final long serialVersionUID = 1L; @Override/*from www . j a v a2s . c o m*/ protected CharSequence getEventHandler() { AppendingStringBuffer handler = new AppendingStringBuffer(); handler.append(super.getEventHandler()); handler.append("; return false;"); return handler; } @Override protected IAjaxCallDecorator getAjaxCallDecorator() { return AjaxWizardButtonBar.this.getAjaxCallDecorator(); } @Override protected void onSubmit(AjaxRequestTarget target) { wizard.getWizardModel().cancel(); wizard = new ArkCommonWizard(wizard.getId(), wizard.getWizardSteps(), wizard.getResultListContainer(), wizard.getWizardPanelContainer(), wizard.getWizardPanelFormContainer(), wizard.getSearchPanelContainer(), wizard.getTarget()); wizard.getSearchPanelContainer().setVisible(true); wizard.getResultListContainer().setVisible(true); wizard.getWizardPanelContainer().setVisible(true); cancelWizard(target); target.add(wizard.getSearchPanelContainer()); target.add(wizard.getResultListContainer()); target.add(wizard.getWizardPanelContainer()); target.add(wizard); } @Override protected void onError(AjaxRequestTarget target) { target.add(wizard); } }); add(button); }
From source file:au.org.theark.core.web.component.wizard.AjaxWizardButtonBar.java
License:Open Source License
private void addAjaxFinish(final WizardButton button) { button.add(new AjaxFormSubmitBehavior("onclick") { private static final long serialVersionUID = 1L; @Override/* www . j av a2s. co m*/ protected CharSequence getEventHandler() { AppendingStringBuffer handler = new AppendingStringBuffer(); handler.append(super.getEventHandler()); handler.append("; return false;"); return handler; } @Override protected IAjaxCallDecorator getAjaxCallDecorator() { return AjaxWizardButtonBar.this.getAjaxCallDecorator(); } @Override protected void onSubmit(AjaxRequestTarget target) { wizard.getSearchPanelContainer().setVisible(true); wizard.getResultListContainer().setVisible(true); wizard.getWizardPanelContainer().setVisible(true); wizard.getWizardModel().finish(); target.add(wizard.getSearchPanelContainer()); target.add(wizard.getResultListContainer()); target.add(wizard.getWizardPanelContainer()); target.add(wizard); } @Override protected void onError(AjaxRequestTarget target) { target.add(wizard); } }); add(button); }
From source file:com.doculibre.constellio.wicket.components.modal.NonAjaxModalWindow.java
License:Apache License
/** * Returns the javascript used to open the window. * //w w w . j a v a2 s.c o m * @return javascript that opens the window */ private String getWindowOpenJavascript() { AppendingStringBuffer buffer = new AppendingStringBuffer(); if (isCustomComponent() == true) { buffer.append("var element = document.getElementById(\"" + getContentMarkupId() + "\");\n"); } buffer.append("var settings = new Object();\n"); buffer.append("settings.minWidth=" + getMinimalWidth() + ";\n"); buffer.append("settings.minHeight=" + getMinimalHeight() + ";\n"); buffer.append("settings.className=\"" + getCssClassName() + "\";\n"); buffer.append("settings.width=\"" + getInitialWidth() + "\";\n"); if (isUseInitialHeight() == true || isCustomComponent() == false) buffer.append("settings.height=\"" + getInitialHeight() + "\";\n"); else buffer.append("settings.height=null;\n"); buffer.append("settings.resizable=" + Boolean.toString(isResizable()) + ";\n"); if (isResizable() == false) { buffer.append("settings.widthUnit=\"" + getWidthUnit() + "\";\n"); buffer.append("settings.heightUnit=\"" + getHeightUnit() + "\";\n"); } if (isCustomComponent() == false) { Page page = createPage(); if (page == null) { throw new WicketRuntimeException("Error creating page for modal dialog."); } RequestCycle.get().setUrlForNewWindowEncoding(); buffer.append("settings.src=\"" + RequestCycle.get().urlFor(page) + "\";\n"); if (getPageMapName() != null) { buffer.append("settings.iframeName=\"" + getPageMapName() + "\";\n"); } } else { buffer.append("settings.element = element;\n"); } if (getCookieName() != null) { buffer.append("settings.cookieId=\"" + getCookieName() + "\";\n"); } Object title = getTitle() != null ? getTitle().getObject() : null; if (title != null) { buffer.append("settings.title=\"" + escapeQuotes(title.toString()) + "\";\n"); } if (getMaskType() == MaskType.TRANSPARENT) { buffer.append("settings.mask=\"transparent\";\n"); } else if (getMaskType() == MaskType.SEMI_TRANSPARENT) { buffer.append("settings.mask=\"semi-transparent\";\n"); } // set true if we set a windowclosedcallback boolean haveCloseCallback = false; // in case user is interested in window close callback or we have a // pagemap to clean // attach notification request if ((isCustomComponent() == false && deletePageMap) || windowClosedCallback != null) { WindowClosedBehavior behavior = (WindowClosedBehavior) getBehaviors(WindowClosedBehavior.class).get(0); buffer.append("settings.onClose = function() { " + /*behavior.getCallbackScript() +*/ " };\n"); haveCloseCallback = true; } // in case we didn't set windowclosecallback, we need at least callback // on close button, // to close window property (thus cleaning the shown flag) if (closeButtonCallback != null || haveCloseCallback == false) { CloseButtonBehavior behavior = (CloseButtonBehavior) getBehaviors(CloseButtonBehavior.class).get(0); buffer.append("settings.onCloseButton = function() { " + /*behavior.getCallbackScript() +*/ "};\n"); } postProcessSettings(buffer); buffer.append("Wicket.Window.create(settings).show();\n"); return buffer.toString(); }
From source file:com.googlecode.wicketwebbeans.datepicker.DatePicker.java
License:Apache License
/** * Gets the initilization javascript./*from www. j av a 2 s. c o m*/ * * @return the initilization javascript */ private CharSequence getInitScript() { Map<String, String> additionalSettings = new HashMap<String, String>(); appendSettings(additionalSettings); AppendingStringBuffer b = new AppendingStringBuffer(); if (defaultDate != null) { Calendar calendar = Calendar.getInstance(); calendar.setTime(defaultDate); b.append("\nvar defaultDate = new Date();"); b.append("\ndefaultDate.setFullYear(").append(calendar.get(Calendar.YEAR)).append(");"); b.append("\ndefaultDate.setDate(").append(calendar.get(Calendar.DAY_OF_MONTH)).append(");"); b.append("\ndefaultDate.setMonth(").append(calendar.get(Calendar.MONTH)).append(");"); b.append("\ndefaultDate.setHours(").append(calendar.get(Calendar.HOUR_OF_DAY)).append(");"); b.append("\ndefaultDate.setMinutes(").append(calendar.get(Calendar.MINUTE)).append(");\n"); } b.append("\nCalendar.setup(\n{"); // Append specific settings for (Iterator iter = additionalSettings.keySet().iterator(); iter.hasNext();) { String option = (String) iter.next(); b.append("\n\t\t").append(option).append(" : ").append(additionalSettings.get(option)).append(","); } // Callbacks if (settings.getOnClose() != null) { b.append("\n\t\tonClose : ").append(onClose.getCallbackFunctionName()).append(","); } if (settings.getOnSelect() != null) { b.append("\n\t\tonSelect : ").append(onSelect.getCallbackFunctionName()).append(","); } if (settings.getOnUpdate() != null) { b.append("\n\t\tonUpdate : ").append(onUpdate.getCallbackFunctionName()).append(","); } if (defaultDate != null) { b.append("\n\t\tdate : defaultDate,"); } String pattern = null; if (dateConverter == null) { dateConverter = getDateConverter(); } DateFormat df = dateConverter.getDateFormat(getDatePickerLocale()); if (df instanceof SimpleDateFormat) { pattern = ((SimpleDateFormat) df).toPattern(); } b.append(settings.toScript(getDatePickerLocale(), pattern)); int last = b.length() - 1; if (',' == b.charAt(last)) { b.deleteCharAt(last); } b.append("\n});"); return b; }
From source file:com.mylab.wicket.jpa.ui.pages.select2.AbstractSelect2Choice.java
License:Apache License
/** * this method will add default options//from ww w . j ava2 s.c om * * @param markupStream * The markup stream * @param openTag * The open tag for the body */ @Override public void onComponentTagBody(final MarkupStream markupStream, final ComponentTag openTag) { final AppendingStringBuffer buffer = new AppendingStringBuffer(); M currentValue = getCurrentValue(); if (currentValue instanceof Collection) { @SuppressWarnings("unchecked") Collection<T> choices = (Collection<T>) currentValue; for (T choice : choices) { addOption(choice, buffer); } } else { if (currentValue != null) { @SuppressWarnings("unchecked") T choice = (T) currentValue; addOption(choice, buffer); } } replaceComponentTagBody(markupStream, openTag, buffer); }
From source file:com.servoy.j2db.server.headlessclient.dataui.WebCellBasedView.java
License:Open Source License
public String getRowSelectionScript(List<Integer> indexToUpdate) { if (currentData == null) return null; if (!hasOnRender() && (bgColorScript != null || hasOddEvenSelected()) && indexToUpdate != null) { int firstRow = table.isPageableMode() ? table.getCurrentPage() * table.getRowsPerPage() : table.getStartIndex(); int lastRow = firstRow + table.getViewSize() - 1; int[] newSelectedIndexes = getSelectedIndexes(); AppendingStringBuffer sab = new AppendingStringBuffer(); for (int rowIdx : indexToUpdate) { ArrayList<String> bgRuntimeColorjsArray = new ArrayList<String>(); ArrayList<String> fgRuntimeColorjsArray = new ArrayList<String>(); ArrayList<String> fstyleJsAray = new ArrayList<String>(); ArrayList<String> fweightJsAray = new ArrayList<String>(); ArrayList<String> fsizeJsAray = new ArrayList<String>(); ArrayList<String> ffamilyJsAray = new ArrayList<String>(); ArrayList<String> bstyleJsAray = new ArrayList<String>(); ArrayList<String> bwidthJsAray = new ArrayList<String>(); ArrayList<String> bcolorJsAray = new ArrayList<String>(); if (rowIdx >= firstRow && rowIdx <= lastRow) { ListItem<IRecordInternal> selectedListItem = (ListItem<IRecordInternal>) table .get(Integer.toString(rowIdx)); if (selectedListItem != null) { String selectedId = selectedListItem.getMarkupId(); boolean isSelected = Arrays.binarySearch(newSelectedIndexes, rowIdx) >= 0; // IF ONLY SELCTED STYLE RULE is defined then apply runtimeComonent style properties if (bgColorScript == null && !isSelected && (getRowOddStyle().getAttributeCount() == 0) && (getRowEvenStyle().getAttributeCount() == 0)) { Iterable<? extends Component> it = Utils.iterate(selectedListItem.iterator()); Component cellContents; for (Component c : it) { if (c instanceof CellContainer) { CellContainer cell = (CellContainer) c; cellContents = cell.iterator().next(); } else { cellContents = c; }//from w ww . j av a 2 s . com if (cellContents instanceof IScriptableProvider) { IScriptable scriptableComponent = ((IScriptableProvider) cellContents) .getScriptObject(); if (scriptableComponent instanceof IRuntimeComponent) { IRuntimeComponent runtimeComponent = (IRuntimeComponent) scriptableComponent; //bgcolor bgRuntimeColorjsArray.add(runtimeComponent.getBgcolor()); //fgcolor fgRuntimeColorjsArray.add(runtimeComponent.getFgcolor()); // font style String fontStyle = runtimeComponent.getFont(); StringBuilder fstyle = new StringBuilder(""), //$NON-NLS-1$ fweight = new StringBuilder(""), fsize = new StringBuilder(""), //$NON-NLS-1$//$NON-NLS-2$ ffamily = new StringBuilder(""); //$NON-NLS-1$ splitFontStyle(fontStyle, fstyle, fweight, fsize, ffamily); fstyleJsAray.add(fstyle.toString()); fweightJsAray.add(fweight.toString()); fsizeJsAray.add(fsize.toString()); ffamilyJsAray.add(ffamily.toString()); // border style String borderStyle = runtimeComponent.getBorder(); StringBuilder bstyle = new StringBuilder(""), //$NON-NLS-1$ bwidth = new StringBuilder(""), bcolor = new StringBuilder(""); //$NON-NLS-1$ //$NON-NLS-2$ splitBorderStyle(borderStyle, bstyle, bwidth, bcolor); bstyleJsAray.add(bstyle.toString()); bwidthJsAray.add(bwidth.toString()); bcolorJsAray.add(bcolor.toString()); } } } } String selectedColor = null, selectedFgColor = null, selectedFont = null, selectedBorder = null; selectedColor = getListItemBgColor(selectedListItem, isSelected, true); if (!isListViewMode()) { selectedFgColor = getListItemFgColor(selectedListItem, isSelected, true); selectedFont = getListItemFont(selectedListItem, isSelected); selectedBorder = getListItemBorder(selectedListItem, isSelected); } selectedColor = (selectedColor == null ? "" : selectedColor.toString()); //$NON-NLS-1$ selectedFgColor = (selectedFgColor == null) ? "" : selectedFgColor.toString(); //$NON-NLS-1$ // font styles StringBuilder fstyle = new StringBuilder(""), fweight = new StringBuilder(""), //$NON-NLS-1$//$NON-NLS-2$ fsize = new StringBuilder(""), //$NON-NLS-1$ ffamily = new StringBuilder(""); //$NON-NLS-1$ splitFontStyle(selectedFont, fstyle, fweight, fsize, ffamily); //border styles StringBuilder bstyle = new StringBuilder(""), bwidth = new StringBuilder(""), //$NON-NLS-1$//$NON-NLS-2$ bcolor = new StringBuilder(""); //$NON-NLS-1$ splitBorderStyle(selectedBorder, bstyle, bwidth, bcolor); if (bgColorScript == null && !isSelected && (getRowOddStyle().getAttributeCount() == 0) && (getRowEvenStyle().getAttributeCount() == 0) && !isListViewMode()) { //backgroundcolor and color are sent as final inline string sab.append("Servoy.TableView.setRowStyle('"). //$NON-NLS-1$ append(selectedId).append("', "). //$NON-NLS-1$ append(toJsArrayString(bgRuntimeColorjsArray, "background-color:")).append(","). //$NON-NLS-1$ append(toJsArrayString(fgRuntimeColorjsArray, "color:")).append(","). //$NON-NLS-1$ append(toJsArrayString(fstyleJsAray, "")).append(", "). //$NON-NLS-1$ append(toJsArrayString(fweightJsAray, "")).append(", "). //$NON-NLS-1$ append(toJsArrayString(fsizeJsAray, "")).append(", "). //$NON-NLS-1$ append(toJsArrayString(ffamilyJsAray, "")).append(", "). //$NON-NLS-1$ append(toJsArrayString(bstyleJsAray, "")).append(", "). //$NON-NLS-1$ append(toJsArrayString(bwidthJsAray, "")).append(","). //$NON-NLS-1$ append(toJsArrayString(bcolorJsAray, "")).append(","). //$NON-NLS-1$ append(isListViewMode()).append(");\n"); //$NON-NLS-1$ } else { sab.append("Servoy.TableView.setRowStyle('"). //$NON-NLS-1$ append(selectedId).append("', '"). //$NON-NLS-1$ append(selectedColor).append("', '"). //$NON-NLS-1$ append(selectedFgColor).append("', '"). //$NON-NLS-1$ append(fstyle).append("', '"). //$NON-NLS-1$ append(fweight).append("', '"). //$NON-NLS-1$ append(fsize).append("', '"). //$NON-NLS-1$ append(ffamily).append("', '"). //$NON-NLS-1$ append(bstyle).append("', '"). //$NON-NLS-1$ append(bwidth).append("', '"). //$NON-NLS-1$ append(bcolor).append("', "). //$NON-NLS-1$ append(isListViewMode()).append(");\n"); //$NON-NLS-1$ } } } } String rowSelectionScript = sab.toString(); if (rowSelectionScript.length() > 0) return rowSelectionScript; } return null; }
From source file:com.tysanclan.site.projectewok.components.ConfirmationLink.java
License:Open Source License
@Override protected CharSequence getOnClickScript(CharSequence url) { AppendingStringBuffer scriptBuffer = new AppendingStringBuffer(); scriptBuffer.append("return confirm('"); scriptBuffer.append(confirmMessage); scriptBuffer.append("');"); return scriptBuffer; }
From source file:ontopoly.components.AjaxParentFormChoiceComponentUpdatingBehavior.java
License:Apache License
@Override public void renderHead(IHeaderResponse response) { super.renderHead(response); AppendingStringBuffer asb = new AppendingStringBuffer(); asb.append("function attachChoiceHandler(markupId, callbackScript) {\n"); asb.append(" var inputNode = wicketGet(markupId);\n"); asb.append(" var inputType = inputNode.type.toLowerCase();\n"); asb.append(" if (inputType == 'checkbox' || inputType == 'radio') {\n"); asb.append(" Wicket.Event.add(inputNode, 'click', callbackScript);\n"); asb.append(" }\n"); asb.append("}\n"); response.renderJavascript(asb, "attachChoiceParent"); }
From source file:org.apache.isis.viewer.wicket.ui.panels.PromptFormAbstract.java
License:Apache License
@Override protected void appendDefaultButtonField() { AppendingStringBuffer buffer = new AppendingStringBuffer(); buffer.append(//from www . ja va2 s . c om "<div style=\"width:0px;height:0px;position:absolute;left:-100px;top:-100px;overflow:hidden\">"); buffer.append("<input type=\"text\" tabindex=\"-1\" autocomplete=\"off\"/>"); Component submittingComponent = (Component) this.defaultSubmittingComponent(); buffer.append("<input type=\"submit\" tabindex=\"-1\" name=\""); buffer.append(this.defaultSubmittingComponent().getInputName()); buffer.append("\" onclick=\" var b=document.getElementById(\'"); buffer.append(submittingComponent.getMarkupId()); buffer.append( "\'); if (b!=null&&b.onclick!=null&&typeof(b.onclick) != \'undefined\') { var r = Wicket.bind(b.onclick, b)(); if (r != false) b.click(); } else { b.click(); }; return false;\" "); buffer.append(" />"); buffer.append("</div>"); this.getResponse().write(buffer); }