Search in sources :

Example 1 with FormField

use of org.openntf.domino.design.FormField in project org.openntf.domino by OpenNTF.

the class FormTest method getFormInfo.

private void getFormInfo(final Database db, final StringBuilder sb) {
    DesignForm form = db.getDesign().getForm("testForm");
    FormField field = form.addField();
    field.setName("EclipseTest");
    field.setKind(Kind.COMPUTED);
    field.setDefaultValueFormula("@Today");
    field.setFieldType(Type.DATETIME);
    FormField field2 = form.addField();
    field2.setName("EclipseTest2");
    field2.setKind(Kind.EDITABLE);
    field2.setDefaultValueFormula("Hello");
    field2.setAllowMultiValues(true);
    sb.append("Outputting explicit subforms for testForm");
    addNewLine(sb);
    List<String> subforms = form.getExplicitSubforms();
    for (String subformName : subforms) {
        sb.append(subformName);
        addNewLine(sb);
    }
    sb.append("Outputting computed subforms for testForm");
    addNewLine(sb);
    subforms = form.getComputedSubforms();
    for (String subformName : subforms) {
        sb.append(subformName);
        addNewLine(sb);
    }
}
Also used : DesignForm(org.openntf.domino.design.DesignForm) FormField(org.openntf.domino.design.FormField)

Example 2 with FormField

use of org.openntf.domino.design.FormField in project org.openntf.domino by OpenNTF.

the class FormCRUDTest method run.

@SuppressWarnings("unchecked")
@Override
public void run() {
    try {
        Session sess = Factory.getSession(SessionType.NATIVE);
        Database db = sess.getDatabase("PrivateTest.nsf");
        DesignForm form = db.getDesign().createForm();
        form.setName("EclipseTest");
        FormField field = form.addField();
        field.setName("EclipseTest");
        field.setKind(Kind.COMPUTED);
        field.setDefaultValueFormula("@Today");
        field.setFieldType(Type.DATETIME);
        FormField field2 = form.addField();
        field2.setName("EclipseTest2");
        field2.setKind(Kind.EDITABLE);
        field2.setDefaultValueFormula("Hello");
        field2.setAllowMultiValues(true);
        form.save();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Database(org.openntf.domino.Database) DesignForm(org.openntf.domino.design.DesignForm) FormField(org.openntf.domino.design.FormField) Session(org.openntf.domino.Session)

Example 3 with FormField

use of org.openntf.domino.design.FormField in project org.openntf.domino by OpenNTF.

the class Subform method addField.

@Override
public FormField addField() {
    XMLNode body = getBody();
    // Create an appropriate paragraph definition
    // $NON-NLS-1$
    XMLNode finalPardef = getDxl().selectSingleNode("//pardef[last()]");
    // $NON-NLS-1$
    int nextId = Integer.valueOf(finalPardef.getAttribute("id")) + 1;
    // $NON-NLS-1$
    XMLNode pardef = body.addChildElement("pardef");
    // $NON-NLS-1$
    pardef.setAttribute("id", String.valueOf(nextId));
    // Now create the par and the field
    // $NON-NLS-1$
    XMLNode par = body.addChildElement("par");
    // $NON-NLS-1$ //$NON-NLS-2$
    par.setAttribute("def", pardef.getAttribute("id"));
    // Now add the field
    // $NON-NLS-1$
    XMLNode field = par.addChildElement("field");
    // $NON-NLS-1$ //$NON-NLS-2$
    field.setAttribute("kind", "editable");
    // $NON-NLS-1$ //$NON-NLS-2$
    field.setAttribute("name", "");
    // $NON-NLS-1$ //$NON-NLS-2$
    field.setAttribute("type", "text");
    return new org.openntf.domino.design.impl.FormField(field);
}
Also used : XMLNode(org.openntf.domino.utils.xml.XMLNode) FormField(org.openntf.domino.design.FormField)

Aggregations

FormField (org.openntf.domino.design.FormField)3 DesignForm (org.openntf.domino.design.DesignForm)2 Database (org.openntf.domino.Database)1 Session (org.openntf.domino.Session)1 XMLNode (org.openntf.domino.utils.xml.XMLNode)1