Class JSONArrayRequestParameter
java.lang.Object
com.invirgance.convirgance.web.parameter.JSONArrayRequestParameter
- All Implemented Interfaces:
Parameter
A mechanism for converting multiple HTML form input elements with the same name
into an array of objects that can be processed by Convirgance.
For example, a sequence of suggested scheduling dates might look like this:
For example, a sequence of suggested scheduling dates might look like this:
<div>
<input type="date" name="available_date" value="2025-02-10">
<select name="time_of_day">
<option selected>Morning</option>
<option>Afternoon</option>
<option>Evening</option>
</select>
</div>
<div>
<input type="date" name="available_date" value="2025-02-12">
<select name="time_of_day">
<option>Morning</option>
<option>Afternoon</option>
<option selected>Evening</option>
</select>
</div>
The submitted form would contain the values in order, like this:
available_date=2025-02-10&time_of_day=Morning&available_date=2025-02-12&time_of_day=Evening
Using this Parameter with the available_date
and time_of_day keys like this:
<JSONArrayRequestParameter>
<name>fields</name>
<keys>available_date,time_of_day</keys>
</JSONArrayRequestParameter>
...results in the following value being returned:
[
{"available_date": "2025-02-10", "time_of_day": "Morning"},
{"available_date": "2025-02-12", "time_of_day": "Evening"}
]
This list of records could then be processed using the <children> feature
in the QueryConsumer or UpdateService features.- Author:
- jbanes
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionString[]getKeys()Get the array of parameter names that will be read into the arraygetName()Gets the name of this parameter.getValue(HttpRequest request) Extracts a value from the HTTP request.voidSet a list of request parameter names that will be included in the array.voidSets the name of the parameter to return
-
Constructor Details
-
JSONArrayRequestParameter
public JSONArrayRequestParameter()
-
-
Method Details
-
getName
Description copied from interface:ParameterGets the name of this parameter. -
setName
Sets the name of the parameter to return- Parameters:
name- the name of the parameter
-
getKeys
Get the array of parameter names that will be read into the array- Returns:
- an array of parameter names
-
setKeys
Set a list of request parameter names that will be included in the array. Note that the parameter names must appear the same number of times in the correct order to ensure that the values are correctly decoded into the correct object in theJSONArray.- Parameters:
keys-
-
getValue
Description copied from interface:ParameterExtracts a value from the HTTP request.
-