Search in sources :

Example 1 with SelectSearchField

use of com.manydesigns.elements.fields.search.SelectSearchField in project Portofino by ManyDesigns.

the class SearchFormTest method testForm1.

public void testForm1() {
    SelectSearchField field = (SelectSearchField) form.get(0);
    // Controllo l'html prodotto
    field.toXhtml(buffer);
    writer.flush();
    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=\"\" selected=\"selected\">-- Select field1 --</option><option value=\"__notset__\">-- Not set --</option><option value=\"1\">a</option><option value=\"2\">b</option></select></div>", result);
}
Also used : SelectSearchField(com.manydesigns.elements.fields.search.SelectSearchField)

Example 2 with SelectSearchField

use of com.manydesigns.elements.fields.search.SelectSearchField in project Portofino by ManyDesigns.

the class SearchFormTest method testForm10.

// testo il form builder aggiungendo un selection provider a cascata su field2
public void testForm10() {
    DefaultSelectionProvider provider = new DefaultSelectionProvider("provider");
    provider.appendOption("v1", "ll", true);
    provider.appendOption("v2", "l2", true);
    provider.appendOption("v3", "l3", true);
    SearchFormBuilder builder = new SearchFormBuilder(AnnotatedBean3.class);
    builder.configSelectionProvider(provider, "field2");
    form = builder.build();
    SelectSearchField field = (SelectSearchField) form.get(1);
    // Controllo l'html prodotto
    field.toXhtml(buffer);
    writer.flush();
    String result = writer.toString();
    assertEquals("<div class=\"form-group\"><label for=\"field2\" class=\"control-label\">Field2</label><select id=\"field2\" name=\"field2\" class=\"form-control\"><option value=\"\" selected=\"selected\">-- Select field2 --</option><option value=\"__notset__\">-- Not set --</option><option value=\"v1\">ll</option><option value=\"v2\">l2</option><option value=\"v3\">l3</option></select></div>", result);
}
Also used : SelectSearchField(com.manydesigns.elements.fields.search.SelectSearchField) DefaultSelectionProvider(com.manydesigns.elements.options.DefaultSelectionProvider)

Example 3 with SelectSearchField

use of com.manydesigns.elements.fields.search.SelectSearchField in project Portofino by ManyDesigns.

the class SearchFormTest method testForm9.

public void testForm9() {
    SelectSearchField field = (SelectSearchField) form.get(5);
    // Controllo l'html prodotto
    field.toXhtml(buffer);
    writer.flush();
    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\">a</option><option value=\"2\">b</option></select></div></div>", result);
}
Also used : SelectSearchField(com.manydesigns.elements.fields.search.SelectSearchField)

Example 4 with SelectSearchField

use of com.manydesigns.elements.fields.search.SelectSearchField in project Portofino by ManyDesigns.

the class SearchFormTest method testForm5.

// testo il form builder aggiungendo un selection provider su field2
public void testForm5() {
    DefaultSelectionProvider provider = new DefaultSelectionProvider("provider");
    provider.appendRow("v1", "ll", true);
    provider.appendRow("v2", "l2", true);
    provider.appendRow("v3", "l3", true);
    SearchFormBuilder builder = new SearchFormBuilder(AnnotatedBean3.class);
    builder.configSelectionProvider(provider, "field2");
    form = builder.build();
    SelectSearchField field = (SelectSearchField) form.get(1);
    // Controllo l'html prodotto
    field.toXhtml(buffer);
    writer.flush();
    String result = writer.toString();
    assertEquals("<div class=\"form-group\"><label for=\"field2\" class=\"control-label\">Field2</label><select id=\"field2\" name=\"field2\" class=\"form-control\"><option value=\"\" selected=\"selected\">-- Select field2 --</option><option value=\"__notset__\">-- Not set --</option><option value=\"v1\">ll</option><option value=\"v2\">l2</option><option value=\"v3\">l3</option></select></div>", result);
}
Also used : SelectSearchField(com.manydesigns.elements.fields.search.SelectSearchField) DefaultSelectionProvider(com.manydesigns.elements.options.DefaultSelectionProvider)

Example 5 with SelectSearchField

use of com.manydesigns.elements.fields.search.SelectSearchField in project Portofino by ManyDesigns.

the class SearchFormTest method testForm3.

// Lettura dato non esitente da request
public void testForm3() {
    SelectSearchField field = (SelectSearchField) form.get(0);
    req.setParameter("field1", "3");
    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);
}
Also used : SelectSearchField(com.manydesigns.elements.fields.search.SelectSearchField)

Aggregations

SelectSearchField (com.manydesigns.elements.fields.search.SelectSearchField)13 DefaultSelectionProvider (com.manydesigns.elements.options.DefaultSelectionProvider)2 FieldsManager (com.manydesigns.elements.fields.helpers.FieldsManager)1 SearchField (com.manydesigns.elements.fields.search.SearchField)1 SelectionModel (com.manydesigns.elements.options.SelectionModel)1 SelectionProvider (com.manydesigns.elements.options.SelectionProvider)1 PropertyAccessor (com.manydesigns.elements.reflection.PropertyAccessor)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1