use of com.manydesigns.elements.fields.search.SelectSearchField in project Portofino by ManyDesigns.
the class SearchFormTest method testForm4.
// Lettura da request vuota
public void testForm4() {
SelectSearchField field = (SelectSearchField) form.get(0);
field.readFromRequest(req);
field.toXhtml(buffer);
String result = writer.toString();
// Il dato non รจ nel modello
assertNull(field.getSelectionModel().getValue(0));
// Devo avere il campo vuoto selezionato
assertEquals("<div class=\"form-group\"><label for=\"field1\" class=\"control-label\">Field1</label><select id=\"field1\" name=\"field1\" class=\"form-control\"><option value=\"\" selected=\"selected\">-- Select field1 --</option><option value=\"__notset__\">-- Not set --</option><option value=\"1\">a</option><option value=\"2\">b</option></select></div>", result);
}
use of com.manydesigns.elements.fields.search.SelectSearchField in project Portofino by ManyDesigns.
the class SearchFormTest method testForm7.
public void testForm7() {
SelectSearchField field = (SelectSearchField) form.get(3);
// Controllo l'html prodotto
field.toXhtml(buffer);
writer.flush();
String result = writer.toString();
assertEquals("<div class=\"form-group\"><label for=\"field4\" class=\"control-label\">Field4</label><div class=\"form-control radio\"><input type=\"radio\" id=\"field4_0\" name=\"field4\" value=\"\" checked=\"checked\" /><label class=\"radio\" for=\"field4_0\">Not filtered</label><input type=\"radio\" id=\"field4_1\" name=\"field4\" value=\"__notset__\" /><label class=\"radio\" for=\"field4_1\">(not set)</label><input type=\"radio\" id=\"field4_2\" name=\"field4\" value=\"1\" /><label class=\"radio\" for=\"field4_2\">a</label><input type=\"radio\" id=\"field4_3\" name=\"field4\" value=\"2\" /><label class=\"radio\" for=\"field4_3\">b</label></div></div>", result);
}
use of com.manydesigns.elements.fields.search.SelectSearchField in project Portofino by ManyDesigns.
the class SearchFormTest method testForm2b.
// Lettura multipla da request con multipleselect
public void testForm2b() {
SelectSearchField field = (SelectSearchField) form.get(5);
String[] field6Values = { "1", "2" };
req.setParameter("field6", field6Values);
field.readFromRequest(req);
Object[] value = (Object[]) field.getSelectionModel().getValue(0);
assertEquals("1", (String) value[0]);
field.toXhtml(buffer);
String result = writer.toString();
assertEquals("<div class=\"form-group\"><label for=\"field6\" class=\"control-label\">Field6</label><div class=\"form-control multiple-select\"><select id=\"field6\" name=\"field6\" multiple=\"multiple\" size=\"5\"><option value=\"1\" selected=\"selected\">a</option><option value=\"2\" selected=\"selected\">b</option></select></div></div>", result);
StringBuilder sb = new StringBuilder();
field.toSearchString(sb, "UTF-8");
result = sb.toString();
assertEquals("field6=1,field6=2", result);
}
use of com.manydesigns.elements.fields.search.SelectSearchField in project Portofino by ManyDesigns.
the class SearchFormTest method testForm2.
// Lettura corretta da request
public void testForm2() {
SelectSearchField field = (SelectSearchField) form.get(0);
req.setParameter("field1", "1");
field.readFromRequest(req);
Object[] value = (Object[]) field.getSelectionModel().getValue(0);
assertEquals("1", (String) value[0]);
field.toXhtml(buffer);
String result = writer.toString();
assertEquals("<div class=\"form-group\"><label for=\"field1\" class=\"control-label\">Field1</label><select id=\"field1\" name=\"field1\" class=\"form-control\"><option value=\"\">-- Select field1 --</option><option value=\"__notset__\">-- Not set --</option><option value=\"1\" selected=\"selected\">a</option><option value=\"2\">b</option></select></div>", result);
StringBuilder sb = new StringBuilder();
field.toSearchString(sb, "UTF-8");
result = sb.toString();
assertEquals("field1=1", result);
}
use of com.manydesigns.elements.fields.search.SelectSearchField in project Portofino by ManyDesigns.
the class SearchFormTest method testForm6.
// **************************************************************************
// test DISPLAYMODE
// **************************************************************************
public void testForm6() {
SelectSearchField field = (SelectSearchField) form.get(2);
// Controllo l'html prodotto
field.toXhtml(buffer);
writer.flush();
String result = writer.toString();
assertEquals("<div class=\"form-group\"><label for=\"field3\" class=\"control-label\">Field3</label><input type=\"hidden\" id=\"field3\" name=\"field3\" /><input id=\"field3_autocomplete\" type=\"text\" name=\"field3_autocomplete\" class=\"form-control\" /><script type=\"text/javascript\">setupAutocomplete('#field3_autocomplete', 'field3', 0, 'jsonAutocompleteSearchOptions', '#field3');</script></div>", result);
}
Aggregations