View | Details | Raw Unified | Return to bug 59967
Collapse All | Expand All

(-)src/components/org/apache/jmeter/extractor/HtmlExtractor.java (-1 / +11 lines)
Lines 76-81 Link Here
76
    
76
    
77
    private static final String UNDERSCORE = "_";  // $NON-NLS-1$
77
    private static final String UNDERSCORE = "_";  // $NON-NLS-1$
78
    
78
    
79
    private static final String DEFAULT_EMPTY_VALUE = "HtmlExtractor.default_empty_value"; // $NON-NLS-1$
80
79
    private Extractor extractor;
81
    private Extractor extractor;
80
82
81
    /**
83
    /**
Lines 102-108 Link Here
102
        int matchNumber = getMatchNumber();
104
        int matchNumber = getMatchNumber();
103
        final String defaultValue = getDefaultValue();
105
        final String defaultValue = getDefaultValue();
104
        
106
        
105
        if (defaultValue.length() > 0){// Only replace default if it is provided
107
        if (defaultValue.length() > 0  || isEmptyDefaultValue()){// Only replace default if it is provided or empty default value is explicitly requested
106
            vars.put(refName, defaultValue);
108
            vars.put(refName, defaultValue);
107
        }
109
        }
108
        
110
        
Lines 306-311 Link Here
306
        setProperty(DEFAULT, defaultValue);
308
        setProperty(DEFAULT, defaultValue);
307
    }
309
    }
308
310
311
    public void setDefaultEmptyValue(boolean defaultEmptyValue) {
312
        setProperty(DEFAULT_EMPTY_VALUE, defaultEmptyValue);
313
    }
314
    
309
    /**
315
    /**
310
     * Get the default value for the variable if no matches are found
316
     * Get the default value for the variable if no matches are found
311
     * @return The default value for the variable
317
     * @return The default value for the variable
Lines 313-316 Link Here
313
    public String getDefaultValue() {
319
    public String getDefaultValue() {
314
        return getPropertyAsString(DEFAULT);
320
        return getPropertyAsString(DEFAULT);
315
    }
321
    }
322
    
323
    public boolean isEmptyDefaultValue() {
324
        return getPropertyAsBoolean(DEFAULT_EMPTY_VALUE);
325
    }
316
}
326
}
(-)src/components/org/apache/jmeter/extractor/gui/HtmlExtractorGui.java (-3 / +30 lines)
Lines 22-32 Link Here
22
import java.awt.Component;
22
import java.awt.Component;
23
import java.awt.GridBagConstraints;
23
import java.awt.GridBagConstraints;
24
import java.awt.GridBagLayout;
24
import java.awt.GridBagLayout;
25
import java.awt.event.ItemEvent;
26
import java.awt.event.ItemListener;
25
import java.util.List;
27
import java.util.List;
26
28
27
import javax.swing.BorderFactory;
29
import javax.swing.BorderFactory;
28
import javax.swing.Box;
30
import javax.swing.Box;
29
import javax.swing.DefaultComboBoxModel;
31
import javax.swing.DefaultComboBoxModel;
32
import javax.swing.JCheckBox;
30
import javax.swing.JComboBox;
33
import javax.swing.JComboBox;
31
import javax.swing.JComponent;
34
import javax.swing.JComponent;
32
import javax.swing.JLabel;
35
import javax.swing.JLabel;
Lines 64-70 Link Here
64
67
65
    private JComboBox<String> extractorImplName;
68
    private JComboBox<String> extractorImplName;
66
69
67
70
    private JCheckBox emptyDefaultValue;
71
    
68
    public HtmlExtractorGui() {
72
    public HtmlExtractorGui() {
69
        super();
73
        super();
70
        init();
74
        init();
Lines 84-89 Link Here
84
            expressionField.setText(htmlExtractor.getExpression());
88
            expressionField.setText(htmlExtractor.getExpression());
85
            attributeField.setText(htmlExtractor.getAttribute());
89
            attributeField.setText(htmlExtractor.getAttribute());
86
            defaultField.setText(htmlExtractor.getDefaultValue());
90
            defaultField.setText(htmlExtractor.getDefaultValue());
91
            emptyDefaultValue.setSelected(htmlExtractor.isEmptyDefaultValue());
87
            matchNumberField.setText(htmlExtractor.getMatchNumberAsString());
92
            matchNumberField.setText(htmlExtractor.getMatchNumberAsString());
88
            refNameField.setText(htmlExtractor.getRefName());
93
            refNameField.setText(htmlExtractor.getRefName());
89
            extractorImplName.setSelectedItem(htmlExtractor.getExtractor());
94
            extractorImplName.setSelectedItem(htmlExtractor.getExtractor());
Lines 115-120 Link Here
115
            htmlExtractor.setExpression(expressionField.getText());
120
            htmlExtractor.setExpression(expressionField.getText());
116
            htmlExtractor.setAttribute(attributeField.getText());
121
            htmlExtractor.setAttribute(attributeField.getText());
117
            htmlExtractor.setDefaultValue(defaultField.getText());
122
            htmlExtractor.setDefaultValue(defaultField.getText());
123
            htmlExtractor.setDefaultEmptyValue(emptyDefaultValue.isSelected());
118
            htmlExtractor.setMatchNumber(matchNumberField.getText());
124
            htmlExtractor.setMatchNumber(matchNumberField.getText());
119
            if(extractorImplName.getSelectedIndex()< HtmlExtractor.getImplementations().length) {
125
            if(extractorImplName.getSelectedIndex()< HtmlExtractor.getImplementations().length) {
120
                htmlExtractor.setExtractor(HtmlExtractor.getImplementations()[extractorImplName.getSelectedIndex()]);
126
                htmlExtractor.setExtractor(HtmlExtractor.getImplementations()[extractorImplName.getSelectedIndex()]);
Lines 136-141 Link Here
136
        attributeField.setText(""); //$NON-NLS-1$
142
        attributeField.setText(""); //$NON-NLS-1$
137
        defaultField.setText(""); //$NON-NLS-1$
143
        defaultField.setText(""); //$NON-NLS-1$
138
        refNameField.setText(""); //$NON-NLS-1$
144
        refNameField.setText(""); //$NON-NLS-1$
145
        emptyDefaultValue.setSelected(false);
139
        matchNumberField.setText(""); //$NON-NLS-1$
146
        matchNumberField.setText(""); //$NON-NLS-1$
140
    }
147
    }
141
148
Lines 174-180 Link Here
174
    private JPanel makeParameterPanel() {        
181
    private JPanel makeParameterPanel() {        
175
        expressionField = new JLabeledTextField(JMeterUtils.getResString("expression_field")); //$NON-NLS-1$
182
        expressionField = new JLabeledTextField(JMeterUtils.getResString("expression_field")); //$NON-NLS-1$
176
        attributeField = new JLabeledTextField(JMeterUtils.getResString("attribute_field")); //$NON-NLS-1$
183
        attributeField = new JLabeledTextField(JMeterUtils.getResString("attribute_field")); //$NON-NLS-1$
177
        defaultField = new JLabeledTextField(JMeterUtils.getResString("default_value_field")); //$NON-NLS-1$
178
        refNameField = new JLabeledTextField(JMeterUtils.getResString("ref_name_field")); //$NON-NLS-1$
184
        refNameField = new JLabeledTextField(JMeterUtils.getResString("ref_name_field")); //$NON-NLS-1$
179
        matchNumberField = new JLabeledTextField(JMeterUtils.getResString("match_num_field")); //$NON-NLS-1$
185
        matchNumberField = new JLabeledTextField(JMeterUtils.getResString("match_num_field")); //$NON-NLS-1$
180
186
Lines 190-196 Link Here
190
        addField(panel, matchNumberField, gbc);
196
        addField(panel, matchNumberField, gbc);
191
        resetContraints(gbc);
197
        resetContraints(gbc);
192
        gbc.weighty = 1;
198
        gbc.weighty = 1;
193
        addField(panel, defaultField, gbc);
199
        
200
        defaultField = new JLabeledTextField(JMeterUtils.getResString("default_value_field")); //$NON-NLS-1$
201
        List<JComponent> item = defaultField.getComponentList();
202
        panel.add(item.get(0), gbc.clone());
203
        JPanel p = new JPanel(new BorderLayout());
204
        p.add(item.get(1), BorderLayout.WEST);
205
        emptyDefaultValue = new JCheckBox(JMeterUtils.getResString("cssjquery_empty_default_value"));
206
        emptyDefaultValue.addItemListener(new ItemListener() {
207
            @Override
208
            public void itemStateChanged(ItemEvent e) {
209
                if(emptyDefaultValue.isSelected()) {
210
                    defaultField.setText("");
211
                }
212
                defaultField.setEnabled(!emptyDefaultValue.isSelected());
213
            }
214
        });
215
        p.add(emptyDefaultValue, BorderLayout.CENTER);
216
        gbc.gridx++;
217
        gbc.weightx = 1;
218
        gbc.fill = GridBagConstraints.HORIZONTAL;
219
        panel.add(p, gbc.clone());
220
        
194
        return panel;
221
        return panel;
195
    }
222
    }
196
223
(-)src/core/org/apache/jmeter/resources/messages.properties (+1 lines)
Lines 214-219 Link Here
214
critical_section_controller_label=Lock name
214
critical_section_controller_label=Lock name
215
critical_section_controller_title=Critical Section Controller
215
critical_section_controller_title=Critical Section Controller
216
cssjquery_attribute=Attribute\:
216
cssjquery_attribute=Attribute\:
217
cssjquery_empty_default_value=Use empty default value
217
cssjquery_tester_error=An error occured evaluating expression:{0}, error:{1}
218
cssjquery_tester_error=An error occured evaluating expression:{0}, error:{1}
218
cssjquery_impl=CSS/JQuery implementation\:
219
cssjquery_impl=CSS/JQuery implementation\:
219
cssjquery_render_no_text=Data response result isn't text.
220
cssjquery_render_no_text=Data response result isn't text.
(-)src/core/org/apache/jmeter/resources/messages_fr.properties (-2 / +3 lines)
Lines 207-212 Link Here
207
critical_section_controller_label=Nom du verrou
207
critical_section_controller_label=Nom du verrou
208
critical_section_controller_title=Contr\u00F4leur Section critique
208
critical_section_controller_title=Contr\u00F4leur Section critique
209
cssjquery_attribute=Attribut
209
cssjquery_attribute=Attribut
210
cssjquery_empty_default_value=Utiliser la cha\u00EEne vide comme valeur par d\u00E9faut
210
cssjquery_impl=Impl\u00E9mentation CSS/JQuery\:
211
cssjquery_impl=Impl\u00E9mentation CSS/JQuery\:
211
cssjquery_render_no_text=Les donn\u00E9es de r\u00E9ponse ne sont pas du texte.
212
cssjquery_render_no_text=Les donn\u00E9es de r\u00E9ponse ne sont pas du texte.
212
cssjquery_tester_button_test=Tester
213
cssjquery_tester_button_test=Tester
Lines 219-227 Link Here
219
database_conn_pool_max_usage=Utilisation max pour chaque connexion\:
220
database_conn_pool_max_usage=Utilisation max pour chaque connexion\:
220
database_conn_pool_props=Pool de connexions \u221A\u2020 la base de donn\u221A\u00A9es
221
database_conn_pool_props=Pool de connexions \u221A\u2020 la base de donn\u221A\u00A9es
221
database_conn_pool_size=Nombre de Connexions dans le Pool\:
222
database_conn_pool_size=Nombre de Connexions dans le Pool\:
222
database_conn_pool_title=Valeurs par d\u221A\u00A9faut du Pool de connexions JDBC
223
database_conn_pool_title=Valeurs par d\u00E9faut du Pool de connexions JDBC
223
database_driver_class=Classe du Driver\:
224
database_driver_class=Classe du Driver\:
224
database_login_title=Valeurs par d\u221A\u00A9faut de la base de donn\u221A\u00A9es JDBC
225
database_login_title=Valeurs par d\u00E9faut de la base de donn\u221A\u00A9es JDBC
225
database_sql_query_string=Requ\u00EAte SQL \:
226
database_sql_query_string=Requ\u00EAte SQL \:
226
database_sql_query_title=Requ\u00EAte SQL JDBC par d\u00E9faut
227
database_sql_query_title=Requ\u00EAte SQL JDBC par d\u00E9faut
227
database_testing_title=Requ\u221A\u2122te JDBC
228
database_testing_title=Requ\u221A\u2122te JDBC
(-)xdocs/usermanual/component_reference.xml (+10 lines)
Lines 5656-5661 Link Here
5656
        In this case, remove the default value once debugging is complete.
5656
        In this case, remove the default value once debugging is complete.
5657
        </p> 
5657
        </p> 
5658
        </property>
5658
        </property>
5659
        <property name="Use empty default value" required="No">
5660
        If the checkbox is checked and <code>Default Value</code> is empty, then JMeter will set the variable to empty string instead of not setting it.
5661
        Thus when you will for example use <code>${var}</code> (if <code>Reference Name</code> is var) in your Test Plan, if the extracted value is not found then 
5662
        <code>${var}</code> will be equal to empty string instead of containing <code>${var}</code> which may be useful if extracted value is optional.
5663
        </property>
5659
</properties>
5664
</properties>
5660
<p>
5665
<p>
5661
    If the match number is set to a non-negative number, and a match occurs, the variables are set as follows:
5666
    If the match number is set to a non-negative number, and a match occurs, the variables are set as follows:
Lines 5765-5770 Link Here
5765
        In this case, remove the default value once debugging is complete.
5770
        In this case, remove the default value once debugging is complete.
5766
        </p> 
5771
        </p> 
5767
        </property>
5772
        </property>
5773
        <property name="Use empty default value" required="No">
5774
        If the checkbox is checked and <code>Default Value</code> is empty, then JMeter will set the variable to empty string instead of not setting it.
5775
        Thus when you will for example use <code>${var}</code> (if <code>Reference Name</code> is var) in your Test Plan, if the extracted value is not found then 
5776
        <code>${var}</code> will be equal to empty string instead of containing <code>${var}</code> which may be useful if extracted value is optional.
5777
        </property>
5768
</properties>
5778
</properties>
5769
<p>
5779
<p>
5770
    If the match number is set to a non-negative number, and a match occurs, the variables are set as follows:
5780
    If the match number is set to a non-negative number, and a match occurs, the variables are set as follows:

Return to bug 59967