use of org.jivesoftware.smackx.xdatalayout.packet.DataLayout in project Smack by igniterealtime.
the class DataFormTest method testLayout.
@Test
public void testLayout() throws Exception {
//Build a Form
DataForm df = new DataForm(DataForm.Type.submit);
String instruction = "InstructionTest1";
df.addInstruction(instruction);
FormField field = new FormField("testField1");
df.addField(field);
DataLayout layout = new DataLayout("Label");
Fieldref reffield = new Fieldref("testField1");
layout.getPageLayout().add(reffield);
Section section = new Section("section Label");
section.getSectionLayout().add(new Text("SectionText"));
layout.getPageLayout().add(section);
layout.getPageLayout().add(new Text("PageText"));
df.addExtensionElement(layout);
assertNotNull(df.toXML());
String output = df.toXML().toString();
assertEquals(TEST_OUTPUT_2, output);
XmlPullParser parser = PacketParserUtils.getParserFor(output);
df = pr.parse(parser);
assertNotNull(df);
assertNotNull(df.getExtensionElements());
assertEquals(1, df.getExtensionElements().size());
Element element = df.getExtensionElements().get(0);
assertNotNull(element);
layout = (DataLayout) element;
assertEquals(3, layout.getPageLayout().size());
assertNotNull(df.toXML());
output = df.toXML().toString();
assertEquals(TEST_OUTPUT_2, output);
}
use of org.jivesoftware.smackx.xdatalayout.packet.DataLayout in project Smack by igniterealtime.
the class DataLayoutProvider method parse.
public static DataLayout parse(XmlPullParser parser) throws XmlPullParserException, IOException {
DataLayout dataLayout = new DataLayout(parser.getAttributeValue("", "label"));
parseLayout(dataLayout.getPageLayout(), parser);
return dataLayout;
}
Aggregations