Package org.jivesoftware.smackx

Examples of org.jivesoftware.smackx.FormField


            assertNotNull("No room configuration form", form);
            // Create a new form to submit based on the original form
            Form submitForm = form.createAnswerForm();
            // Add default answers to the form to submit
            for (Iterator<FormField> fields = form.getFields(); fields.hasNext();) {
                FormField field = fields.next();
                if (!FormField.TYPE_HIDDEN.equals(field.getType())
                    && field.getVariable() != null) {
                    // Sets the default value as the answer
                    submitForm.setDefaultAnswer(field.getVariable());
                }
            }
            List<String> owners = new ArrayList<String>();
            owners.add(getBareJID(0));
            submitForm.setAnswer("muc#roomconfig_roomowners", owners);
View Full Code Here


    @Test
    public void validateRoomWithForm()
    {
  DataForm dataForm = new DataForm("result");
 
  FormField desc = new FormField("muc#roominfo_description");
  desc.addValue("The place for all good witches!");
  dataForm.addField(desc);

  FormField subject = new FormField("muc#roominfo_subject");
  subject.addValue("Spells");
  dataForm.addField(subject);

  FormField occupants = new FormField("muc#roominfo_occupants");
  occupants.addValue("3");
  dataForm.addField(occupants);

  DiscoverInfo discoInfo = new DiscoverInfo();
  discoInfo.addExtension(dataForm);
  RoomInfo roomInfo = new RoomInfo(discoInfo);
View Full Code Here

            muc.create("testbot");

            // User1 sends an empty room configuration form which indicates that we want
            // an instant room
            Form form = new Form(Form.TYPE_SUBMIT);
            FormField field = new FormField("muc#roomconfig_whois");
            field.setType("list-single");
            form.addField(field);
            form.setAnswer("muc#roomconfig_whois", Arrays.asList("moderators"));
            muc.sendConfigurationForm(form);
        }
        catch (Exception e) {
View Full Code Here

        this.passwordProtected = info.containsFeature("muc_passwordprotected");
        this.persistent = info.containsFeature("muc_persistent");
        // Get the information based on the discovered extended information
        Form form = Form.getFormFrom(info);
        if (form != null) {
            FormField descField = form.getField("muc#roominfo_description");
            this.description = descField == null ? "" : descField.getValues().next();

            FormField subjField = form.getField("muc#roominfo_subject");
            this.subject = subjField == null ? "" : subjField.getValues().next();

            FormField occCountField = form.getField("muc#roominfo_occupants");
            this.occupantsCount = occCountField == null ? -1 : Integer.parseInt(occCountField.getValues()
                    .next());
        }
    }
View Full Code Here

            Item item = (Item) i.next();
            buf.append(item.toXML());
        }
        // Loop through all the form fields and append them to the string buffer
        for (Iterator i = getFields(); i.hasNext();) {
            FormField field = (FormField) i.next();
            buf.append(field.toXML());
        }
        buf.append("</").append(getElementName()).append(">");
        return buf.toString();
    }
View Full Code Here

        public String toXML() {
            StringBuilder buf = new StringBuilder();
            buf.append("<reported>");
            // Loop through all the form items and append them to the string buffer
            for (Iterator i = getFields(); i.hasNext();) {
                FormField field = (FormField) i.next();
                buf.append(field.toXML());
            }
            buf.append("</reported>");
            return buf.toString();
        }
View Full Code Here

        public String toXML() {
            StringBuilder buf = new StringBuilder();
            buf.append("<item>");
            // Loop through all the form items and append them to the string buffer
            for (Iterator i = getFields(); i.hasNext();) {
                FormField field = (FormField) i.next();
                buf.append(field.toXML());
            }
            buf.append("</item>");
            return buf.toString();
        }
View Full Code Here

        response.setFrom(streamInitiationOffer.getTo());
        response.setType(IQ.Type.RESULT);
        response.setPacketID(streamInitiationOffer.getPacketID());

        DataForm form = new DataForm(Form.TYPE_SUBMIT);
        FormField field = new FormField(
                FileTransferNegotiator.STREAM_DATA_FIELD_NAME);
        for (String namespace : namespaces) {
            field.addValue(namespace);
        }
        form.addField(field);

        response.setFeatureNegotiationForm(form);
        return response;
View Full Code Here

     *                       there is not an appropriate stream method.
     */
    public StreamNegotiator selectStreamNegotiator(
            FileTransferRequest request) throws XMPPException {
        StreamInitiation si = request.getStreamInitiation();
        FormField streamMethodField = getStreamMethodField(si
                .getFeatureNegotiationForm());

        if (streamMethodField == null) {
            String errorMessage = "No stream methods contained in packet.";
            XMPPError error = new XMPPError(XMPPError.Condition.bad_request, errorMessage);
View Full Code Here

        return selectedStreamNegotiator;
    }

    private FormField getStreamMethodField(DataForm form) {
        FormField field = null;
        for (Iterator<FormField> it = form.getFields(); it.hasNext();) {
            field = it.next();
            if (field.getVariable().equals(STREAM_DATA_FIELD_NAME)) {
                break;
            }
            field = null;
        }
        return field;
View Full Code Here

TOP

Related Classes of org.jivesoftware.smackx.FormField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.