Пример #1
0
		/**
     * Adds a field to the list of fields that will be returned from a search. Each field represents
     * a column in the report. The order of the columns in the report will honor the sequence in
     * which they were added.
     *
     * @param variable variable name of the new column. This value will be used in
     *       {@link #addItemFields} when adding reported items.
     * @param label label that corresponds to the new column. Optional parameter.
     * @param type indicates the type of field of the new column. Optional parameter.
     */
		public void AddReportedField(String variable, String label, FormField.Type type) {
			XElement reported = element.Element("reported");
			lock (element) {
				if (reported == null) {
					reported = element.Element("reported");
					if (reported == null) {
                        reported = new XElement("reported");
						element.Add(reported);
					}
				}
			}
		    var fieldElement = new XElement("field");
            reported.Add(fieldElement);

			FormField newField = new FormField(fieldElement);
			newField.SetVariable(variable);
			newField.SetType(type);
			newField.SetLabel(label);
		}
		public void setUp() {
			// reset the element before every test.
			final Element emptyElement = DF.createDocument().addElement("field");
			field = new FormField(emptyElement);
		}
Пример #3
0
		/**
     * Adds a new field as part of the form. The provided arguments are optional 
     * (they are allowed to be <tt>null</tt>).
     *
     * @param variable the unique identifier of the field in the context of the 
     * 		form. Optional parameter.
     * @param type an indicative of the format for the data. Optional parameter. 
     * @param label the label of the question. Optional parameter.
     * @return the newly created field.
     */
		public FormField AddField(String variable, String label, FormField.Type? type) {
			FormField result = AddField();
		    if (!string.IsNullOrEmpty(variable))
		    {
		        result.SetVariable(variable);
		    }

			if (type != null) {
				result.SetType(type);
			}

			if (label != null && label.Trim().Length >= 0) {
				result.SetLabel(label);
			}

			return result;
		}