Java Code Examples for net.sf.jasperreports.engine.JRParameter#getName()
The following examples show how to use
net.sf.jasperreports.engine.JRParameter#getName() .
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: JRBaseParameter.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
/** * */ protected JRBaseParameter(JRParameter parameter, JRBaseObjectFactory factory) { factory.put(parameter, this); name = parameter.getName(); description = parameter.getDescription(); valueClassName = parameter.getValueClassName(); nestedTypeName = parameter.getNestedTypeName(); isSystemDefined = parameter.isSystemDefined(); isForPrompting = parameter.isForPrompting(); evaluationTime = parameter.getEvaluationTime(); defaultValueExpression = factory.getExpression(parameter.getDefaultValueExpression()); propertiesMap = parameter.getPropertiesMap().cloneProperties(); }
Example 2
Source File: JRDesignDataset.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
/** * Inserts a parameter at the specified position into the dataset. * @param index the parameter position * @param parameter the parameter to insert * @throws JRException * @see net.sf.jasperreports.engine.JRDataset#getParameters() */ public void addParameter(int index, JRParameter parameter) throws JRException { if (parametersMap.containsKey(parameter.getName())) { throw new JRException( EXCEPTION_MESSAGE_KEY_DUPLICATE_PARAMETER, new Object[]{parameter.getName()}); } parametersList.add(index, parameter); parametersMap.put(parameter.getName(), parameter); getEventSupport().fireCollectionElementAddedEvent(PROPERTY_PARAMETERS, parameter, index); }
Example 3
Source File: JRVerifier.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
/** * */ private void verifyParameters(JRDesignDataset dataset) { JRParameter[] parameters = dataset.getParameters(); if (parameters != null && parameters.length > 0) { for(int index = 0; index < parameters.length; index++) { JRParameter parameter = parameters[index]; Object errorSource = parameter; if (parameter.isSystemDefined()) { errorSource = jasperDesign; } if (parameter.getName() == null || parameter.getName().trim().length() == 0) { addBrokenRule("Parameter name missing.", errorSource); } if (parameter.getValueClassName() == null) { addBrokenRule("Class not set for parameter : " + parameter.getName(), errorSource); } } } }
Example 4
Source File: JasperReportRunner.java From Knowage-Server with GNU Affero General Public License v3.0 | 4 votes |
protected Map adaptReportParams(Map parameters, JasperReport report) { logger.debug("IN"); String dateformat = (String) parameters.get("dateformat"); if (dateformat != null) { dateformat = dateformat.replaceAll("D", "d"); dateformat = dateformat.replaceAll("m", "M"); dateformat = dateformat.replaceAll("Y", "y"); } JRParameter[] reportParameters = report.getParameters(); ParametersDecoder decoder = new ParametersDecoder(); for (int i = 0; i < reportParameters.length; i++) { JRParameter aReportParameter = reportParameters[i]; String paramName = aReportParameter.getName(); logger.debug("Examining parameter with name [" + paramName + "] ..."); String paramValueString = null; if (parameters.get(paramName) instanceof String) { paramValueString = (String) parameters.get(paramName); } if (paramValueString == null) { logger.debug("No value found for parameter with name [" + paramName + "]"); continue; } if (paramValueString != null) { logger.debug("Value found for parameter with name [" + paramName + "] is [" + paramValueString + "]"); /* * The ParameterConverter converts a single value. Multi-value parameters are assumed to contains values that are String type. If they are not * Strings (list of dates, list of numbers, ...) the converter will not work. */ if (decoder.isMultiValues(paramValueString)) { logger.debug("Value found for parameter with name [" + paramName + "] is [" + paramValueString + "] and it is multivalue. " + "Cannot adapt parameter nature"); continue; } Class aReportParameterClass = aReportParameter.getValueClass(); Object newValue = ParameterConverter.convertParameter(aReportParameterClass, paramValueString, dateformat); if (newValue == null) newValue = paramValueString; if (!(newValue instanceof String)) { logger.debug("Updating parameter with name [" + paramName + "] to a " + newValue.getClass().getName() + "."); parameters.put(paramName, newValue); } } } logger.debug("OUT"); return parameters; }
Example 5
Source File: JRParameterDefaultValuesEvaluator.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
/** * Evaluates the default values for the parameters of a report. * * @param report the report * @param initialParameters initial parameter value map * @return a map containing parameter values indexed by parameter names * @throws JRException */ public static Map<String,Object> evaluateParameterDefaultValues(JasperReportsContext jasperReportsContext, JasperReport report, Map<String,Object> initialParameters) throws JRException { Map<String,Object> valuesMap = initialParameters == null ? new HashMap<String,Object>() : new HashMap<String,Object>(initialParameters); valuesMap.put(JRParameter.JASPER_REPORT, report); ObjectFactory factory = new ObjectFactory(); JRDataset reportDataset = report.getMainDataset(); JRFillDataset fillDataset = factory.getDataset(reportDataset); @SuppressWarnings("deprecation") JasperReportsContext depContext = net.sf.jasperreports.engine.util.LocalJasperReportsContext.getLocalContext(jasperReportsContext, initialParameters); fillDataset.setJasperReportsContext(depContext); fillDataset.createCalculator(report); fillDataset.initCalculator(); JRResourcesFillUtil.ResourcesFillContext resourcesContext = JRResourcesFillUtil.setResourcesFillContext(valuesMap); try { fillDataset.setParameterValues(valuesMap); Map<String,Object> parameterValues = new HashMap<String,Object>(); JRParameter[] parameters = reportDataset.getParameters(); for (int i = 0; i < parameters.length; i++) { JRParameter param = parameters[i]; if (!param.isSystemDefined()) { String name = param.getName(); Object value = fillDataset.getParameterValue(name); parameterValues.put(name, value); } } return parameterValues; } finally { fillDataset.disposeParameterContributors(); JRResourcesFillUtil.revertResourcesFillContext(resourcesContext); } }
Example 6
Source File: JRParameterEditorDialog.java From jdal with Apache License 2.0 | 4 votes |
public void initialize() { this.setTitle("ParĂ¡metros del informe"); // Main Panel containing parameter panel and button panel. JPanel borderPanel = new JPanel(); borderPanel.setBorder(BorderFactory.createTitledBorder("")); borderPanel.setMinimumSize(borderPanel.getPreferredSize()); borderPanel.setLayout(new BorderLayout()); // Button Panel JPanel buttonPanel = new JPanel(); JButton acceptButton = new JButton(new AcceptAction()); acceptButton.setText("Aceptar"); JButton cancelButton = new JButton(new CancelAction()); cancelButton.setText("Cancelar"); acceptButton.setAlignmentX(Component.CENTER_ALIGNMENT); cancelButton.setAlignmentX(Component.CENTER_ALIGNMENT); buttonPanel.add(acceptButton); buttonPanel.add(cancelButton); // Parameter panel JPanel paramPanel = new JPanel(new SpringLayout()); for (JRParameter param : parameters.values()) { ReportParameterEditor propertyEditor = editorFactory .getParameterEditor(param); propertyEditor.getEditor().addKeyListener(new KeyPressed()); JLabel label = new JLabel(param.getName()); label.setLabelFor(propertyEditor.getEditor()); paramPanel.add(label); paramPanel.add(propertyEditor.getEditor()); editors.put(param.getName(), propertyEditor); } borderPanel.add(paramPanel, BorderLayout.PAGE_START); borderPanel.add(buttonPanel, BorderLayout.PAGE_END); SpringUtilities.makeCompactGrid(paramPanel, parameters.size(), 2, // rows, // cols 6, 6, // initX, initY 6, 6); // xPad, yPad add(borderPanel); setLocationRelativeTo(null); pack(); }