/** * This function creates a <code> {@link CmsWidgetDialogParameter} </code> Object based * on the given properties.<p> * * @param property the base object property to map the parameter to / from * @param widget the widget used for this dialog-parameter * * @return a <code> {@link CmsWidgetDialogParameter} </code> Object */ protected CmsWidgetDialogParameter getDialogParameter(String property, I_CmsWidget widget) { return new CmsWidgetDialogParameter(m_htmlimport, property, PAGES[0], widget); }
int maxOccurs = base.getMaxOccurs(); if (base.isCollectionBase()) { || CmsStringUtil.isEmpty(base.getDialogPage()) || base.getDialogPage().equals(page); String id = CmsWidgetDialogParameter.createId(base.getName(), j); boolean required = (params.size() < base.getMinOccurs()) || (processedParameters.get(id) != null) || (!onPage && base.hasValue(j)); CmsWidgetDialogParameter param = new CmsWidgetDialogParameter(base, params.size(), j); param.setKeyPrefix(m_prefix); base.getWidget().setEditorValue(getCms(), processedParameters, this, param); params.add(param); m_widgetParamValues.put(base.getName(), params);
/** * Create a new Widget parameter.<p> * * @param base the base of the parameter * @param index the index of this parameter in the list */ public CmsWidgetDialogParameter(CmsWidgetDialogParameter base, int index) { this( null, base.m_defaultValue, base.getName(), base.getWidget(), base.getDialogPage(), base.getMinOccurs(), base.getMaxOccurs(), index); m_baseObject = base.m_baseObject; m_baseObjectProperty = base.m_baseObjectProperty; m_baseCollection = base.m_baseCollection; m_prefix = base.m_prefix; }
/** * Returns the value of the widget parameter with the given name and index, or <code>null</code> * if no such widget parameter is available.<p> * * @param name the widget parameter name to get the value for * @param index the widget parameter index * * @return the value of the widget parameter with the given name and index */ public String getParamValue(String name, int index) { List params = (List)m_widgetParamValues.get(name); if (params != null) { if ((index >= 0) && (index < params.size())) { CmsWidgetDialogParameter param = (CmsWidgetDialogParameter)params.get(index); if (param.getId().equals(CmsWidgetDialogParameter.createId(name, index))) { return param.getStringValue(getCms()); } } } return null; }
if ((dialogPage == null) || (base.getDialogPage() == null) || dialogPage.equals(base.getDialogPage())) { base.prepareCommit(); List<CmsWidgetDialogParameter> params = m_widgetParamValues.get(base.getName()); Iterator<CmsWidgetDialogParameter> j = params.iterator(); while (j.hasNext()) { CmsWidgetDialogParameter param = j.next(); try { param.commitValue(this); } catch (Exception e) { result.add(e);
List sequence = (List)getParameters().get(base.getName()); int count = sequence.size(); if (count < base.getMaxOccurs()) { addValue = true; if (count > base.getMinOccurs()) { removeValue = true; sequence.add(base); count = 1; if (base.getMinOccurs() == 0) { disabledElement = true; I_CmsWidget widget = p.getWidget(); if (p.hasError()) { result.append("error.png"); result.append("\" border=\"0\" alt=\"\"></td><td class=\"xmlTdError\">"); Throwable t = p.getError(); while (t != null) { if (t instanceof I_CmsThrowable) { result.append(keyDefault(A_CmsWidget.getLabelKey(p), p.getName())); if (count > 1) { result.append(" [").append(p.getIndex() + 1).append("]"); if (p.getIndex() == 0) {
List<CmsWidgetDialogParameter> sequence = getParameters().get(base.getName()); if (sequence.size() > 0) { CmsWidgetDialogParameter newParam = new CmsWidgetDialogParameter(base, index); params.add(index, newParam); param.setindex(i);
/** * Generates the HTML for the end of the widget dialog.<p> * * This HTML includes additional components, for example the <div> * tags containing the help texts.<p> * * @return the HTML for the end of the widget dialog */ public String getWidgetHtmlEnd() { StringBuffer result = new StringBuffer(32); // iterate over unique widgets from collector Iterator<CmsWidgetDialogParameter> i = getWidgets().iterator(); while (i.hasNext()) { CmsWidgetDialogParameter param = i.next(); result.append(param.getWidget().getDialogHtmlEnd(getCms(), this, param)); } return result.toString(); }
while (j.hasNext()) { CmsWidgetDialogParameter param = (CmsWidgetDialogParameter)j.next(); String value = param.getStringValue(getCms()); if (CmsStringUtil.isNotEmpty(value) && ((excludeDialogPage == null) || (!param.getDialogPage().equals(excludeDialogPage)))) { result.append("<input type=\"hidden\" name=\""); result.append(HIDDEN_PARAM_PREFIX); result.append(param.getId()); result.append("\" value=\""); String encoded = CmsEncoder.encode(value, getCms().getRequestContext().getEncoding());
/** * @see org.opencms.widgets.I_CmsWidgetParameter#getKey() */ public String getKey() { StringBuffer result = new StringBuffer(128); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_prefix)) { result.append(m_prefix); result.append('.'); } result.append(getName()); return result.toString(); }
/** * Sets the index to the provided value.<p> * * @param index the new index value to set */ public void setindex(int index) { m_index = index; m_id = createId(m_name, m_index); }
/** * Creates the dialog HTML for all defined widgets of the named dialog (page).<p> * * To get a more complex layout variation, you have to overwrite this method in your dialog class.<p> * * @param dialog the dialog (page) to get the HTML for * @return the dialog HTML for all defined widgets of the named dialog (page) */ protected String createDialogHtml(String dialog) { StringBuffer result = new StringBuffer(1024); // create table result.append(createWidgetTableStart()); // show error header once if there were validation errors result.append(createWidgetErrorHeader()); Iterator<CmsWidgetDialogParameter> i = getWidgets().iterator(); // iterate the type sequence while (i.hasNext()) { // get the current widget base definition CmsWidgetDialogParameter base = i.next(); // check if the element is on the requested dialog page if ((dialog == null) || dialog.equals(base.getDialogPage())) { // add the HTML for the dialog element result.append(createDialogRowHtml(base)); } } // close table result.append(createWidgetTableEnd()); return result.toString(); }
/** * Create a new Widget parameter.<p> * * @param base the base of the parameter * @param index the index of this parameter in the list */ public CmsWidgetDialogParameter(CmsWidgetDialogParameter base, int index) { this( null, base.m_defaultValue, base.getName(), base.getWidget(), base.getDialogPage(), base.getMinOccurs(), base.getMaxOccurs(), index); m_baseObject = base.m_baseObject; m_baseObjectProperty = base.m_baseObjectProperty; m_baseCollection = base.m_baseCollection; m_prefix = base.m_prefix; }
List<CmsWidgetDialogParameter> sequence = getParameters().get(base.getName()); int count = sequence.size(); if (count < base.getMaxOccurs()) { addValue = true; if (count > base.getMinOccurs()) { removeValue = true; sequence.add(base); count = 1; if (base.getMinOccurs() == 0) { disabledElement = true; I_CmsWidget widget = p.getWidget(); if (p.hasError()) { result.append("error.png"); result.append("\" border=\"0\" alt=\"\"></td><td class=\"xmlTdError\">"); Throwable t = p.getError(); while (t != null) { if (t instanceof I_CmsThrowable) { result.append(keyDefault(A_CmsWidget.getLabelKey(p), p.getName())); if (count > 1) { result.append(" [").append(p.getIndex() + 1).append("]"); if (p.getIndex() == 0) {
List sequence = (List)getParameters().get(base.getName()); if (sequence.size() > 0) { CmsWidgetDialogParameter newParam = new CmsWidgetDialogParameter(base, index); params.add(index, newParam); param.setindex(i);
if ((dialogPage == null) || (base.getDialogPage() == null) || dialogPage.equals(base.getDialogPage())) { base.prepareCommit(); List params = (List)m_widgetParamValues.get(base.getName()); Iterator j = params.iterator(); while (j.hasNext()) { CmsWidgetDialogParameter param = (CmsWidgetDialogParameter)j.next(); try { param.commitValue(this); } catch (Exception e) { result.add(e);
/** * Generates the HTML for the end of the widget dialog.<p> * * This HTML includes additional components, for example the <div> * tags containing the help texts.<p> * * @return the HTML for the end of the widget dialog */ public String getWidgetHtmlEnd() { StringBuffer result = new StringBuffer(32); // iterate over unique widgets from collector Iterator i = getWidgets().iterator(); while (i.hasNext()) { CmsWidgetDialogParameter param = (CmsWidgetDialogParameter)i.next(); result.append(param.getWidget().getDialogHtmlEnd(getCms(), this, param)); } return result.toString(); }
/** * Returns the value of the widget parameter with the given name and index, or <code>null</code> * if no such widget parameter is available.<p> * * @param name the widget parameter name to get the value for * @param index the widget parameter index * * @return the value of the widget parameter with the given name and index */ public String getParamValue(String name, int index) { List<CmsWidgetDialogParameter> params = m_widgetParamValues.get(name); if (params != null) { if ((index >= 0) && (index < params.size())) { CmsWidgetDialogParameter param = params.get(index); if (param.getId().equals(CmsWidgetDialogParameter.createId(name, index))) { return param.getStringValue(getCms()); } } } return null; }
while (j.hasNext()) { CmsWidgetDialogParameter param = j.next(); String value = param.getStringValue(getCms()); if (CmsStringUtil.isNotEmpty(value) && ((excludeDialogPage == null) || (!param.getDialogPage().equals(excludeDialogPage)))) { result.append("<input type=\"hidden\" name=\""); result.append(HIDDEN_PARAM_PREFIX); result.append(param.getId()); result.append("\" value=\""); String encoded = CmsEncoder.encode(value, getCms().getRequestContext().getEncoding());
/** * @see org.opencms.widgets.I_CmsWidgetParameter#getKey() */ public String getKey() { StringBuffer result = new StringBuffer(128); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_prefix)) { result.append(m_prefix); result.append('.'); } result.append(getName()); return result.toString(); }