List of usage examples for org.apache.wicket Component getSession
public Session getSession()
From source file:gr.abiss.calipso.wicket.components.formfields.MultipleValuesTextField.java
License:Open Source License
/** * Return the value a raw HTML <code><table></code> with headings and summary. The original input is HTML escaped. * @param input// w w w. j a v a 2s .c om * @return */ public static String toHtmlSafeTable(String input, FieldConfig fieldConfig, Localizer localizer, Component callerComponent) { String escapedInput = XmlUtils.escapeHTML(HtmlUtils.htmlUnescape(input)); StringBuffer html = new StringBuffer(); List<String> escapedLines = MultipleValuesTextField.getValueRows(escapedInput);// HtmlUtils.htmlEscape(input)); final FieldSummaryHelper helper = new FieldSummaryHelper(fieldConfig); if (CollectionUtils.isNotEmpty(escapedLines)) { html.append("<table cellspacing=\"1\" cellpadding=\"0\" class=\"custom-attribute-tabular\">"); if (fieldConfig != null && localizer != null && callerComponent != null) { List<FieldConfig> configs = fieldConfig.getSubFieldConfigs(); if (CollectionUtils.isNotEmpty(configs)) { html.append("<thead><tr>"); int styleMinWidth = ((100 / configs.size()) / 3) * 2; for (FieldConfig config : configs) { html.append("<th style=\"min-width:" + styleMinWidth + "%\">"); html.append(localizer.getString(config.getLabelKey(), callerComponent)); html.append("</th>"); } html.append("</tr></thead>"); } } html.append("<tbody>"); int lineIndex = 1; for (String line : escapedLines) { List<String> escapedLineSubvalues = MultipleValuesTextField.getValueRowSubvalues(line); if (CollectionUtils.isNotEmpty(escapedLineSubvalues)) { int styleWidth = 100 / escapedLineSubvalues.size(); html.append(lineIndex % 2 == 0 ? "<tr class=\"even\">" : "<tr class=\"odd\">"); int cellIndex = 0; for (String subValue : escapedLineSubvalues) { FieldConfig subconfig = fieldConfig != null && CollectionUtils.isNotEmpty(fieldConfig.getSubFieldConfigs()) ? fieldConfig.getSubFieldConfigs().get(cellIndex) : FieldConfig.FALLBACK_SUBCONFIG; html.append("<td ").append(subconfig.isNumberType() ? " class=\"right\">" : ">"); html.append(helper.parseFormat(subconfig, subValue, callerComponent != null ? callerComponent.getSession().getLocale() : Locale.ENGLISH)); html.append("</td>"); helper.updateSummary(subconfig, subValue); cellIndex++; } html.append("</tr>"); } lineIndex++; } html.append("</tbody>"); if (fieldConfig != null && CollectionUtils.isNotEmpty(fieldConfig.getSubFieldConfigs())) { html.append("<tfoot>"); html.append( (helper.getSummaryEntriesCount()) % 2 == 0 ? "<tr class=\"even\">" : "<tr class=\"odd\">"); for (FieldConfig subConfig : fieldConfig.getSubFieldConfigs()) { html.append("<td").append(subConfig.isNumberType() ? " class=\"right\">" : ">"); if (callerComponent != null && StringUtils.isNotBlank(subConfig.getSummary())) { html.append( callerComponent.getLocalizer().getString(subConfig.getSummary(), callerComponent)) .append(": "); } html.append(helper.getCalculatedSummary(subConfig)); html.append("</td>"); } html.append("</tr></tfoot>"); } html.append("</table>"); } // String html = escapedInput.replaceAll("\\n", "<br />") // .replaceAll(MultipleValuesTextField.SEPARATOR_LINE_SUBVALUE_REGEXP, " "); return html.toString(); }
From source file:gr.abiss.calipso.wicket.ComponentUtils.java
License:Open Source License
public static User getPrincipal(Component c) { return ((CalipsoSession) c.getSession()).getUser(); }
From source file:gr.abiss.calipso.wicket.ComponentUtils.java
License:Open Source License
public static void setCurrentSpace(Component c, Space space) { ((CalipsoSession) c.getSession()).setCurrentSpace(space); }
From source file:gr.abiss.calipso.wicket.ComponentUtils.java
License:Open Source License
public static Space getCurrentSpace(Component c) { return ((CalipsoSession) c.getSession()).getCurrentSpace(); }
From source file:gr.abiss.calipso.wicket.ComponentUtils.java
License:Open Source License
public static void setCurrentItemSearch(Component c, ItemSearch itemSearch) { ((CalipsoSession) c.getSession()).setItemSearch(itemSearch); }
From source file:gr.abiss.calipso.wicket.ComponentUtils.java
License:Open Source License
public static ItemSearch getCurrentItemSearch(Component c) { return ((CalipsoSession) c.getSession()).getItemSearch(); }
From source file:gr.abiss.calipso.wicket.ComponentUtils.java
License:Open Source License
public static void refreshPrincipal(Component c) { User temp = getCalipso(c).loadUser(getPrincipal(c).getId()); // loadUserByUsername forces hibernate eager load CalipsoSession session = (CalipsoSession) c.getSession(); User user = (User) getCalipso(c).loadUserByUsername(temp.getLoginName()); session.setUser(user);/* www . j a va 2 s. c o m*/ }
From source file:gr.interamerican.wicket.utils.TestWicketUtils.java
License:Open Source License
/** * Test ValidateNotNull//from w ww . j av a 2 s . c o m */ @Test public void testValidateNotNull() { Component component = new EmptyPanel("panelid"); //$NON-NLS-1$ IModel<Void> model = null; DropDownChoice<String> formComponent = new DropDownChoice("id", model); //$NON-NLS-1$ WicketUtils.validateNotNull(component, formComponent); assertEquals(1, component.getSession().getFeedbackMessages().size()); }
From source file:gr.interamerican.wicket.utils.TestWicketUtils.java
License:Open Source License
/** * Test ValidateNotNull/*from w w w .j av a2 s .c om*/ */ @Test public void testValidateNotNull_withTreeArgs() { Component component = new EmptyPanel("panelid"); //$NON-NLS-1$ IModel<Void> model = null; DropDownChoice<String> formComponent = new DropDownChoice("id", model); //$NON-NLS-1$ String resourceKey = "1"; //$NON-NLS-1$ WicketUtils.validateNotNull(component, resourceKey, formComponent); assertEquals(1, component.getSession().getFeedbackMessages().size()); }
From source file:info.jtrac.wicket.ComponentUtils.java
License:Apache License
public static User getPrincipal(Component c) { return ((JtracSession) c.getSession()).getUser(); }